Module: Cinch::Commands::ClassMethods

Defined in:
lib/cinch/commands/commands.rb

Instance Method Summary collapse

Instance Method Details

#command(name, arguments = {}, options = {}) ⇒ Command (protected)

Registers a command.

Examples:

command :grant, {name: :string, :level: :integer},
                summary: "Grants access",
                description: %{
                  Grants a certain level of access to the user
                }

Parameters:

  • name (Symbol)
  • arguments (Hash{Symbol => Symbol,Regexp}) (defaults to: {})
  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :summary (String)

    The short summary for the command.

  • :description (String)

    The long description for the command.

Returns:



55
56
57
58
59
60
61
62
# File 'lib/cinch/commands/commands.rb', line 55

def command(name,arguments={},options={})
  new_command = Command.new(name,arguments,options)

  match(new_command.regexp, method: name)

  commands << new_command
  return new_command
end

#commandsArray<Command>

All registered commands.

Returns:

  • (Array<Command>)

    The registered commands.



23
24
25
# File 'lib/cinch/commands/commands.rb', line 23

def commands
  @commands ||= []
end