Class: Machete::Matchers::ChoiceMatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alternatives) ⇒ ChoiceMatcher

Returns a new instance of ChoiceMatcher.



26
27
28
# File 'lib/machete/matchers.rb', line 26

def initialize(alternatives)
  @alternatives = alternatives
end

Instance Attribute Details

#alternativesObject (readonly)

Returns the value of attribute alternatives.



24
25
26
# File 'lib/machete/matchers.rb', line 24

def alternatives
  @alternatives
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/machete/matchers.rb', line 30

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

#matches?(node) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/machete/matchers.rb', line 34

def matches?(node)
  @alternatives.any? { |a| a.matches?(node) }
end