Class: Weskit::MP::Connection
- Extended by:
- Forwardable
- Defined in:
- lib/weskit/mp/connection.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #close ⇒ Object
- #defaults ⇒ Object
-
#initialize(worker, options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #open ⇒ Object
Constructor Details
#initialize(worker, options = {}) ⇒ Connection
Returns a new instance of Connection.
26 27 28 29 30 31 |
# File 'lib/weskit/mp/connection.rb', line 26 def initialize worker, = {} @options = defaults.merge @adapter = Adapter.new self, @options[:debug] @worker = worker end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
10 11 12 |
# File 'lib/weskit/mp/connection.rb', line 10 def adapter @adapter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/weskit/mp/connection.rb', line 10 def @options end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
10 11 12 |
# File 'lib/weskit/mp/connection.rb', line 10 def socket @socket end |
Instance Method Details
#close ⇒ Object
13 14 15 |
# File 'lib/weskit/mp/connection.rb', line 13 def close @socket.close end |
#defaults ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/weskit/mp/connection.rb', line 17 def defaults { :debug => false, :host => 'server.wesnoth.org', :port => 15000, :version => '1.10.0' } end |
#open ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/weskit/mp/connection.rb', line 33 def open @socket = socket_for destination_socket @worker.login if block_given? result = yield close ; result end end |