Class: LocoStrings::LocoString

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, comment = nil, state = nil, translatable = nil) ⇒ LocoString

Returns a new instance of LocoString.



13
14
15
16
# File 'lib/loco_strings.rb', line 13

def initialize(key, value, comment = nil, state = nil, translatable = nil)
  translatable = true if translatable.nil?
  super(key, value, comment, state, translatable)
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment

Returns:

  • (Object)

    the current value of comment



12
13
14
# File 'lib/loco_strings.rb', line 12

def comment
  @comment
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



12
13
14
# File 'lib/loco_strings.rb', line 12

def key
  @key
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



12
13
14
# File 'lib/loco_strings.rb', line 12

def state
  @state
end

#translatableObject

Returns the value of attribute translatable

Returns:

  • (Object)

    the current value of translatable



12
13
14
# File 'lib/loco_strings.rb', line 12

def translatable
  @translatable
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



12
13
14
# File 'lib/loco_strings.rb', line 12

def value
  @value
end

Instance Method Details

#to_sObject



25
26
27
28
29
30
31
32
33
# File 'lib/loco_strings.rb', line 25

def to_s
  if translatable
    "Key: #{key}, Value: #{value}, Comment: #{comment || "None"}, " \
      "State: #{state || "None"}"
  else
    "Key: #{key}, Value: #{value}, Comment: #{comment || "None"}, " \
      "State: #{state || "None"}, Translatable: #{translatable}"
  end
end

#update(value, comment = nil, state = nil, translatable = nil) ⇒ Object



18
19
20
21
22
23
# File 'lib/loco_strings.rb', line 18

def update(value, comment = nil, state = nil, translatable = nil)
  self.value = value
  self.comment = comment unless comment.nil?
  self.state = state
  self.translatable = translatable unless translatable.nil?
end