class WeddingRegistryScraper::Registries::WilliamsSonoma
Private Instance Methods
get_desired(product)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 31 def get_desired(product) product.css('td.requested').text.strip.to_i end
get_image_url(product)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 23 def get_image_url(product) product.css('img')[0]['src'].sub(/f\.jpg$/, 'c.jpg') end
get_name(product)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 9 def get_name(product) product.css('.product-detail .product-info .title a').text.strip end
get_price(product)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 35 def get_price(product) if (sale_price = product.css('td.price .price-state.price-special')).any? sale_price.css('.currencyUSD .price-amount').text.strip.to_f else product.css('td.price .price-state.price-standard .currencyUSD .price-amount').text.strip.to_f end end
get_products(doc)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 5 def get_products(doc) doc.css('table.registry-category-list tbody tr') end
get_remaining(product)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 27 def get_remaining(product) product.css('td.still-needs').text.strip.to_i end
get_sku(product)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 13 def get_sku(product) sku = product.css('.product-detail .product-info .item-number').text.strip.match(/: (\d+)/)[1] "williams-sonoma:#{sku}" end
get_url(product)
click to toggle source
# File lib/wedding_registry_scraper/registries/williams_sonoma.rb, line 18 def get_url(product) # product.css('.product-detail .product-info .title a')[0]['href'] @url end