Class: ScrapedResponse
- Inherits:
-
Object
- Object
- ScrapedResponse
- Defined in:
- lib/web-scraper/scraped_response.rb
Overview
ScrapedResponse
Will hold values from the scraping of the page
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(page_content, options) ⇒ ScrapedResponse
constructor
The constructor define at runtime all the methods name contained in the key of the hash that will return the computation of the XPath of the hash value.
Constructor Details
#initialize(page_content, options) ⇒ ScrapedResponse
The constructor define at runtime all the methods name contained in the key of the hash that will return the computation of the XPath of the hash value
10 11 12 13 14 |
# File 'lib/web-scraper/scraped_response.rb', line 10 def initialize(page_content, ) # puts page_content @document = Nokogiri::HTML(page_content) ScrapedResponse.create_methods() end |
Class Method Details
.create_methods(options) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/web-scraper/scraped_response.rb', line 16 def self.create_methods() .each do |key,value| define_method(key) do @document.xpath(value).children.first.text.strip! end end end |