Class: EacRubyUtils::Listable::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/listable/value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list, value, key, translation_required = true) ⇒ Value

Returns a new instance of Value.



10
11
12
13
14
15
# File 'lib/eac_ruby_utils/listable/value.rb', line 10

def initialize(list, value, key, translation_required = true)
  @list = list
  @value = value
  @key = key
  @translation_required = translation_required
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/eac_ruby_utils/listable/value.rb', line 8

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/eac_ruby_utils/listable/value.rb', line 8

def value
  @value
end

Instance Method Details

#constant_nameObject



21
22
23
# File 'lib/eac_ruby_utils/listable/value.rb', line 21

def constant_name
  ::EacRubyUtils::Inflector.variableize("#{@list.item}_#{@key}").upcase
end

#descriptionObject



29
30
31
# File 'lib/eac_ruby_utils/listable/value.rb', line 29

def description
  translate('description')
end

#labelObject



25
26
27
# File 'lib/eac_ruby_utils/listable/value.rb', line 25

def label
  translate('label')
end

#to_optionArray

Returns A two-item array in format ‘[label, value]`.

Returns:

  • (Array)

    A two-item array in format ‘[label, value]`.



34
35
36
# File 'lib/eac_ruby_utils/listable/value.rb', line 34

def to_option
  [label, value]
end

#to_sObject



17
18
19
# File 'lib/eac_ruby_utils/listable/value.rb', line 17

def to_s
  "I: #{@list.item}, V: #{@value}, K: #{@key}"
end

#translation_required?Boolean

Returns:



38
39
40
# File 'lib/eac_ruby_utils/listable/value.rb', line 38

def translation_required?
  @translation_required
end