Class: Resedit::TextConvertCommand
Instance Attribute Summary
#fname
Attributes inherited from AppCommand
#names, #ohash, #opts, #params, #type
Instance Method Summary
collapse
#backup, #getOutName, #job
Methods inherited from AppCommand
#addOption, #addParam, #job, #log, #logd, #loge, #parseParams, #run
Constructor Details
7
8
9
10
11
12
|
# File 'lib/resedit/app/text_convert.rb', line 7
def initialize(fname)
super('text', fname)
@font = nil
addOption('format','f',nil,'output file format')
addOption('encoding','e',nil,'output file encoding')
end
|
Instance Method Details
#export(outname) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/resedit/app/text_convert.rb', line 31
def export(outname)
logd("exporting txet #{@resname} to #{outname}")
File.open(@resname, "rb"){|file|
@text = mktext(file, @params['format'], @params['encoding'])
unpack(file) if @text
}
raise "Text not unpacked" if !@text
@text.save(outname)
end
|
#import(inname) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/resedit/app/text_convert.rb', line 14
def import(inname)
logd("importing text #{inname} to #{@resname}")
back = backup()
File.open(back,"rb"){|file|
@text = mktext(file, @params['format'], @params['encoding'])
@text.load(inname, linesCount())
StringIO.open("","w+b"){|stream|
pack(file, stream)
stream.seek(0)
File.open(@resname,"wb"){|out|
out.write(stream.read())
}
}
}
end
|
#linesCount(file) ⇒ Object
46
47
48
|
# File 'lib/resedit/app/text_convert.rb', line 46
def linesCount(file)
raise "Not implemented"
end
|
#mktext(file, format, encoding) ⇒ Object
42
43
44
|
# File 'lib/resedit/app/text_convert.rb', line 42
def mktext(file, format, encoding)
raise "Not implemented."
end
|
#pack(file, outstream) ⇒ Object
50
51
52
|
# File 'lib/resedit/app/text_convert.rb', line 50
def pack(file, outstream)
raise "Not implemented."
end
|
#unpack(file) ⇒ Object
54
55
56
|
# File 'lib/resedit/app/text_convert.rb', line 54
def unpack(file)
raise "Not implemented."
end
|