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

Returns a new instance of Value.



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

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/eac_ruby_utils/listable/value.rb', line 6

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/eac_ruby_utils/listable/value.rb', line 6

def value
  @value
end

Instance Method Details

#constant_nameObject



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

def constant_name
  "#{@list.item}_#{@key}".gsub(/[^a-z0-9_]/, '_').gsub(/_+/, '_')
                         .gsub(/(?:\A_|_\z)/, '').upcase
end

#descriptionObject



27
28
29
# File 'lib/eac_ruby_utils/listable/value.rb', line 27

def description
  translate('description')
end

#labelObject



23
24
25
# File 'lib/eac_ruby_utils/listable/value.rb', line 23

def label
  translate('label')
end

#to_sObject



14
15
16
# File 'lib/eac_ruby_utils/listable/value.rb', line 14

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