Class: Resedit::ConvertCommand

Inherits:
AppCommand show all
Defined in:
lib/resedit/app/io_commands.rb

Direct Known Subclasses

FontConvertCommand, TextConvertCommand

Instance Attribute Summary collapse

Attributes inherited from AppCommand

#names, #ohash, #opts, #params, #type

Instance Method Summary collapse

Methods inherited from AppCommand

#addOption, #addParam, #log, #logd, #loge, #parseParams, #run

Constructor Details

#initialize(name, fname) ⇒ ConvertCommand

Returns a new instance of ConvertCommand.



31
32
33
34
35
36
37
# File 'lib/resedit/app/io_commands.rb', line 31

def initialize(name, fname)
    super([name])
    addParam('action','import/export action')
    addParam('file','file to import/export')
    addOption('output','o',nil,'converted file name')
    @fname=fname
end

Instance Attribute Details

#fnameObject (readonly)

Returns the value of attribute fname.



28
29
30
# File 'lib/resedit/app/io_commands.rb', line 28

def fname
  @fname
end

Instance Method Details

#backupObject



44
45
46
47
48
# File 'lib/resedit/app/io_commands.rb', line 44

def backup()
    bname=@resname+'.bak'
    FileUtils.cp(@resname,bname) if ! File.exist?(bname)
    return bname
end

#export(outfile) ⇒ Object



69
70
71
# File 'lib/resedit/app/io_commands.rb', line 69

def export(outfile)
    raise 'Not implemented'
end

#getOutNameObject



40
41
42
# File 'lib/resedit/app/io_commands.rb', line 40

def getOutName()
    return File.basename(@resname,File.extname(@resname))
end

#import(infile) ⇒ Object



65
66
67
# File 'lib/resedit/app/io_commands.rb', line 65

def import(infile)
    raise 'Not implemented'
end

#job(params) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/resedit/app/io_commands.rb', line 50

def job(params)
    @params=params
    @resname=params['file']
    fname = getOutName()
    fname = params['output'] if params['output']
    if params['action']=='import'
        import(fname)
    elsif params['action']=='export'
        export(fname)
    else
        raise "Unknown action #{params['action']}. import or export expected."
    end

end