Class: Punchout::Puncher
- Inherits:
-
Object
show all
- Defined in:
- lib/punchout/puncher.rb,
lib/punchout/puncher/matchable.rb,
lib/punchout/puncher/matchables.rb,
lib/punchout/puncher/matchable/resolver.rb
Defined Under Namespace
Classes: Matchable, Matchables
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Puncher.
6
7
8
|
# File 'lib/punchout/puncher.rb', line 6
def initialize
@matchables = Matchables.new
end
|
Instance Method Details
#add(matchable) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/punchout/puncher.rb', line 10
def add(matchable)
if !matchable.kind_of?(Matchable)
raise
end
@matchables.add(matchable)
end
|
#can_punch?(type) ⇒ Boolean
18
19
20
|
# File 'lib/punchout/puncher.rb', line 18
def can_punch?(type)
@matchables.include?(type)
end
|
#punch(type) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/punchout/puncher.rb', line 22
def punch(type)
match = @matchables.find(type)
if match
match.thing
end
end
|