Class: Juknife::Middleware::ScrapingDSL
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Juknife::Middleware::ScrapingDSL
- Includes:
- Scraping::DSL
- Defined in:
- lib/juknife/middleware/scraping_dsl.rb
Overview
A Faraday middleware to interpret Juknife scraping DSL
Instance Method Summary collapse
-
#initialize(app, params = {}, &block) ⇒ ScrapingDSL
constructor
A new instance of ScrapingDSL.
- #parse(doc) ⇒ Object
Methods included from Scraping::DSL
#children, #item, #items, #scope
Constructor Details
#initialize(app, params = {}, &block) ⇒ ScrapingDSL
Returns a new instance of ScrapingDSL.
12 13 14 15 16 |
# File 'lib/juknife/middleware/scraping_dsl.rb', line 12 def initialize(app, params = {}, &block) super(app) @params = params instance_eval(&block) end |
Instance Method Details
#parse(doc) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/juknife/middleware/scraping_dsl.rb', line 18 def parse(doc) context = Juknife::Scraping::Context.new(doc) children.each do |child| child.visit(context) end context.result end |