Class: Eac::Listable::Value

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list, value, key) ⇒ Value

Returns a new instance of Value.



165
166
167
168
169
# File 'lib/eac/listable.rb', line 165

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



163
164
165
# File 'lib/eac/listable.rb', line 163

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



163
164
165
# File 'lib/eac/listable.rb', line 163

def value
  @value
end

Instance Method Details

#constant_nameObject



175
176
177
178
# File 'lib/eac/listable.rb', line 175

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

#descriptionObject



184
185
186
# File 'lib/eac/listable.rb', line 184

def description
  translate('description')
end

#labelObject



180
181
182
# File 'lib/eac/listable.rb', line 180

def label
  translate('label')
end

#to_sObject



171
172
173
# File 'lib/eac/listable.rb', line 171

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