Class: Ddr::Extraction::Extractor

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ddr/extraction/extractor.rb

Overview

The Extractor is the main public class.

It works by delegating to an adapter that does the real work.

extractor = Ddr::Extraction::Extractor.build(:tika)
text = extractor.extract(:text, "/path/to/text/file")
puts text.read
...

Class Method Summary collapse

Class Method Details

.build(adapter_name = nil) {|extractor| ... } ⇒ Object

Returns/yields an extractor instance

Parameters:

  • adapter_name (Symbol) (defaults to: nil)

    the name of the adapter to plug in. If not given, a default adapter will be used, if Ddr::Extraction::Adapters.default has been set with the name of the default adapter.

Yields:

  • (extractor)


27
28
29
30
31
32
# File 'lib/ddr/extraction/extractor.rb', line 27

def build(adapter_name = nil)
  adapter = Adapters.get_adapter(adapter_name)
  extractor = new(adapter.new)
  yield extractor if block_given?
  extractor
end