Class: ApiBucket::Yahooauction::Response
- Inherits:
-
Base::Response
- Object
- Base::Response
- ApiBucket::Yahooauction::Response
- Defined in:
- lib/api_bucket/yahooauction/response.rb
Instance Attribute Summary
Attributes inherited from Base::Response
Instance Method Summary collapse
- #first_item ⇒ Object
-
#initialize(xml) ⇒ Response
constructor
A new instance of Response.
-
#item_page ⇒ Object
Return current page no if :item_page option is when initiating the request.
- #items ⇒ Object
-
#total_pages ⇒ Object
Return total pages.
-
#total_results ⇒ Object
Return total results.
Methods inherited from Base::Response
Constructor Details
#initialize(xml) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/api_bucket/yahooauction/response.rb', line 6 def initialize(xml) @doc = xml end |
Instance Method Details
#first_item ⇒ Object
20 21 22 |
# File 'lib/api_bucket/yahooauction/response.rb', line 20 def first_item @items[0] end |
#item_page ⇒ Object
Return current page no if :item_page option is when initiating the request.
25 26 27 |
# File 'lib/api_bucket/yahooauction/response.rb', line 25 def item_page @item_page ||= @doc[:page].to_i end |
#items ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/api_bucket/yahooauction/response.rb', line 10 def items return [] if @doc.nil? if @doc['ResultSet']['Result']['Item'] @items ||= @doc['ResultSet']['Result']['Item'].map {|item| ApiBucket::Yahooauction::Item.new(item) } else @items = [ApiBucket::Yahooauction::Item.new(@doc['ResultSet']['Result'])] end end |
#total_pages ⇒ Object
Return total pages.
35 36 37 |
# File 'lib/api_bucket/yahooauction/response.rb', line 35 def total_pages @total_pages ||= @doc[:totalResultsAvailable].to_i / @doc[:totalResultsAvailable] end |
#total_results ⇒ Object
Return total results.
30 31 32 |
# File 'lib/api_bucket/yahooauction/response.rb', line 30 def total_results @total_results ||= @doc[:totalResultsReturned].to_i end |