Class: CobwebModule::CrawlObject
- Inherits:
-
Object
- Object
- CobwebModule::CrawlObject
- Defined in:
- lib/crawl_object.rb
Instance Method Summary collapse
-
#initialize(content_hash, options = {}) ⇒ CrawlObject
constructor
A new instance of CrawlObject.
- #method_missing(m) ⇒ Object
-
#permitted_type? ⇒ Boolean
Helper method to determine if this content is to be processed or not.
- #to_hash ⇒ Object
Constructor Details
#initialize(content_hash, options = {}) ⇒ CrawlObject
Returns a new instance of CrawlObject.
4 5 6 7 |
# File 'lib/crawl_object.rb', line 4 def initialize(content_hash, ={}) @content = HashUtil.deep_symbolize_keys(content_hash) @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/crawl_object.rb', line 18 def method_missing(m) if @content.keys.include? m.to_sym @content[m.to_sym] else super end end |
Instance Method Details
#permitted_type? ⇒ Boolean
Helper method to determine if this content is to be processed or not
11 12 13 14 15 16 |
# File 'lib/crawl_object.rb', line 11 def permitted_type? @options[:valid_mime_types].each do |valid_mime_type| return true if @content[:mime_type].match(Cobweb.escape_pattern_for_regex(valid_mime_type)) end false end |
#to_hash ⇒ Object
26 27 28 |
# File 'lib/crawl_object.rb', line 26 def to_hash @content end |