Class: Machete::Matchers::LiteralMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/machete/matchers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(literal) ⇒ LiteralMatcher

Returns a new instance of LiteralMatcher.



123
124
125
# File 'lib/machete/matchers.rb', line 123

def initialize(literal)
  @literal = literal
end

Instance Attribute Details

#literalObject (readonly)

Returns the value of attribute literal.



121
122
123
# File 'lib/machete/matchers.rb', line 121

def literal
  @literal
end

Instance Method Details

#==(other) ⇒ Object



127
128
129
# File 'lib/machete/matchers.rb', line 127

def ==(other)
  other.instance_of?(self.class) && @literal == other.literal
end

#matches?(node) ⇒ Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/machete/matchers.rb', line 131

def matches?(node)
  @literal == node
end