Module: Wombat::Crawler

Extended by:
ActiveSupport::Concern
Includes:
Processing::Parser
Defined in:
lib/wombat/crawler.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary

Attributes included from Processing::Parser

#context, #mechanize, #page, #response_code

Instance Method Summary collapse

Methods included from Processing::Parser

#initialize, #parse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



36
37
38
# File 'lib/wombat/crawler.rb', line 36

def method_missing(method, *args, &block)
  self.class.send method, *args, &block
end

Instance Method Details

#crawl(&block) ⇒ Object Also known as: scrape



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/wombat/crawler.rb', line 13

def crawl(&block)
  if block
    @metadata_dup = self.class.send(:metadata).clone
    instance_eval do
      alias :old_method_missing :method_missing
      def method_missing method, *args, &block
        @metadata_dup.send method, *args, &block
      end
    end
    self.instance_eval &block
    parsed = parse @metadata_dup
    instance_eval do
      alias :method_missing :old_method_missing
      remove_instance_variable :@metadata_dup
    end
    parsed
  else
    parse self.class.send(:metadata)
  end
end