Class: KQL::Matcher::Tag

Inherits:
KQL::Matcher show all
Defined in:
lib/kql/matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tagObject (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

Returns:

  • (Boolean)


23
24
25
# File 'lib/kql/matcher.rb', line 23

def match?(node)
  node.type == tag
end