class Lokale::LString
Hashable
Attributes
key[RW]
note[RW]
source[RW]
str[RW]
target[RW]
Public Class Methods
from_xliff_string(s, lang)
click to toggle source
# File lib/lokale/agent.rb, line 69 def self.from_xliff_string(s, lang) str = LString.new(s.id, s.target, s.note, lang) str.source = s.source str end
new(key, str, note, target)
click to toggle source
# File lib/lokale/model.rb, line 6 def initialize(key, str, note, target) @key = key; @str = str; @note = note; @target = target end
strings_from_file(file_path, lang)
click to toggle source
# File lib/lokale/model.rb, line 10 def self.strings_from_file(file_path, lang) regex = /(?:\/\* (.+) \*\/.*\n)?"(.+)" *= *"(.+)";/ File.read(file_path).scan(regex).map { |m| LString.new(m[1], m[2], m[0], lang) } end
Public Instance Methods
==(other)
click to toggle source
# File lib/lokale/model.rb, line 123 def ==(other) self.class === other && other.fields == fields end
Also aliased as: eql?
fields()
click to toggle source
# File lib/lokale/model.rb, line 119 def fields [@key, @str, @note, @target] end
for_export(lang)
click to toggle source
# File lib/lokale/agent.rb, line 75 def for_export(lang) str = LString.new(@key, nil, @note, lang) str.source = @str str end
hash()
click to toggle source
# File lib/lokale/model.rb, line 129 def hash fields.hash end
inspect()
click to toggle source
# File lib/lokale/model.rb, line 15 def inspect "<\#LS:#{@key}; s:#{@str}; n:#{@note}; t:#{@target}>" end
pretty()
click to toggle source
# File lib/lokale/agent.rb, line 65 def pretty "\"#{key}\" = \"#{str}\";" end
write_format()
click to toggle source
# File lib/lokale/agent.rb, line 57 def write_format note = @note unless @note.empty? note = @source if note.nil? note = "(no comment)" if note.nil? "/* #{note} */\n\"#{key}\" = \"#{str}\";\n" end