Class: Punchout::Puncher::Matchables

Inherits:
Object
  • Object
show all
Defined in:
lib/punchout/puncher/matchables.rb

Instance Method Summary collapse

Constructor Details

#initializeMatchables

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

#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

Returns:

  • (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