Class: WeddingRegistryScraper::Registry
- Inherits:
-
Object
- Object
- WeddingRegistryScraper::Registry
- Defined in:
- lib/wedding_registry_scraper/registry.rb
Direct Known Subclasses
WeddingRegistryScraper::Registries::CrateAndBarrel, WeddingRegistryScraper::Registries::HeathCeramics, WeddingRegistryScraper::Registries::PotteryBarn, WeddingRegistryScraper::Registries::Rei, WeddingRegistryScraper::Registries::WilliamsSonoma, WeddingRegistryScraper::Registries::Zola
Constant Summary collapse
- PRICE_TYPES =
[ FIXED_PRICE = 'Fixed price', VARIABLE_PRICE = 'Variable price', ]
Class Attribute Summary collapse
-
.display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
.domain ⇒ Object
readonly
Returns the value of attribute domain.
Instance Method Summary collapse
- #get_items ⇒ Object
-
#initialize(url, params = {}) ⇒ Registry
constructor
A new instance of Registry.
Constructor Details
#initialize(url, params = {}) ⇒ Registry
Returns a new instance of Registry.
15 16 17 18 19 |
# File 'lib/wedding_registry_scraper/registry.rb', line 15 def initialize(url, params={}) params.symbolize_keys! @url = url @debug = params[:debug] == true end |
Class Attribute Details
.display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
11 12 13 |
# File 'lib/wedding_registry_scraper/registry.rb', line 11 def display_name @display_name end |
.domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/wedding_registry_scraper/registry.rb', line 12 def domain @domain end |
Instance Method Details
#get_items ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wedding_registry_scraper/registry.rb', line 21 def get_items doc = get_registry get_products(doc).reduce({}) do |products, product| sku = get_sku(product) details = { :name => get_name(product), :remaining => get_remaining(product), :desired => get_desired(product), :url => get_url(product), :image_url => get_image_url(product), :registry_name => self.class.display_name, :fulfilled => fulfilled?(product), :price_type => price_type(product), :price_value => get_price(product), } products.merge! sku => details end end |