Class: Phearb::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/phearb/agent.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Agent

Returns a new instance of Agent.



8
9
10
# File 'lib/phearb/agent.rb', line 8

def initialize(url)
  @url = url
end

Instance Method Details

#fetch(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/phearb/agent.rb', line 12

def fetch(options = {})
  params = options.merge(fetch_url: @url)

  Timeout::timeout(Phearb.configuration.timeout.to_f) do
    http_response = RestClient.get(server_url, params: params)        
    Response.from_json(http_response)
  end
rescue Timeout::Error => exception
  raise Error::Timeout
end