Class: ApiBucket::Itunes::Response
- Inherits:
-
Base::Response
- Object
- Base::Response
- ApiBucket::Itunes::Response
- Defined in:
- lib/api_bucket/itunes/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/itunes/response.rb', line 6 def initialize(xml) @doc = xml end |
Instance Method Details
#first_item ⇒ Object
16 17 18 |
# File 'lib/api_bucket/itunes/response.rb', line 16 def first_item @items[0] end |
#item_page ⇒ Object
Return current page no if :item_page option is when initiating the request.
21 22 23 |
# File 'lib/api_bucket/itunes/response.rb', line 21 def item_page @item_page = 1 end |
#items ⇒ Object
10 11 12 13 14 |
# File 'lib/api_bucket/itunes/response.rb', line 10 def items return [] if @doc.nil? @items ||= @doc["results"].collect { |item| ApiBucket::Itunes::Item.new(item) } end |
#total_pages ⇒ Object
Return total pages.
31 32 33 |
# File 'lib/api_bucket/itunes/response.rb', line 31 def total_pages @total_pages = 1 end |
#total_results ⇒ Object
Return total results.
26 27 28 |
# File 'lib/api_bucket/itunes/response.rb', line 26 def total_results @total_results ||= @doc[:resultCount].to_i end |