Class: ChupaText::Extractor
- Inherits:
-
Object
- Object
- ChupaText::Extractor
- Includes:
- Loggable
- Defined in:
- lib/chupa-text/extractor.rb
Instance Method Summary collapse
-
#add_decomposer(decomposer) ⇒ Object
-
#apply_configuration(configuration) ⇒ void
Sets the extractor up by the configuration.
-
#extract(input) {|text_data| ... } ⇒ void
Extracts texts from input.
-
#initialize ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize ⇒ Extractor
Returns a new instance of Extractor.
25 26 27 |
# File 'lib/chupa-text/extractor.rb', line 25 def initialize @decomposers = [] end |
Instance Method Details
#add_decomposer(decomposer) ⇒ Object
44 45 46 |
# File 'lib/chupa-text/extractor.rb', line 44 def add_decomposer(decomposer) @decomposers << decomposer end |
#apply_configuration(configuration) ⇒ void
This method returns an undefined value.
Sets the extractor up by the configuration. It adds decomposers enabled in the configuration.
36 37 38 39 40 41 42 |
# File 'lib/chupa-text/extractor.rb', line 36 def apply_configuration(configuration) decomposers = Decomposers.create(Decomposer.registry, configuration.decomposer) decomposers.each do |decomposer| add_decomposer(decomposer) end end |
#extract(input) {|text_data| ... } ⇒ void
This method returns an undefined value.
Extracts texts from input. Each extracted text is passes to the given block.
61 62 63 |
# File 'lib/chupa-text/extractor.rb', line 61 def extract(input, &block) extract_recursive(ensure_data(input), &block) end |