Class: RconCmdAdd

Inherits:
Object
  • Object
show all
Defined in:
lib/messages/rcon_cmd_add.rb

Overview

RconCmdAdd

Server -> Client

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#helpObject

Returns the value of attribute help.



10
11
12
# File 'lib/messages/rcon_cmd_add.rb', line 10

def help
  @help
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/messages/rcon_cmd_add.rb', line 10

def name
  @name
end

#paramsObject

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_aObject

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_hObject



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_sObject



49
50
51
# File 'lib/messages/rcon_cmd_add.rb', line 49

def to_s
  to_h
end