Class: RconLine
- Inherits:
-
Object
- Object
- RconLine
- Defined in:
- lib/messages/rcon_line.rb
Overview
RconLine
Server -> Client
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
Instance Method Summary collapse
- #init_hash(attr) ⇒ Object
- #init_raw(data) ⇒ Object
-
#initialize(hash_or_raw) ⇒ RconLine
constructor
A new instance of RconLine.
-
#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) ⇒ RconLine
Returns a new instance of RconLine.
12 13 14 15 16 17 18 |
# File 'lib/messages/rcon_line.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
#command ⇒ Object
Returns the value of attribute command.
10 11 12 |
# File 'lib/messages/rcon_line.rb', line 10 def command @command end |
Instance Method Details
#init_hash(attr) ⇒ Object
25 26 27 |
# File 'lib/messages/rcon_line.rb', line 25 def init_hash(attr) @command = attr[:command] || 'hello world' end |
#init_raw(data) ⇒ Object
20 21 22 23 |
# File 'lib/messages/rcon_line.rb', line 20 def init_raw(data) u = Unpacker.new(data) @command = u.get_string end |
#to_a ⇒ Object
basically to_network int array the Server sends to the Client
37 38 39 |
# File 'lib/messages/rcon_line.rb', line 37 def to_a Packer.pack_str(@command) end |
#to_h ⇒ Object
29 30 31 32 33 |
# File 'lib/messages/rcon_line.rb', line 29 def to_h { command: @command } end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/messages/rcon_line.rb', line 41 def to_s to_h end |