1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
module Morpher
class Evaluator
class Predicate
# Predicate negation
class Negation < self
include Unary
register :negate
# Return evaluation for input
#
# @param [Object] input
#
# @return [Evaluation]
#
# @api private
#
def evaluation(input)
operand_output = operand.call(input)
evaluation_success(input, operand_output, !operand_output)
end
# Call evaluator
#
# @param [Object] input
#
# @return [true]
# if input NOT evaluated to true under operand
#
# @return [false]
# otherwise
#
# @api private
#
def call(input)
!operand.call(input)
end
# Return inverse evaluator
#
# @return [Evaluator]
#
# @api private
#
def inverse
operand
end
end # Negation
end # Predicate
end # Evaluator
end # Morpher
|