Module: Wombat::Parser

Includes:
PropertyLocator
Included in:
Crawler
Defined in:
lib/wombat/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PropertyLocator

#locate

Methods included from NodeSelector

#select_nodes

Instance Attribute Details

#contextObject

Returns the value of attribute context.



9
10
11
# File 'lib/wombat/parser.rb', line 9

def context
  @context
end

#mechanizeObject

Returns the value of attribute mechanize.



9
10
11
# File 'lib/wombat/parser.rb', line 9

def mechanize
  @mechanize
end

#response_codeObject

Returns the value of attribute response_code.



9
10
11
# File 'lib/wombat/parser.rb', line 9

def response_code
  @response_code
end

Instance Method Details

#initializeObject



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
# File 'lib/wombat/parser.rb', line 15

def parse()
  self.context = parser_for 
  original_context = self.context

  .iterators.each do |it|
    it.reset # Clean up iterator results before starting
    select_nodes(it.selector).each do |node|
      self.context = node
      it.parse { |p| locate p }
    end
  end

  self.context = original_context

  .parse { |p| locate p }

  .flatten
end