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) ⇒ LocoVariantions

Returns a new instance of LocoVariantions.



29
30
31
32
# File 'lib/loco_strings.rb', line 29

def initialize(key, strings = nil, comment = nil)
  super
  self.strings = strings || {}
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment

Returns:

  • (Object)

    the current value of comment



28
29
30
# File 'lib/loco_strings.rb', line 28

def comment
  @comment
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



28
29
30
# File 'lib/loco_strings.rb', line 28

def key
  @key
end

#stringsObject

Returns the value of attribute strings

Returns:

  • (Object)

    the current value of strings



28
29
30
# File 'lib/loco_strings.rb', line 28

def strings
  @strings
end

Instance Method Details

#append_string(string) ⇒ Object



34
35
36
# File 'lib/loco_strings.rb', line 34

def append_string(string)
  strings[string.key] = string
end

#to_sObject



46
47
48
# File 'lib/loco_strings.rb', line 46

def to_s
  "Key: #{key}, Strings: #{strings}, Comment: #{comment || "None"}"
end

#update_variant(key, value, comment = nil, state = nil) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/loco_strings.rb', line 38

def update_variant(key, value, comment = nil, state = nil)
  if strings.key? key
    strings[key].update(value, comment, state)
  else
    strings[key] = LocoString.new(key, value, comment, state)
  end
end