Module: LibSL::DSL
- Defined in:
- lib/dsl.rb
Class Method Summary collapse
-
.client ⇒ Object
Client getter.
Instance Method Summary collapse
-
#handle(type, cb = nil, &block) ⇒ Object
Handle the event type given a Proc cb or a block.
- #logger ⇒ Object
-
#send_packet(packet, reliable = false) ⇒ Object
Send packet.
-
#set_logging(output, debug = false, colors = true) ⇒ Object
Configure logging.
-
#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object
Setup the client is given.
- #shutdown ⇒ Object
-
#when_ready(cb = nil) {|Symbol| ... } ⇒ Object
Handle the :ready event (syntactic sugar).
- #when_stopped(cb = nil, &block) ⇒ Object
- #when_stopping(cb = nil, &block) ⇒ Object
Class Method Details
Instance Method Details
#handle(type, cb = nil, &block) ⇒ Object
Handle the event type given a Proc cb or a block
52 53 54 55 |
# File 'lib/dsl.rb', line 52 def handle(type, cb=nil, &block) cb ||= Proc.new EventManager::register_handler EventHandler.new(Proc.new, type) end |
#logger ⇒ Object
10 11 12 |
# File 'lib/dsl.rb', line 10 def logger client.logger end |
#send_packet(packet, reliable = false) ⇒ Object
Send packet
59 60 61 |
# File 'lib/dsl.rb', line 59 def send_packet(packet, reliable=false) client.network_manager.send_packet(packet, reliable) end |
#set_logging(output, debug = false, colors = true) ⇒ Object
Configure logging
19 20 21 |
# File 'lib/dsl.rb', line 19 def set_logging(output, debug=false, colors=true) client.logger = Logger.new(output, debug, colors) end |
#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object
Setup the client is given
30 31 32 |
# File 'lib/dsl.rb', line 30 def setup(firstname, lastname, password, start='last', grid=:agni) client.setup firstname, lastname, password, start, grid end |
#shutdown ⇒ Object
63 64 65 |
# File 'lib/dsl.rb', line 63 def shutdown client.stop end |
#when_ready(cb = nil) {|Symbol| ... } ⇒ Object
Handle the :ready event (syntactic sugar)
38 39 40 |
# File 'lib/dsl.rb', line 38 def when_ready(cb=nil, &block) handle(:ready, cb, &block) end |
#when_stopped(cb = nil, &block) ⇒ Object
46 47 48 |
# File 'lib/dsl.rb', line 46 def when_stopped(cb=nil, &block) handle(:stopped, cb, &block) end |
#when_stopping(cb = nil, &block) ⇒ Object
42 43 44 |
# File 'lib/dsl.rb', line 42 def when_stopping(cb=nil, &block) handle(:stopping, cb, &block) end |