Class: ApiBucket::Itunes::Response

Inherits:
Base::Response show all
Defined in:
lib/api_bucket/itunes/response.rb

Instance Attribute Summary

Attributes inherited from Base::Response

#count, #page

Instance Method Summary collapse

Methods inherited from Base::Response

#doc, #dump

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_itemObject



16
17
18
# File 'lib/api_bucket/itunes/response.rb', line 16

def first_item
  @items[0]
end

#item_pageObject

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

#itemsObject



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_pagesObject

Return total pages.



31
32
33
# File 'lib/api_bucket/itunes/response.rb', line 31

def total_pages
  @total_pages = 1
end

#total_resultsObject

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