Class: Grubby::PageScraper
- Defined in:
- lib/grubby/page_scraper.rb
Instance Attribute Summary collapse
-
#page ⇒ Mechanize::Page
readonly
The Page being scraped.
Attributes inherited from Scraper
Class Method Summary collapse
-
.scrape_file(path, agent = $grubby) ⇒ Grubby::PageScraper
Scrapes a locally-stored file.
Instance Method Summary collapse
-
#initialize(source) ⇒ PageScraper
constructor
A new instance of PageScraper.
Methods inherited from Scraper
#[], each, fields, scrape, scrapes, #to_h
Constructor Details
#initialize(source) ⇒ PageScraper
Returns a new instance of PageScraper.
11 12 13 14 |
# File 'lib/grubby/page_scraper.rb', line 11 def initialize(source) @page = source.assert!(Mechanize::Page) super end |
Instance Attribute Details
#page ⇒ Mechanize::Page (readonly)
The Page being scraped.
6 7 8 |
# File 'lib/grubby/page_scraper.rb', line 6 def page @page end |
Class Method Details
.scrape_file(path, agent = $grubby) ⇒ Grubby::PageScraper
Scrapes a locally-stored file. This method is intended for use with subclasses of Grubby::PageScraper
.
31 32 33 |
# File 'lib/grubby/page_scraper.rb', line 31 def self.scrape_file(path, agent = $grubby) self.new(Mechanize::Page.read_local(path).tap{|page| page.mech = agent }) end |