Class: Awis::Models::CategoryListings
- Defined in:
- lib/awis/models/category_listings.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#listings ⇒ Object
Returns the value of attribute listings.
-
#recursive_count ⇒ Object
Returns the value of attribute recursive_count.
Attributes inherited from Base
#request_id, #response, #status_code
Instance Method Summary collapse
- #base_node_name ⇒ Object
-
#initialize(response) ⇒ CategoryListings
constructor
A new instance of CategoryListings.
- #setup_data!(response) ⇒ Object
Methods inherited from Base
#action_name, #loading_response, #relationship_collections, #root_node_name, #success?
Constructor Details
#initialize(response) ⇒ CategoryListings
Returns a new instance of CategoryListings.
8 9 10 11 |
# File 'lib/awis/models/category_listings.rb', line 8 def initialize(response) @listings = [] setup_data! loading_response(response) end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
6 7 8 |
# File 'lib/awis/models/category_listings.rb', line 6 def count @count end |
#listings ⇒ Object
Returns the value of attribute listings.
6 7 8 |
# File 'lib/awis/models/category_listings.rb', line 6 def listings @listings end |
#recursive_count ⇒ Object
Returns the value of attribute recursive_count.
6 7 8 |
# File 'lib/awis/models/category_listings.rb', line 6 def recursive_count @recursive_count end |
Instance Method Details
#base_node_name ⇒ Object
43 44 45 |
# File 'lib/awis/models/category_listings.rb', line 43 def base_node_name "#{root_node_name}/aws:CategoryListings/aws:Listings/aws:Listing" end |
#setup_data!(response) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/awis/models/category_listings.rb', line 13 def setup_data!(response) category_listings = [] response.each_node do |node, path| text = node.inner_xml text = text.to_i if text.to_i.to_s == text text = nil if text.class == String && text.empty? if node.name == 'aws:RequestId' @request_id ||= text elsif node.name == 'aws:StatusCode' @status_code ||= text elsif node.name == 'aws:Count' @count ||= text elsif node.name == 'aws:RecursiveCount' @recursive_count ||= text elsif node.name == 'aws:DataUrl' && path == "#{base_node_name}/aws:DataUrl" category_listings << { data_url: text } elsif node.name == 'aws:Title' && path == "#{base_node_name}/aws:Title" category_listings << { title: text } elsif node.name == 'aws:PopularityRank' && path == "#{base_node_name}/aws:PopularityRank" category_listings << { popularity_rank: text } elsif node.name == 'aws:Description' && path == "#{base_node_name}/aws:Description" category_listings << { description: text } end end relationship_collections(@listings, category_listings, 4, Listing) end |