Class: KQL::Matcher::Tag
- Inherits:
-
KQL::Matcher
- Object
- KQL::Matcher
- KQL::Matcher::Tag
- Defined in:
- lib/kql/matcher.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
(also: #value)
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #coerce(a) ⇒ Object
-
#initialize(tag) ⇒ Tag
constructor
A new instance of Tag.
- #match?(node) ⇒ Boolean
Constructor Details
#initialize(tag) ⇒ Tag
Returns a new instance of Tag.
19 20 21 |
# File 'lib/kql/matcher.rb', line 19 def initialize(tag) @tag = tag end |
Instance Attribute Details
#tag ⇒ Object (readonly) Also known as: value
Returns the value of attribute tag.
16 17 18 |
# File 'lib/kql/matcher.rb', line 16 def tag @tag end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 30 31 |
# File 'lib/kql/matcher.rb', line 27 def ==(other) return false unless other.is_a?(Tag) other.tag == tag end |
#coerce(a) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/kql/matcher.rb', line 33 def coerce(a) case a when ::KDL::Node, ::KDL::Value then a.type else a end end |
#match?(node) ⇒ Boolean
23 24 25 |
# File 'lib/kql/matcher.rb', line 23 def match?(node) node.type == tag end |