Module: Leonidas::Commands::Aggregator

Included in:
App::Connection
Defined in:
lib/leonidas/commands/aggregator.rb

Instance Method Summary collapse

Instance Method Details

#add_command!(command) ⇒ Object

Raises:

  • (TypeError)


6
7
8
9
# File 'lib/leonidas/commands/aggregator.rb', line 6

def add_command!(command)
	raise TypeError, "Argument must be a Leonidas::Commands::Command" unless command.is_a? ::Leonidas::Commands::Command
	@active_commands << command
end

#add_commands!(commands) ⇒ Object



11
12
13
# File 'lib/leonidas/commands/aggregator.rb', line 11

def add_commands!(commands)
	commands.each {|command| add_command!(command)}
end

#commands_since(timestamp) ⇒ Object



19
20
21
# File 'lib/leonidas/commands/aggregator.rb', line 19

def commands_since(timestamp)
	@active_commands.select {|command| command.timestamp > timestamp}
end

#commands_through(timestamp) ⇒ Object



15
16
17
# File 'lib/leonidas/commands/aggregator.rb', line 15

def commands_through(timestamp)
	@active_commands.select {|command| command.timestamp <= timestamp}
end

#deactivate_commands!(commands) ⇒ Object



23
24
25
26
# File 'lib/leonidas/commands/aggregator.rb', line 23

def deactivate_commands!(commands)
	commands.each {|command| @inactive_commands << command if @active_commands.include? command}
	@active_commands.select! {|command| not commands.include? command}
end