Class: MessageCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/message_collector.rb

Direct Known Subclasses

MessageCollectorProcessed

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&operation) ⇒ MessageCollector

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