Class: Six::Arma::Tools::CfgConvert

Inherits:
Object
  • Object
show all
Defined in:
lib/six/arma/tools/cfgconvert.rb

Constant Summary collapse

TOOL =

TODO: Add to configuration file

"CfgConvert.exe"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, destination = nil) ⇒ CfgConvert

cfgConvert [-bin | -txt | -xml] <destination>] <source>



11
12
13
14
# File 'lib/six/arma/tools/cfgconvert.rb', line 11

def initialize(source, destination = nil)
  @source = source
  @destination = destination
end

Instance Attribute Details

#destinationObject

allows instance.attribute to be read and written (e.g convert.destination)



8
9
10
# File 'lib/six/arma/tools/cfgconvert.rb', line 8

def destination
  @destination
end

#sourceObject (readonly)

allows instance.attribute to be read (e.g convert.source)



7
8
9
# File 'lib/six/arma/tools/cfgconvert.rb', line 7

def source
  @source
end

Instance Method Details

#binObject



16
17
18
# File 'lib/six/arma/tools/cfgconvert.rb', line 16

def bin
  exec("bin")
end

#exec(cmd) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/six/arma/tools/cfgconvert.rb', line 28

def exec(cmd)
  extension = "#{cmd}"
  cmd += " -dst #{@destination}" if @destination

  # TODO: Handle exceptions, maybe with FileTest
  system "#{TOOL} -#{cmd} #{@source}"
  "#{source[/\A.*\./]}#{extension}" # return the predicted output file
end

#txtObject



20
21
22
# File 'lib/six/arma/tools/cfgconvert.rb', line 20

def txt
  exec("txt")
end

#xmlObject



24
25
26
# File 'lib/six/arma/tools/cfgconvert.rb', line 24

def xml
  exec("xml")
end