Class: LocoStrings::LocoVariantions
- Inherits:
-
Struct
- Object
- Struct
- LocoStrings::LocoVariantions
- Defined in:
- lib/loco_strings.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#key ⇒ Object
Returns the value of attribute key.
-
#strings ⇒ Object
Returns the value of attribute strings.
-
#translatable ⇒ Object
Returns the value of attribute translatable.
Instance Method Summary collapse
- #append_string(string) ⇒ Object
-
#initialize(key, strings = nil, comment = nil, translatable = nil) ⇒ LocoVariantions
constructor
A new instance of LocoVariantions.
- #to_s ⇒ Object
- #update_variant(key, value, comment = nil, state = nil, translatable = nil) ⇒ Object
Constructor Details
#initialize(key, strings = nil, comment = nil, translatable = nil) ⇒ LocoVariantions
Returns a new instance of LocoVariantions.
37 38 39 |
# File 'lib/loco_strings.rb', line 37 def initialize(key, strings = nil, comment = nil, translatable = nil) super(key, strings || {}, comment, translatable || true) end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment
36 37 38 |
# File 'lib/loco_strings.rb', line 36 def comment @comment end |
#key ⇒ Object
Returns the value of attribute key
36 37 38 |
# File 'lib/loco_strings.rb', line 36 def key @key end |
#strings ⇒ Object
Returns the value of attribute strings
36 37 38 |
# File 'lib/loco_strings.rb', line 36 def strings @strings end |
#translatable ⇒ Object
Returns the value of attribute translatable
36 37 38 |
# File 'lib/loco_strings.rb', line 36 def translatable @translatable end |
Instance Method Details
#append_string(string) ⇒ Object
41 42 43 |
# File 'lib/loco_strings.rb', line 41 def append_string(string) strings[string.key] = string end |
#to_s ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/loco_strings.rb', line 53 def to_s if translatable "Key: #{key}, Strings: #{strings}, Comment: #{comment || "None"}" else "Key: #{key}, Strings: #{strings}, Comment: #{comment || "None"}, " \ "Translatable: #{translatable}" end end |
#update_variant(key, value, comment = nil, state = nil, translatable = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/loco_strings.rb', line 45 def update_variant(key, value, comment = nil, state = nil, translatable = nil) if strings.key? key strings[key].update(value, comment, state, translatable) else strings[key] = LocoString.new(key, value, comment, state, nil, translatable) end end |