Class: RScale::Processor::Convert

Inherits:
Object
  • Object
show all
Defined in:
lib/rscale/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_from, file_to) {|_self| ... } ⇒ Convert

Returns a new instance of Convert.

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
17
# File 'lib/rscale/processor.rb', line 12

def initialize(file_from, file_to)
  @file_from = File.expand_path(file_from)
  @file_to = File.expand_path(file_to)
  @options = []
  yield self if block_given?
end

Instance Attribute Details

#file_fromObject (readonly)

Returns the value of attribute file_from.



9
10
11
# File 'lib/rscale/processor.rb', line 9

def file_from
  @file_from
end

#file_toObject (readonly)

Returns the value of attribute file_to.



9
10
11
# File 'lib/rscale/processor.rb', line 9

def file_to
  @file_to
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/rscale/processor.rb', line 10

def options
  @options
end

Instance Method Details

#add(param, value) ⇒ Object



19
20
21
# File 'lib/rscale/processor.rb', line 19

def add(param, value)
  @options << "-#{param.to_s} '#{value}'"
end

#executeObject



23
24
25
26
27
28
# File 'lib/rscale/processor.rb', line 23

def execute        
  unless File.exists?(File.dirname(@file_to))
    File.makedirs(File.dirname(@file_to)) 
  end
  `convert #{@file_from.shellescape} #{@options.join(' ')} #{@file_to.shellescape} 2>&1`
end