module Syndi::DSL::Base
A domain-specific language (DSL
) wrapper mixin for simple usage of the events system, {Syndi::API::Events}, and the timers system, {Syndi::API::Timers}.
@api DSL
@author noxgirl @since 4.0.0
@see Syndi::API::Events @see Syndi::API::Timers
Public Instance Methods
@see Syndi::API::Timers#spawn
# File lib/syndi/dsl/base.rb, line 22 def clock_do(*args); $m.clock.spawn(*args); end
@see Syndi::API::Timers#del
# File lib/syndi/dsl/base.rb, line 24 def clock_stop(*args); $m.clock.del(*args); end
Emit an event.
@param [Symbol] system The events system to access. @param [Symbol] event The event onto which to hook.
@see Syndi::API::Events#call
# 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
Hook onto an event.
@param [Symbol] system The events system to access. @param [Symbol] event The event onto which to hook.
@see Syndi::API::Events#on
# 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
Delete a hook.
@param [Symbol] system The events system to access. @param [Array(Symbol, Integer
, String
)] hook The identification data of the hook.
@see Syndi::API::Events#del
# 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