class Knitpickr::Scraper
Attributes
doc[RW]
yarn[RW]
Public Class Methods
all_fibers()
click to toggle source
# File lib/knitpickr/scraper.rb, line 43 def self.all_fibers @@all_fibers.uniq end
all_names()
click to toggle source
# File lib/knitpickr/scraper.rb, line 39 def self.all_names @@all_names.uniq end
all_sale()
click to toggle source
# File lib/knitpickr/scraper.rb, line 55 def self.all_sale @@all_sale.uniq end
all_weights()
click to toggle source
# File lib/knitpickr/scraper.rb, line 47 def self.all_weights @@all_weights.uniq end
all_yarns()
click to toggle source
# File lib/knitpickr/scraper.rb, line 51 def self.all_yarns @@all_yarns end
make_yarns()
click to toggle source
# File lib/knitpickr/scraper.rb, line 17 def self.make_yarns self.scrape_yarns all_yarns = @doc.css("div.listItem.book") all_yarns.each do |yarn| y = Knitpickr::Yarn.new(yarn.css(".titleSmall").first.attribute("title").value) @@all_yarns << y y.name = yarn.css(".titleSmall").first.attribute("title").value @@all_names << y.name y.weight = yarn.css(".yarnWeight")[1].text @@all_weights << y.weight y.fiber = yarn.css(".yarnWeight").first.text @@all_fibers << y.fiber y.price = yarn.css(".costSmall").first.text.strip if yarn.css(".listItemStatusTags").text == "Sale" y.sale = true @@all_sale << y end y end end
scrape_yarns()
click to toggle source
# File lib/knitpickr/scraper.rb, line 13 def self.scrape_yarns @doc = Nokogiri::HTML(open("http://www.knitpicks.com/yarns/All_Knit_Picks_Yarn__L300198.html?showAll=yes")) end