Class: Hyperfeed::Client
- Inherits:
-
Object
- Object
- Hyperfeed::Client
- Includes:
- ResourceBuilder
- Defined in:
- lib/hyperfeed.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
- #get(id = nil) ⇒ Object
-
#initialize(url, options) ⇒ Client
constructor
A new instance of Client.
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 = 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
#body ⇒ Object
Returns the value of attribute body.
12 13 14 |
# File 'lib/hyperfeed.rb', line 12 def body @body end |
#code ⇒ Object
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, = {}) new(url, ) 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 |