Module: Wombat::Crawler
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary
Attributes included from Parser
#context, #mechanize, #response_code
Instance Method Summary collapse
- #crawl(&block) ⇒ Object
- #for_each(selector, &block) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
Methods included from Parser
Methods included from PropertyLocator
Methods included from NodeSelector
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
34 35 36 |
# File 'lib/wombat/crawler.rb', line 34 def method_missing(method, *args, &block) self.class.send method, *args, &block end |
Instance Method Details
#crawl(&block) ⇒ Object
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 |
#for_each(selector, &block) ⇒ Object
38 39 40 |
# File 'lib/wombat/crawler.rb', line 38 def for_each(selector, &block) self.class.for_each selector, &block end |