Module: SpiderCore::FieldDSL
- Included in:
- MicroSpider
- Defined in:
- lib/spider_core/field_dsl.rb
Instance Method Summary collapse
-
#field(display, pattern, opts = {}, &block) ⇒ Object
Get a field on current page.
- #fields(display, pattern, opts = {}, &block) ⇒ Object
- #foreach(pattern, opts = {}, &block) ⇒ Object
Instance Method Details
#field(display, pattern, opts = {}, &block) ⇒ Object
Get a field on current page.
7 8 9 10 11 |
# File 'lib/spider_core/field_dsl.rb', line 7 def field(display, pattern, opts = {}, &block) actions << lambda { action_for(:field, {display: display, pattern: pattern}, opts, &block) } end |
#fields(display, pattern, opts = {}, &block) ⇒ Object
13 14 15 16 17 |
# File 'lib/spider_core/field_dsl.rb', line 13 def fields(display, pattern, opts = {}, &block) actions << lambda { action_for(:fields, {display: display, pattern: pattern}, opts, &block) } end |
#foreach(pattern, opts = {}, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/spider_core/field_dsl.rb', line 19 def foreach(pattern, opts = {}, &block) return unless block_given? actions << lambda { scan_all(pattern, opts).each do |element| yield(element) end } end |