Class: Machete::Matchers::ArrayMatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ ArrayMatcher

Returns a new instance of ArrayMatcher.



61
62
63
# File 'lib/machete/matchers.rb', line 61

def initialize(items)
  @items = items
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



59
60
61
# File 'lib/machete/matchers.rb', line 59

def items
  @items
end

Instance Method Details

#==(other) ⇒ Object



65
66
67
# File 'lib/machete/matchers.rb', line 65

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

#matches?(node) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
72
73
# File 'lib/machete/matchers.rb', line 69

def matches?(node)
  return false unless node.is_a?(Array)

  match(@items, node)
end