Class: Machete::Matchers::ChoiceMatcher
- Defined in:
- lib/machete/matchers.rb
Instance Attribute Summary collapse
-
#alternatives ⇒ Object
readonly
Returns the value of attribute alternatives.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(alternatives) ⇒ ChoiceMatcher
constructor
A new instance of ChoiceMatcher.
- #matches?(node) ⇒ Boolean
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
#alternatives ⇒ Object (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
34 35 36 |
# File 'lib/machete/matchers.rb', line 34 def matches?(node) @alternatives.any? { |a| a.matches?(node) } end |