| Class | RDig::ContentExtractors::ContentExtractor |
| In: |
lib/rdig/content_extractors.rb
|
| Parent: | Object |
Base class for Content Extractors. Extractors inheriting from this class will be auto-discovered and used when can_do returns true
# File lib/rdig/content_extractors.rb, line 23
23: def self.extractor_instances
24: @@extractor_instances ||= extractors.map { |ex_class|
25: puts "initializing content extractor: #{ex_class}" if RDig.configuration.verbose
26: ex_class.new(RDig.configuration.content_extraction)
27: }
28: end
# File lib/rdig/content_extractors.rb, line 17
17: def self.inherited(extractor)
18: super(extractor)
19: self.extractors << extractor
20: end
# File lib/rdig/content_extractors.rb, line 37
37: def initialize(config)
38: @config = config
39: end
# File lib/rdig/content_extractors.rb, line 30
30: def self.process(content, content_type)
31: self.extractor_instances.each { |extractor|
32: return extractor.process(content) if extractor.can_do(content_type)
33: }
34: puts "unable to handle content type #{content_type}"
35: end