Class: HashSpidey::CrawlRecord
- Inherits:
-
Object
- Object
- HashSpidey::CrawlRecord
- Defined in:
- lib/hash_spidey/crawl_record.rb
Constant Summary collapse
- META_ATTS =
%w(crawled_timestamp title header code response_header_charset meta_charset detected_encoding content_type)
Instance Attribute Summary collapse
-
#crawled_timestamp ⇒ Object
readonly
Returns the value of attribute crawled_timestamp.
Instance Method Summary collapse
-
#initialize(obj, timestamp) ⇒ CrawlRecord
constructor
A new instance of CrawlRecord.
- #to_hash ⇒ Object
Constructor Details
#initialize(obj, timestamp) ⇒ CrawlRecord
Returns a new instance of CrawlRecord.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hash_spidey/crawl_record.rb', line 11 def initialize(obj, ) @crawled_timestamp = @page_object = META_ATTS.inject(Hashie::Mash.new) do |msh, att| msh[att] = obj.send(att) if obj.respond_to?(att) msh end @page_object. = @crawled_timestamp end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
29 30 31 32 33 34 35 |
# File 'lib/hash_spidey/crawl_record.rb', line 29 def method_missing(name, *args, &block) if @page_object.respond_to?(name) @page_object.send(name, *args, &block) else super end end |
Instance Attribute Details
#crawled_timestamp ⇒ Object (readonly)
Returns the value of attribute crawled_timestamp.
9 10 11 |
# File 'lib/hash_spidey/crawl_record.rb', line 9 def @crawled_timestamp end |
Instance Method Details
#to_hash ⇒ Object
23 24 25 |
# File 'lib/hash_spidey/crawl_record.rb', line 23 def to_hash return @page_object end |