Class: JSONP3::Path::LogicalNotExpression
- Inherits:
-
Expression
- Object
- Expression
- JSONP3::Path::LogicalNotExpression
- Defined in:
- lib/json_p3/path/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.
144 145 146 147 |
# File 'lib/json_p3/path/filter.rb', line 144 def initialize(token, expression) super(token) @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
142 143 144 |
# File 'lib/json_p3/path/filter.rb', line 142 def expression @expression end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
157 158 159 160 161 |
# File 'lib/json_p3/path/filter.rb', line 157 def ==(other) self.class == other.class && @expression == other.expression && @token == other.token end |
#evaluate(context) ⇒ Object
149 150 151 |
# File 'lib/json_p3/path/filter.rb', line 149 def evaluate(context) !JSONP3::Path.truthy?(@expression.evaluate(context)) end |
#hash ⇒ Object
165 166 167 |
# File 'lib/json_p3/path/filter.rb', line 165 def hash [@expression, @token].hash end |
#to_s ⇒ Object
153 154 155 |
# File 'lib/json_p3/path/filter.rb', line 153 def to_s "!#{@expression}" end |