Sha256: 0605350a072c21425e5353cf24268479d738af57c258ae31c9ea5763dd01a427

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

class Blockers::Blocker

  attr_accessor :name, :url, :price

  @@all = []

  def self.all
    @@all
  end

  def self.delete
    @@all.clear
  end

  def initialize(name, url, price)
    @name = name
    @url = url
    @price = price
    @@all << self
  end

  def self.find(index)
    self.all[index]
  end

  def name
    @name
  end

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blockers-cli-app-0.1.0 lib/blockers/blocker.rb