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