Class: Raibo::DSL
- Inherits:
-
Object
show all
- Defined in:
- lib/raibo/dsl.rb
Instance Method Summary
collapse
Constructor Details
#initialize(bot, connection) ⇒ DSL
Returns a new instance of DSL.
3
4
5
6
|
# File 'lib/raibo/dsl.rb', line 3
def initialize(bot, connection)
@bot = bot
@connection = connection
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
24
25
26
|
# File 'lib/raibo/dsl.rb', line 24
def method_missing(meth, *args, &block)
@connection.__send__(meth, *args, &block)
end
|
Instance Method Details
#doc(cmd, desc = '') ⇒ Object
20
21
22
|
# File 'lib/raibo/dsl.rb', line 20
def doc(cmd, desc='')
@bot.docs << [cmd, desc]
end
|
#match(regexp, &block) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/raibo/dsl.rb', line 12
def match(regexp, &block)
use do |msg|
if msg.body =~ regexp
exec_with_var_arity($~, msg, &block)
end
end
end
|
#use(handler = nil, &block) ⇒ Object
8
9
10
|
# File 'lib/raibo/dsl.rb', line 8
def use(handler=nil, &block)
@bot.use(handler, &block)
end
|