Class: SvClientDrop
- Inherits:
-
Object
- Object
- SvClientDrop
- Defined in:
- lib/messages/sv_client_drop.rb
Overview
SvClientDrop
Server -> Client
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#silent ⇒ Object
Returns the value of attribute silent.
Instance Method Summary collapse
- #init_hash(attr) ⇒ Object
- #init_raw(data) ⇒ Object
-
#initialize(hash_or_raw) ⇒ SvClientDrop
constructor
A new instance of SvClientDrop.
- #silent? ⇒ Boolean
-
#to_a ⇒ Object
basically to_network int array the Server sends to the Client.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hash_or_raw) ⇒ SvClientDrop
Returns a new instance of SvClientDrop.
12 13 14 15 16 17 18 |
# File 'lib/messages/sv_client_drop.rb', line 12 def initialize(hash_or_raw) if hash_or_raw.instance_of?(Hash) init_hash(hash_or_raw) else init_raw(hash_or_raw) end end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
10 11 12 |
# File 'lib/messages/sv_client_drop.rb', line 10 def client_id @client_id end |
#reason ⇒ Object
Returns the value of attribute reason.
10 11 12 |
# File 'lib/messages/sv_client_drop.rb', line 10 def reason @reason end |
#silent ⇒ Object
Returns the value of attribute silent.
10 11 12 |
# File 'lib/messages/sv_client_drop.rb', line 10 def silent @silent end |
Instance Method Details
#init_hash(attr) ⇒ Object
28 29 30 31 32 |
# File 'lib/messages/sv_client_drop.rb', line 28 def init_hash(attr) @client_id = attr[:client_id] || 0 @reason = attr[:reason] == '' ? nil : attr[:reason] @silent = attr[:silent] || false end |
#init_raw(data) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/messages/sv_client_drop.rb', line 20 def init_raw(data) u = Unpacker.new(data) @client_id = u.get_int @reason = u.get_string @reason = @reason == '' ? nil : @reason @silent = u.get_int end |
#silent? ⇒ Boolean
42 43 44 |
# File 'lib/messages/sv_client_drop.rb', line 42 def silent? !@silent.zero? end |
#to_a ⇒ Object
basically to_network int array the Server sends to the Client
48 49 50 51 52 |
# File 'lib/messages/sv_client_drop.rb', line 48 def to_a Packer.pack_int(@client_id) + Packer.pack_str(@reason) + Packer.pack_int(@silent) end |
#to_h ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/messages/sv_client_drop.rb', line 34 def to_h { client_id: @client_id, reason: @reason, silent: @silent } end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/messages/sv_client_drop.rb', line 54 def to_s to_h end |