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
|
#all ⇒ Object
22
23
24
25
26
|
# File 'lib/punchout/puncher.rb', line 22
def all
@matchables.all.map do |m|
m.thing
end
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
28
29
30
31
32
33
34
35
|
# File 'lib/punchout/puncher.rb', line 28
def punch(type)
match = @matchables.find(type)
if match
match.thing
end
end
|