Class: ParameterSubstitution::Formatters::GreaterThanValue

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

encoding, format, key, parse_duration

Constructor Details

#initialize(compare_value, true_value, false_value) ⇒ GreaterThanValue

Returns a new instance of GreaterThanValue.



12
13
14
15
16
# File 'lib/parameter_substitution/formatters/greater_than_value.rb', line 12

def initialize(compare_value, true_value, false_value)
  @compare_value = compare_value
  @true_value = true_value
  @false_value = false_value
end

Class Method Details

.descriptionObject



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

def self.description
  "Compares numerical values and returns results based on the comparison"
end

.has_parameters?Boolean

Returns:

  • (Boolean)


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

def self.has_parameters?
  true
end

Instance Method Details

#format(value) ⇒ Object



18
19
20
# File 'lib/parameter_substitution/formatters/greater_than_value.rb', line 18

def format(value)
  self.class.parse_duration(value) > @compare_value.to_i ? @true_value : @false_value
end