class Algorithmia::Algorithm
Public Class Methods
new(client, endpoint)
click to toggle source
# File lib/algorithmia/algorithm.rb, line 4 def initialize(client, endpoint) @client = client @endpoint = '/v1/algo/' + endpoint @query = {} end
Public Instance Methods
pipe(input)
click to toggle source
# File lib/algorithmia/algorithm.rb, line 15 def pipe(input) client_timeout = (@query[:timeout] || 300) + 10 response = Algorithmia::Requester.new(@client).post(@endpoint, input, query: @query, headers: {}, timeout: client_timeout) Algorithmia::Response.new(response.parsed_response, @query[:output]) end
pipe_json(input)
click to toggle source
# File lib/algorithmia/algorithm.rb, line 21 def pipe_json(input) client_timeout = (@query[:timeout] || 300) + 10 headers = { 'Content-Type' => 'application/json' } response = Algorithmia::Requester.new(@client).post(@endpoint, input, query: @query, headers: headers, timeout: client_timeout) Algorithmia::Response.new(response.parsed_response, @query[:output]) end
set(options_hash)
click to toggle source
# File lib/algorithmia/algorithm.rb, line 10 def set(options_hash) @query.update(options_hash) self end