Class: LocoStrings::LocoVariantions

Inherits:
Struct
  • Object
show all
Defined in:
lib/loco_strings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commentObject

Returns the value of attribute comment

Returns:

  • (Object)

    the current value of comment



36
37
38
# File 'lib/loco_strings.rb', line 36

def comment
  @comment
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



36
37
38
# File 'lib/loco_strings.rb', line 36

def key
  @key
end

#stringsObject

Returns the value of attribute strings

Returns:

  • (Object)

    the current value of strings



36
37
38
# File 'lib/loco_strings.rb', line 36

def strings
  @strings
end

#translatableObject

Returns the value of attribute translatable

Returns:

  • (Object)

    the current value of 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_sObject



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