Class: Resedit::FormatTxt

Inherits:
TextFormat show all
Defined in:
lib/resedit/text/format_text.rb

Instance Method Summary collapse

Constructor Details

#initialize(encoding) ⇒ FormatTxt

Returns a new instance of FormatTxt.



18
19
20
# File 'lib/resedit/text/format_text.rb', line 18

def initialize(encoding)
    super((encoding or 'cp1251'))
end

Instance Method Details

#loadLines(fname) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/resedit/text/format_text.rb', line 32

def loadLines(fname)
    lns=[]
    open(fname+".txt", "r:"+@encoding+":utf-8").each_line {|line|
        lns += [line.chomp]
    }
    lns=lns[0..-2] if lns.last == ""
    return lns
end

#saveLines(fname, lines, meta) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/resedit/text/format_text.rb', line 22

def saveLines(fname, lines, meta)
    open(fname+".txt", "w:"+@encoding) {|f|
        lines.each {|l|
            l.force_encoding('utf-8')
            f.write(l)
            f.write("\n")
        }
    }
end