Class: Punchout::Puncher::Matchables
- Inherits:
-
Object
- Object
- Punchout::Puncher::Matchables
- Defined in:
- lib/punchout/puncher/matchables.rb
Instance Method Summary collapse
- #add(matchable) ⇒ Object
- #all ⇒ Object
- #find(type) ⇒ Object
- #include?(type) ⇒ Boolean
-
#initialize ⇒ Matchables
constructor
A new instance of Matchables.
Constructor Details
#initialize ⇒ Matchables
Returns a new instance of Matchables.
4 5 6 |
# File 'lib/punchout/puncher/matchables.rb', line 4 def initialize @matchables = [] end |
Instance Method Details
#add(matchable) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/punchout/puncher/matchables.rb', line 8 def add(matchable) if conflicts?(matchable) raise end @matchables << matchable end |
#all ⇒ Object
27 28 29 |
# File 'lib/punchout/puncher/matchables.rb', line 27 def all @matchables end |
#find(type) ⇒ Object
21 22 23 24 25 |
# File 'lib/punchout/puncher/matchables.rb', line 21 def find(type) @matchables.find do |p| p.matches?(type) end end |
#include?(type) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/punchout/puncher/matchables.rb', line 15 def include?(type) @matchables.any? do |p| p.matches?(type) end end |