Class: Resedit::FormatTxt
- Inherits:
-
TextFormat
- Object
- TextFormat
- Resedit::FormatTxt
- Defined in:
- lib/resedit/text/format_text.rb
Instance Method Summary collapse
-
#initialize(encoding) ⇒ FormatTxt
constructor
A new instance of FormatTxt.
- #loadLines(fname) ⇒ Object
- #saveLines(fname, lines, meta) ⇒ Object
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, ) open(fname+".txt", "w:"+@encoding) {|f| lines.each {|l| l.force_encoding('utf-8') f.write(l) f.write("\n") } } end |