Class: Conditions::NotCondition

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

Overview

Checks if a condition is not true

Instance Method Summary collapse

Constructor Details

#initialize(predicate) ⇒ NotCondition

Returns a new instance of NotCondition.

Parameters:

  • predicate (Hash)

    A hash representing a condition

Raises:



123
124
125
126
127
128
# File 'lib/conditions.rb', line 123

def initialize(predicate)
  raise ConditionError, 'Not condition predicate a condition' unless predicate.is_a?(Hash) && predicate.key?('class')

  predicate = Object.const_get("Conditions::#{predicate['class']}").new(predicate['predicate'])
  super(predicate)
end

Instance Method Details

#apply(value) ⇒ true, false

Parameters:

  • value (Any)

Returns:

  • (true)

    if value does not satisfy the condition

  • (false)

    if value satisfies the condition



134
135
136
# File 'lib/conditions.rb', line 134

def apply(value)
  !@predicate.apply(value)
end