Class: KQL::Matcher::Comparison
- Inherits:
-
KQL::Matcher
- Object
- KQL::Matcher
- KQL::Matcher::Comparison
- Defined in:
- lib/kql/matcher.rb
Instance Attribute Summary collapse
-
#accessor ⇒ Object
readonly
Returns the value of attribute accessor.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(accessor, operator, value) ⇒ Comparison
constructor
A new instance of Comparison.
- #match?(node) ⇒ Boolean
Constructor Details
#initialize(accessor, operator, value) ⇒ Comparison
Returns a new instance of Comparison.
65 66 67 68 69 |
# File 'lib/kql/matcher.rb', line 65 def initialize(accessor, operator, value) @accessor = accessor @operator = operator @value = value end |
Instance Attribute Details
#accessor ⇒ Object (readonly)
Returns the value of attribute accessor.
63 64 65 |
# File 'lib/kql/matcher.rb', line 63 def accessor @accessor end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
63 64 65 |
# File 'lib/kql/matcher.rb', line 63 def operator @operator end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
63 64 65 |
# File 'lib/kql/matcher.rb', line 63 def value @value end |
Instance Method Details
#==(other) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/kql/matcher.rb', line 77 def ==(other) return false unless other.is_a?(Comparison) other.accessor == accessor && other.operator == operator && other.value == value end |
#match?(node) ⇒ Boolean
71 72 73 74 75 |
# File 'lib/kql/matcher.rb', line 71 def match?(node) return false unless accessor.match?(node) operator.execute(value.coerce(accessor.execute(node)), value.value) end |