Class: ParameterSubstitution::Formatters::AddPrefix

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

encoding, format, key, parse_duration

Constructor Details

#initialize(prefix) ⇒ AddPrefix

Returns a new instance of AddPrefix.



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

def initialize(prefix)
  @prefix = prefix
end

Class Method Details

.descriptionObject



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

def self.description
  "This takes a prefix as a constructor parameter and prepends it to the value. If the value is blank, nothing is shown."
end

.has_parameters?Boolean

Returns:

  • (Boolean)


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

def self.has_parameters?
  true
end

Instance Method Details

#format(value) ⇒ Object



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

def format(value)
  value.presence && (@prefix + value.to_s)
end