Class: Newegg::Store
Constant Summary
Constants inherited from Api
Api::DefaultUserAgent, Api::UserAgents
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#show_see_all_deals ⇒ Object
Returns the value of attribute show_see_all_deals.
-
#store_department ⇒ Object
Returns the value of attribute store_department.
-
#store_id ⇒ Object
Returns the value of attribute store_id.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Api
#_categories, #_id, #_stores, #conn
Instance Method Summary collapse
- #get_categories(newegg = Newegg) ⇒ Object
-
#initialize(title, store_department, store_id, show_see_all_deals) ⇒ Store
constructor
A new instance of Store.
- #to_h(newegg = Newegg) ⇒ Object
Methods inherited from Api
#banners, #client_config, #combo_deals, #connection, #country, #daily_deal, #details, #exclusive_deals, #keywords, #navigate, #power_search, #power_search_content, #query, #reviews, #search, #shell_shockers, #shell_shockers_new, #shop_all_navigation, #shop_more_navigation, #shopping_guide, #specifications, #spotlight, #spotlights, #store_content, #store_navigate, #stores
Constructor Details
#initialize(title, store_department, store_id, show_see_all_deals) ⇒ Store
Returns a new instance of Store.
5 6 7 8 9 10 11 |
# File 'lib/newegg/store.rb', line 5 def initialize(title, store_department, store_id, show_see_all_deals) self.title = title self.store_department = store_department self.store_id = store_id self.show_see_all_deals = show_see_all_deals self.categories = [] end |
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
3 4 5 |
# File 'lib/newegg/store.rb', line 3 def categories @categories end |
#show_see_all_deals ⇒ Object
Returns the value of attribute show_see_all_deals.
3 4 5 |
# File 'lib/newegg/store.rb', line 3 def show_see_all_deals @show_see_all_deals end |
#store_department ⇒ Object
Returns the value of attribute store_department.
3 4 5 |
# File 'lib/newegg/store.rb', line 3 def store_department @store_department end |
#store_id ⇒ Object
Returns the value of attribute store_id.
3 4 5 |
# File 'lib/newegg/store.rb', line 3 def store_id @store_id end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/newegg/store.rb', line 3 def title @title end |
Instance Method Details
#get_categories(newegg = Newegg) ⇒ Object
13 14 15 16 |
# File 'lib/newegg/store.rb', line 13 def get_categories(newegg = Newegg) self.categories = newegg.categories(self.store_id).freeze if self.categories.empty? self.categories end |
#to_h(newegg = Newegg) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/newegg/store.rb', line 18 def to_h(newegg = Newegg) @h ||= begin categories_hash = [] get_categories(newegg).each do |c| categories_hash << c.to_h end { :title => title, :store_department => store_department, :store_id => store_id, :show_see_all_deals => show_see_all_deals, :categories => categories_hash }.freeze end end |