Class: Libis::Format::Converter::Base
- Inherits:
-
Object
- Object
- Libis::Format::Converter::Base
- Includes:
- Tools::Logger
- Defined in:
- lib/libis/format/converter/base.rb
Direct Known Subclasses
AudioConverter, EmailConverter, FopPdfConverter, ImageConverter, Jp2Converter, OfficeConverter, PdfConverter, SpreadsheetConverter, VideoConverter, XsltConverter
Instance Attribute Summary collapse
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #convert(source, target, format, opts = {}) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #using_temp(target, &block) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
20 21 22 23 |
# File 'lib/libis/format/converter/base.rb', line 20 def initialize @options = {} @flags = {} end |
Instance Attribute Details
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
18 19 20 |
# File 'lib/libis/format/converter/base.rb', line 18 def flags @flags end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/libis/format/converter/base.rb', line 18 def @options end |
Class Method Details
.input_types ⇒ Object
34 35 36 |
# File 'lib/libis/format/converter/base.rb', line 34 def self.input_types raise RuntimeError, 'Method #input_types needs to be overridden in converter' end |
.output_types(_format = nil) ⇒ Object
38 39 40 |
# File 'lib/libis/format/converter/base.rb', line 38 def self.output_types(_format = nil) raise RuntimeError, 'Method #output_types needs to be overridden in converter' end |
Instance Method Details
#convert(source, target, format, opts = {}) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/libis/format/converter/base.rb', line 25 def convert(source, target, format, opts = {}) unless File.exist? source error "Cannot find file '#{source}'." return nil end @options.merge!(opts[:options]) if opts[:options] @flags.merge!(opts[:flags]) if opts[:flags] end |
#using_temp(target, &block) ⇒ Object
42 43 44 |
# File 'lib/libis/format/converter/base.rb', line 42 def using_temp(target, &block) self.class.using_temp(target, &block) end |