Class: CompareSupermarkets::Woolworths

Inherits:
Supermarket show all
Defined in:
lib/compare_supermarkets/supermarket.rb

Instance Attribute Summary

Attributes inherited from Supermarket

#name

Instance Method Summary collapse

Methods inherited from Supermarket

#add_product, all, all_products, clear_all, products

Constructor Details

#initialize(product) ⇒ Woolworths

Returns a new instance of Woolworths.



52
53
54
55
56
57
58
59
60
61
# File 'lib/compare_supermarkets/supermarket.rb', line 52

def initialize(product)
    @product = product
    @supermarket = self
    @name = @product.css(".shelfProductTile-descriptionLink").text
    @price = @product.css(".shelfProductTile-cupPrice.ng-star-inserted").text.delete_prefix(' $').chomp(" ")
    @unit_size = @product.css(".shelfProductTile-descriptionLink").text.split(" ").last
    @url = "https://www.woolworths.com.au#{@product.css(".shelfProductTile-descriptionLink").attribute('href').value}"
    @dollar_value = @product.css(".price-dollars").text
    @cent_value = @product.css(".price-cents").text
end