Class: Juknife::Scraping::DSL::Scope
- Inherits:
-
Object
- Object
- Juknife::Scraping::DSL::Scope
- Includes:
- Juknife::Scraping::DSL
- Defined in:
- lib/juknife/scraping/dsl/scope.rb
Overview
A DSL node in the tree that makes an scope of element.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
Instance Method Summary collapse
-
#initialize(selector, *args, &block) ⇒ Scope
constructor
A new instance of Scope.
- #visit(context) ⇒ Object
Methods included from Juknife::Scraping::DSL
#children, #item, #items, #scope
Constructor Details
#initialize(selector, *args, &block) ⇒ Scope
Returns a new instance of Scope.
12 13 14 15 16 17 18 |
# File 'lib/juknife/scraping/dsl/scope.rb', line 12 def initialize(selector, *args, &block) @selector = selector @args = args return unless block instance_eval(&block) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/juknife/scraping/dsl/scope.rb', line 10 def args @args end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
10 11 12 |
# File 'lib/juknife/scraping/dsl/scope.rb', line 10 def selector @selector end |
Instance Method Details
#visit(context) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/juknife/scraping/dsl/scope.rb', line 20 def visit(context) scope = context.find(selector) children.each do |child| child.visit(Context.new(scope, context.result)) end end |