Class: Apify::Core::Parser
- Inherits:
-
Object
- Object
- Apify::Core::Parser
- Defined in:
- lib/apify_core/parser.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(html = "", pattern = {}) ⇒ Parser
constructor
A new instance of Parser.
- #perform ⇒ Object
Constructor Details
#initialize(html = "", pattern = {}) ⇒ Parser
Returns a new instance of Parser.
5 6 7 |
# File 'lib/apify_core/parser.rb', line 5 def initialize(html="", pattern={}) @html, @pattern, @doc, @result = html, pattern, ::Nokogiri::HTML(html), {} end |
Class Method Details
.fetch(expression, docs) ⇒ Object
17 18 19 |
# File 'lib/apify_core/parser.rb', line 17 def self.fetch(expression, docs) docs.map{ |html| ::Nokogiri::HTML(html).search(expression) }.flatten end |
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/apify_core/parser.rb', line 9 def perform @pattern.each do |key,value| next if key == '__iterator__' @result[key] = process(value, @doc) end @result end |