class Blockers::Blocker

Attributes

name[RW]
price[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/blockers/blocker.rb, line 7
def self.all
  @@all
end
delete() click to toggle source
# File lib/blockers/blocker.rb, line 11
def self.delete
  @@all.clear
end
find(index) click to toggle source
# File lib/blockers/blocker.rb, line 22
def self.find(index)
  self.all[index]
end
new(name, url, price) click to toggle source
# File lib/blockers/blocker.rb, line 15
def initialize(name, url, price)
  @name = name
  @url = url
  @price = price
  @@all << self
end
scrape() click to toggle source
# 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