Class: JSONP3::Path::FilterExpression
- Inherits:
-
Expression
- Object
- Expression
- JSONP3::Path::FilterExpression
- Defined in:
- lib/json_p3/path/filter.rb
Overview
An expression that evaluates to true or false.
Defined Under Namespace
Classes: Precedence
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) ⇒ FilterExpression
constructor
A new instance of FilterExpression.
- #to_s ⇒ Object
Constructor Details
#initialize(token, expression) ⇒ FilterExpression
Returns a new instance of FilterExpression.
28 29 30 31 |
# File 'lib/json_p3/path/filter.rb', line 28 def initialize(token, expression) super(token) @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
26 27 28 |
# File 'lib/json_p3/path/filter.rb', line 26 def expression @expression end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
41 42 43 44 45 |
# File 'lib/json_p3/path/filter.rb', line 41 def ==(other) self.class == other.class && @expression == other.expression && @token == other.token end |
#evaluate(context) ⇒ Object
33 34 35 |
# File 'lib/json_p3/path/filter.rb', line 33 def evaluate(context) JSONP3::Path.truthy?(@expression.evaluate(context)) end |
#hash ⇒ Object
49 50 51 |
# File 'lib/json_p3/path/filter.rb', line 49 def hash [@expression, @token].hash end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/json_p3/path/filter.rb', line 37 def to_s to_canonical_string(@expression, Precedence::LOWEST) end |