Class: Amazonian::Search
- Inherits:
-
Object
- Object
- Amazonian::Search
- Defined in:
- lib/amazonian.rb
Overview
Search
The Search class is used to neatly box up the Amazon REST API responses into Objects.
When using Amazonian.search you should receive an Search object. Search also attempts to autoboxe all of the Items returned in the search results into an array of Amazonian::Item objects.
A Hashie::Mash is used for the internal data representation and can be accessed over the raw attribute.
Instance Attribute Summary collapse
- #items ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(hash) ⇒ Search
constructor
A new instance of Search.
Constructor Details
#initialize(hash) ⇒ Search
Returns a new instance of Search.
232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/amazonian.rb', line 232 def initialize(hash) @raw = Hashie::Mash.new(hash) @items = [] if @raw.Items && @raw.Items.Item if @raw.Items.TotalResults.to_i > 1 @raw.Items.Item.each {|i| @items.push Amazonian::Item.new(i) } else @items.push Amazonian::Item.new(@raw.Items.Item) end end end |
Instance Attribute Details
#items ⇒ Object (readonly)
231 232 233 |
# File 'lib/amazonian.rb', line 231 def items @items end |