Module: Syndi::DSL::Base
- Included in:
- IRC::Server
- Defined in:
- lib/syndi/dsl/base.rb
Overview
A domain-specific language (DSL) wrapper mixin for simple usage of the events system, API::Events, and the timers system, API::Timers.
Instance Method Summary collapse
- #clock_do(*args) ⇒ Object
- #clock_stop(*args) ⇒ Object
-
#emit(sys, event, *args) ⇒ Object
Emit an event.
-
#on(sys, event, &prc) ⇒ Object
Hook onto an event.
-
#undo_on(sys, hook) ⇒ Object
Delete a hook.
Instance Method Details
#clock_do(*args) ⇒ Object
22 |
# File 'lib/syndi/dsl/base.rb', line 22 def clock_do(*args); $m.clock.spawn(*args); end |
#clock_stop(*args) ⇒ Object
24 |
# File 'lib/syndi/dsl/base.rb', line 24 def clock_stop(*args); $m.clock.del(*args); end |
#emit(sys, event, *args) ⇒ Object
Emit an event.
46 47 48 49 50 51 52 |
# File 'lib/syndi/dsl/base.rb', line 46 def emit(sys, event, *args) if sys == :syndi # central system $m.events.call(event, *args) else $m.send(sys).events.call(event, *args) if $m.respond_to? sys end end |
#on(sys, event, &prc) ⇒ Object
Hook onto an event.
32 33 34 35 36 37 38 |
# File 'lib/syndi/dsl/base.rb', line 32 def on(sys, event, &prc) if sys == :syndi # central system $m.events.on(event, prc) else $m.send(sys).events.on(event, prc) if $m.respond_to? sys end end |
#undo_on(sys, hook) ⇒ Object
Delete a hook.
60 61 62 63 64 65 66 |
# File 'lib/syndi/dsl/base.rb', line 60 def undo_on(sys, hook) if sys == :syndi # central system $m.events.del(hook) else $m.send(sys).events.del(hook) if $m.respond_to? sys end end |