Class: Cadenza::BooleanInverseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenza/nodes/boolean_inverse_node.rb

Overview

The BooleanInverseNode takes an expression and evaluates the logical inverse of that expression so any expression that evaluates to true will return false and vice versa.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression) ⇒ BooleanInverseNode

creates a new Cadenza::BooleanInverseNode with the given expression

Parameters:



11
12
13
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 11

def initialize(expression)
   @expression = expression
end

Instance Attribute Details

#expressionOperationNode

Returns an evaluatable expression node.

Returns:



7
8
9
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 7

def expression
  @expression
end

Instance Method Details

#==(rhs) ⇒ Boolean

Returns if the given Cadenza::BooleanInverseNode is equivalent by value.

Parameters:

Returns:



17
18
19
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 17

def ==(rhs)
   @expression == rhs.expression
end

#eval(context) ⇒ Object

Returns the value of this node evaluated with the data in the given Context.

Parameters:

Returns:

  • the value of this node evaluated with the data in the given Context



23
24
25
26
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 23

def eval(context)
   #TODO: rename me to .evaluate
   !@expression.eval(context)
end