Class: ClSay
- Inherits:
-
Object
- Object
- ClSay
- Defined in:
- lib/messages/cl_say.rb
Overview
ClSay
Client -> Server
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#target_id ⇒ Object
Returns the value of attribute target_id.
Instance Method Summary collapse
- #init_hash(attr) ⇒ Object
- #init_raw(data) ⇒ Object
-
#initialize(hash_or_raw) ⇒ ClSay
constructor
A new instance of ClSay.
-
#to_a ⇒ Object
basically to_network int array the client sends to the server.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hash_or_raw) ⇒ ClSay
Returns a new instance of ClSay.
12 13 14 15 16 17 18 |
# File 'lib/messages/cl_say.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
#message ⇒ Object
Returns the value of attribute message.
10 11 12 |
# File 'lib/messages/cl_say.rb', line 10 def @message end |
#mode ⇒ Object
Returns the value of attribute mode.
10 11 12 |
# File 'lib/messages/cl_say.rb', line 10 def mode @mode end |
#target_id ⇒ Object
Returns the value of attribute target_id.
10 11 12 |
# File 'lib/messages/cl_say.rb', line 10 def target_id @target_id end |
Instance Method Details
#init_hash(attr) ⇒ Object
27 28 29 30 31 |
# File 'lib/messages/cl_say.rb', line 27 def init_hash(attr) @mode = attr[:mode] || 0 @target_id = attr[:target_id] || 0 @message = attr[:message] || 0 end |
#init_raw(data) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/messages/cl_say.rb', line 20 def init_raw(data) u = Unpacker.new(data) @mode = u.get_int @target_id = u.get_int @message = u.get_string end |
#to_a ⇒ Object
basically to_network int array the client sends to the server
43 44 45 46 47 |
# File 'lib/messages/cl_say.rb', line 43 def to_a Packer.pack_int(@mode) + Packer.pack_int(@target_id) + Packer.pack_str(@message) end |
#to_h ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/messages/cl_say.rb', line 33 def to_h { mode: @mode, target_id: @target_id, message: @message } end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/messages/cl_say.rb', line 49 def to_s to_h end |