Class: Lokale::LString
- Inherits:
-
Object
- Object
- Lokale::LString
- Defined in:
- lib/lokale/model.rb,
lib/lokale/agent.rb,
lib/lokale/model.rb
Overview
Hashable
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#note ⇒ Object
Returns the value of attribute note.
-
#source ⇒ Object
Returns the value of attribute source.
-
#str ⇒ Object
Returns the value of attribute str.
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #fields ⇒ Object
- #for_export(lang) ⇒ Object
- #hash ⇒ Object
-
#initialize(key, str, note, target) ⇒ LString
constructor
A new instance of LString.
- #inspect ⇒ Object
- #pretty ⇒ Object
- #write_format ⇒ Object
Constructor Details
#initialize(key, str, note, target) ⇒ LString
Returns a new instance of LString.
6 7 8 |
# File 'lib/lokale/model.rb', line 6 def initialize(key, str, note, target) @key = key; @str = str; @note = note; @target = target end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
4 5 6 |
# File 'lib/lokale/model.rb', line 4 def key @key end |
#note ⇒ Object
Returns the value of attribute note.
4 5 6 |
# File 'lib/lokale/model.rb', line 4 def note @note end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/lokale/model.rb', line 4 def source @source end |
#str ⇒ Object
Returns the value of attribute str.
4 5 6 |
# File 'lib/lokale/model.rb', line 4 def str @str end |
#target ⇒ Object
Returns the value of attribute target.
4 5 6 |
# File 'lib/lokale/model.rb', line 4 def target @target end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
123 124 125 |
# File 'lib/lokale/model.rb', line 123 def ==(other) self.class === other && other.fields == fields end |
#fields ⇒ Object
119 120 121 |
# File 'lib/lokale/model.rb', line 119 def fields [@key, @str, @note, @target] end |
#for_export(lang) ⇒ Object
75 76 77 78 79 |
# File 'lib/lokale/agent.rb', line 75 def for_export(lang) str = LString.new(@key, nil, @note, lang) str.source = @str str end |
#hash ⇒ Object
129 130 131 |
# File 'lib/lokale/model.rb', line 129 def hash fields.hash end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/lokale/model.rb', line 15 def inspect "<\#LS:#{@key}; s:#{@str}; n:#{@note}; t:#{@target}>" end |
#pretty ⇒ Object
65 66 67 |
# File 'lib/lokale/agent.rb', line 65 def pretty "\"#{key}\" = \"#{str}\";" end |
#write_format ⇒ Object
57 58 59 60 61 62 63 |
# 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 |