Class: ParameterSubstitution::Formatters::IfNil

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

encoding, format, key, parse_duration

Constructor Details

#initialize(new_value) ⇒ IfNil

Returns a new instance of IfNil.



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

def initialize(new_value)
  @new_value = new_value
end

Class Method Details

.descriptionObject



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

def self.description
  "Takes one new_value parameter. If the input is nil, the input is replaced with new_value."
end

.has_parameters?Boolean

Returns:

  • (Boolean)


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

def self.has_parameters?
  true
end

Instance Method Details

#format(value) ⇒ Object



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

def format(value)
  value.nil? ? @new_value : value
end