Class: EacRubyUtils::Listable::Value
- Defined in:
- lib/eac_ruby_utils/listable/value.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #constant_name ⇒ Object
- #description ⇒ Object
-
#initialize(list, value, key, translation_required = true) ⇒ Value
constructor
A new instance of Value.
- #label ⇒ Object
-
#to_option ⇒ Array
A two-item array in format ‘[label, value]`.
- #to_s ⇒ Object
- #translation_required? ⇒ Boolean
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/eac_ruby_utils/listable/value.rb', line 8 def key @key end |
#value ⇒ Object (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_name ⇒ Object
21 22 23 |
# File 'lib/eac_ruby_utils/listable/value.rb', line 21 def constant_name ::EacRubyUtils::Inflector.variableize("#{@list.item}_#{@key}").upcase end |
#description ⇒ Object
29 30 31 |
# File 'lib/eac_ruby_utils/listable/value.rb', line 29 def description translate('description') end |
#label ⇒ Object
25 26 27 |
# File 'lib/eac_ruby_utils/listable/value.rb', line 25 def label translate('label') end |
#to_option ⇒ Array
Returns 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_s ⇒ Object
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
38 39 40 |
# File 'lib/eac_ruby_utils/listable/value.rb', line 38 def translation_required? @translation_required end |