Class: Libis::Format::Converter::Base

Inherits:
Object
  • Object
show all
Includes:
Tools::Logger
Defined in:
lib/libis/format/converter/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Base

Returns a new instance of Base.



19
20
21
22
# File 'lib/libis/format/converter/base.rb', line 19

def initialize
  @options = {}
  @flags = {}
end

Instance Attribute Details

#flags ⇒ Object (readonly)

Returns the value of attribute flags.



17
18
19
# File 'lib/libis/format/converter/base.rb', line 17

def flags
  @flags
end

#options ⇒ Object (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/libis/format/converter/base.rb', line 17

def options
  @options
end

Class Method Details

.input_types ⇒ Object

Raises:

  • (RuntimeError)


33
34
35
# File 'lib/libis/format/converter/base.rb', line 33

def self.input_types
  raise RuntimeError, 'Method #input_types needs to be overridden in converter'
end

.output_types(_format = nil) ⇒ Object

Raises:

  • (RuntimeError)


37
38
39
# File 'lib/libis/format/converter/base.rb', line 37

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



24
25
26
27
28
29
30
31
# File 'lib/libis/format/converter/base.rb', line 24

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



41
42
43
# File 'lib/libis/format/converter/base.rb', line 41

def using_temp(target, &block)
  self.class.using_temp(target, &block)
end