Class: ExtraLoop::ExtractionEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/extraloop/extraction_environment.rb

Overview

This class acts as a virtual environment within which Hook handlers and extractors run (through #run)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scraper = nil, document = nil, records = nil) ⇒ ExtractionEnvironment

Returns a new instance of ExtractionEnvironment.



9
10
11
12
13
14
15
16
17
18
# File 'lib/extraloop/extraction_environment.rb', line 9

def initialize(scraper=nil, document=nil, records=nil)

  if scraper
    @options  = scraper.options
    @results  = scraper.results
    @scraper  = scraper
  end
  @document = document
  @records  = records
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



6
7
8
# File 'lib/extraloop/extraction_environment.rb', line 6

def document
  @document
end

#scraperObject (readonly)

Returns the value of attribute scraper.



7
8
9
# File 'lib/extraloop/extraction_environment.rb', line 7

def scraper
  @scraper
end

Instance Method Details

#run(*arguments, &block) ⇒ Object



20
21
22
# File 'lib/extraloop/extraction_environment.rb', line 20

def run(*arguments, &block)
  self.instance_exec(*arguments, &block)
end