Class: Hyperfeed::Client

Inherits:
Object
  • Object
show all
Includes:
ResourceBuilder
Defined in:
lib/hyperfeed.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ResourceBuilder

#build_results, #collect_fields, #generate_id, #get_media, #get_resource, #retrieve_resources_list

Constructor Details

#initialize(url, options) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hyperfeed.rb', line 14

def initialize(url, options)
  @options = options

  response = HttpMonkey.at(url).get
  self.code = response.code
  self.body = response.body
  raise "Error: #{response.code} - #{response.body}" unless response.code == 200

  content = Nokogiri::XML(response.body)
  @feed = OpenStruct.new(:url => url, :content => content)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



12
13
14
# File 'lib/hyperfeed.rb', line 12

def body
  @body
end

#codeObject

Returns the value of attribute code.



12
13
14
# File 'lib/hyperfeed.rb', line 12

def code
  @code
end

Class Method Details

.at(url, options = {}) ⇒ Object



26
27
28
# File 'lib/hyperfeed.rb', line 26

def self.at(url, options = {})
  new(url, options)
end

Instance Method Details

#get(id = nil) ⇒ Object



30
31
32
33
# File 'lib/hyperfeed.rb', line 30

def get(id = nil)
  return retrieve_resources_list(@feed, @options) unless id
  get_resource(@feed, id)
end