class LeicaScFinderApp::CameraListItem

Attributes

count[RW]
title[RW]

Public Class Methods

all() click to toggle source
# File lib/leica_sc_finder_app/camera_list_item.rb, line 6
def self.all
  @@all
end
print() click to toggle source
scrape() click to toggle source
# File lib/leica_sc_finder_app/camera_list_item.rb, line 16
def self.scrape
  @doc = Nokogiri::HTML(open("http://www.leicashop.com/vintage_en/leica/leica-screw-mount-cameras.html?listview=1"))
  @doc.search("table.data-table.table-bordered td").each do |row|
    list_item = LeicaScFinderApp::CameraListItem.new
    list_item.title = row.search("a").attribute("title").text
    list_item.count = row.search("a").text[1..-1].match(/\d/)[0]
    list_item.link = row.search("a").attr("href").value
    self.all << list_item
  end
end