Class: HashSpidey::CrawlRecord

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, timestamp)
	@crawled_timestamp = 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 = @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_timestampObject (readonly)

Returns the value of attribute crawled_timestamp.



9
10
11
# File 'lib/hash_spidey/crawl_record.rb', line 9

def crawled_timestamp
  @crawled_timestamp
end

Instance Method Details

#to_hashObject



23
24
25
# File 'lib/hash_spidey/crawl_record.rb', line 23

def to_hash			
	return @page_object
end