Class: JSONP3::LogicalNotExpression
- Inherits:
-
Expression
- Object
- Expression
- JSONP3::LogicalNotExpression
- Defined in:
- lib/json_p3/filter.rb
Overview
An expression prefixed with the logical not operator.
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
Attributes inherited from Expression
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #evaluate(context) ⇒ Object
- #hash ⇒ Object
-
#initialize(token, expression) ⇒ LogicalNotExpression
constructor
A new instance of LogicalNotExpression.
- #to_s ⇒ Object
Constructor Details
#initialize(token, expression) ⇒ LogicalNotExpression
Returns a new instance of LogicalNotExpression.
142 143 144 145 |
# File 'lib/json_p3/filter.rb', line 142 def initialize(token, expression) super(token) @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
140 141 142 |
# File 'lib/json_p3/filter.rb', line 140 def expression @expression end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
155 156 157 158 159 |
# File 'lib/json_p3/filter.rb', line 155 def ==(other) self.class == other.class && @expression == other.expression && @token == other.token end |
#evaluate(context) ⇒ Object
147 148 149 |
# File 'lib/json_p3/filter.rb', line 147 def evaluate(context) !JSONP3.truthy?(@expression.evaluate(context)) end |
#hash ⇒ Object
163 164 165 |
# File 'lib/json_p3/filter.rb', line 163 def hash [@expression, @token].hash end |
#to_s ⇒ Object
151 152 153 |
# File 'lib/json_p3/filter.rb', line 151 def to_s "!#{@expression}" end |