Class: Command

Inherits:
Plugin show all
Defined in:
lib/raphael/plugin.rb

Instance Attribute Summary collapse

Attributes inherited from Plugin

#opts, #proc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

callback, hook

Constructor Details

#initialize(cmd, opts = {}, &blk) ⇒ Command

Returns a new instance of Command.



32
33
34
35
36
# File 'lib/raphael/plugin.rb', line 32

def initialize cmd, opts={}, &blk
  @proc = blk
  @opts = opts
  @arg = cmd
end

Instance Attribute Details

#argObject (readonly)

Returns the value of attribute arg.



31
32
33
# File 'lib/raphael/plugin.rb', line 31

def arg
  @arg
end

Class Method Details

.check(text) ⇒ Object



44
45
46
47
48
# File 'lib/raphael/plugin.rb', line 44

def check text
  @plugins.any? do |plugin|
    text =~ /^@(?:nkroid)\s+#{plugin.arg}/
  end
end

.register(cmd, opts = {}, &blk) ⇒ Object



39
40
41
42
# File 'lib/raphael/plugin.rb', line 39

def register cmd, opts={}, &blk
  @plugins ||= []
  @plugins << self.new(cmd, opts, &blk)
end