Class: Conditions::LessThanCondition

Inherits:
BaseCondition show all
Defined in:
lib/conditions.rb

Overview

Checks if value is less than a predicate

Instance Method Summary collapse

Constructor Details

#initialize(predicate) ⇒ LessThanCondition

Returns a new instance of LessThanCondition.

Parameters:

  • predicate (Numeric)

Raises:



144
145
146
147
148
# File 'lib/conditions.rb', line 144

def initialize(predicate)
  raise ConditionError, 'LessThan condition predicate must a number' unless predicate.is_a?(Numeric)

  super(predicate)
end

Instance Method Details

#apply(value) ⇒ true, false

Parameters:

  • value (Numeric)

Returns:

  • (true)

    if value < predicate

  • (false)

    if value >= predicate



154
155
156
# File 'lib/conditions.rb', line 154

def apply(value)
  value < @predicate
end