Class: Blockers::Blocker
- Inherits:
-
Object
- Object
- Blockers::Blocker
- Defined in:
- lib/blockers/blocker.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, url, price) ⇒ Blocker
constructor
A new instance of Blocker.
Constructor Details
#initialize(name, url, price) ⇒ Blocker
Returns a new instance of Blocker.
15 16 17 18 19 20 |
# File 'lib/blockers/blocker.rb', line 15 def initialize(name, url, price) @name = name @url = url @price = price @@all << self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/blockers/blocker.rb', line 3 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
3 4 5 |
# File 'lib/blockers/blocker.rb', line 3 def price @price end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/blockers/blocker.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
7 8 9 |
# File 'lib/blockers/blocker.rb', line 7 def self.all @@all end |
.delete ⇒ Object
11 12 13 |
# File 'lib/blockers/blocker.rb', line 11 def self.delete @@all.clear end |
.find(index) ⇒ Object
22 23 24 |
# File 'lib/blockers/blocker.rb', line 22 def self.find(index) self.all[index] end |
.scrape ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/blockers/blocker.rb', line 30 def self.scrape doc = Nokogiri::HTML(open('http://www.goaliemonkey.com/equipment/blockers/sr-goalie-blockers/sort-by/price/sort-direction/asc.html')) doc.css("li.item.span3").each do |item| name = item.css("div.caption h2.product-name a").text.gsub("Goalie Blocker", "") url = item.css("div.caption h2.product-name a").attribute("href").value price = item.css("div.price-box p.regular-price span.regular-price span.price").text self.new(name, url, price) end end |