Class: ParameterSubstitution::Formatters::Lookup

Inherits:
Base
  • Object
show all
Defined in:
lib/parameter_substitution/formatters/lookup.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

encoding, format, key, parse_duration

Constructor Details

#initialize(lookup_table) ⇒ Lookup

Returns a new instance of Lookup.



12
13
14
# File 'lib/parameter_substitution/formatters/lookup.rb', line 12

def initialize(lookup_table)
  @lookup_table = lookup_table
end

Class Method Details

.descriptionObject



4
5
6
# File 'lib/parameter_substitution/formatters/lookup.rb', line 4

def self.description
  "This takes a table as a constructor parameter and performs a lookup from the value. If the value exists as a key in the lookup table, the key's value is returned."
end

.has_parameters?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/parameter_substitution/formatters/lookup.rb', line 8

def self.has_parameters?
  true
end

Instance Method Details

#format(value) ⇒ Object



16
17
18
# File 'lib/parameter_substitution/formatters/lookup.rb', line 16

def format(value)
  @lookup_table[value.to_s]
end