Module: Blur::Script::Commands

Defined in:
library/blur/script/commands.rb

Overview

The Commands module is a module that gives the ability to turn a script into a DSL-like framework.

Defined Under Namespace

Classes: Command

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Extend base with self.



57
58
59
# File 'library/blur/script/commands.rb', line 57

def self.extended base
  base.instance_variable_set :@__commands, []
end

Instance Method Details

#command(name, *args, &block) ⇒ Object

Add a new command handler and trigger.



62
63
64
# File 'library/blur/script/commands.rb', line 62

def command name, *args, &block
  @__commands << Command.new(name, *args, &block)
end

#message(user, channel, line) ⇒ Object

Handle all calls to the scripts message method, check to see if the message containts a valid command, serialize it and pass it to the script as command_name with the parameters user, channel and message.



70
71
72
73
74
# File 'library/blur/script/commands.rb', line 70

def message user, channel, line
  @__commands.each do |command|
    command.received_message user, channel, line
  end
end