Module: Wombat::Parser
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#mechanize ⇒ Object
Returns the value of attribute mechanize.
Instance Method Summary collapse
Methods included from PropertyLocator
Methods included from NodeSelector
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
9 10 11 |
# File 'lib/wombat/parser.rb', line 9 def context @context end |
#mechanize ⇒ Object
Returns the value of attribute mechanize.
9 10 11 |
# File 'lib/wombat/parser.rb', line 9 def mechanize @mechanize end |
Instance Method Details
#initialize ⇒ Object
11 12 13 |
# File 'lib/wombat/parser.rb', line 11 def initialize @mechanize = Mechanize.new end |
#parse(metadata) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wombat/parser.rb', line 15 def parse self.context = get_parser original_context = self.context .iterators.each do |it| select_nodes(it.selector).each do |n| self.context = n it.all_properties.each do |p| p.result ||= [] result = locate(p) if result result = p.callback ? p.callback.call(result) : result p.result << result end end end end self.context = original_context .all_properties.each do |p| result = locate p p.result = p.callback ? p.callback.call(result) : result end .flatten end |