Class: MessageCollector
- Inherits:
-
Object
show all
- Defined in:
- lib/message_collector.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of MessageCollector.
2
3
4
|
# File 'lib/message_collector.rb', line 2
def initialize(&operation)
@operation = operation
end
|
Class Method Details
.for(minecraft, &operations) ⇒ Object
6
7
8
9
10
|
# File 'lib/message_collector.rb', line 6
def self.for(minecraft, &operations)
self.new do |collector|
minecraft.with_message_collector(collector, &operations)
end
end
|
Instance Method Details
#collect(msg) ⇒ Object
12
13
14
|
# File 'lib/message_collector.rb', line 12
def collect(msg)
@collector.call(msg)
end
|
#each(&collector) ⇒ Object
16
17
18
19
|
# File 'lib/message_collector.rb', line 16
def each(&collector)
@collector = collector
@operation.call(method(:collect))
end
|