Class: Hyperfeed::Client

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

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.



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

def initialize(url, options)
  @options = options

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

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

Class Method Details

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



22
23
24
# File 'lib/hyperfeed.rb', line 22

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

Instance Method Details

#get(id = nil) ⇒ Object



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

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