Class: Butler::IRC::Parser::Commands
- Inherits:
-
Object
- Object
- Butler::IRC::Parser::Commands
- Defined in:
- lib/butler/irc/parser/commands.rb
Instance Method Summary collapse
- #[](raw) ⇒ Object
- #add(raw, *args, &proc) ⇒ Object
- #alter(raw, *args, &proc) ⇒ Object
-
#initialize(specifics = nil) ⇒ Commands
constructor
A new instance of Commands.
- #inspect ⇒ Object
Constructor Details
#initialize(specifics = nil) ⇒ Commands
Returns a new instance of Commands.
17 18 19 20 21 |
# File 'lib/butler/irc/parser/commands.rb', line 17 def initialize(specifics=nil) @commands = Hash.new { |h,k| raise IndexError, "Unknown command #{k}" } file = "#{File.dirname(__FILE__)}/generic.rb" instance_eval(File.read(file), file) end |
Instance Method Details
#[](raw) ⇒ Object
33 34 35 |
# File 'lib/butler/irc/parser/commands.rb', line 33 def [](raw) @commands[raw.downcase] end |
#add(raw, *args, &proc) ⇒ Object
23 24 25 26 |
# File 'lib/butler/irc/parser/commands.rb', line 23 def add(raw, *args, &proc) raise IndexError, "Command #{raw} is already registered. Did you want 'alter'?" if @commands.has_key?(raw) @commands[raw.downcase] = Command.new(raw, *args, &proc) end |
#alter(raw, *args, &proc) ⇒ Object
28 29 30 31 |
# File 'lib/butler/irc/parser/commands.rb', line 28 def alter(raw, *args, &proc) raise IndexError, "Command #{raw} is not registered. Did you want 'add'?" unless @commands.has_key?(raw) @commands[raw.downcase] = Command.new(raw, *args, &proc) end |
#inspect ⇒ Object
37 38 39 |
# File 'lib/butler/irc/parser/commands.rb', line 37 def inspect "#<%s:0x%x>" % [self.class, object_id] end |