Class: Telos::Message::Incoming
- Inherits:
-
Object
- Object
- Telos::Message::Incoming
- Defined in:
- lib/telos/message/incoming.rb
Instance Method Summary collapse
- #argument_size ⇒ Object
- #arguments ⇒ Object
- #command ⇒ Object
-
#initialize(data) ⇒ Incoming
constructor
A new instance of Incoming.
- #inspect ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(data) ⇒ Incoming
Returns a new instance of Incoming.
4 5 6 |
# File 'lib/telos/message/incoming.rb', line 4 def initialize(data) @data = data end |
Instance Method Details
#argument_size ⇒ Object
12 13 14 |
# File 'lib/telos/message/incoming.rb', line 12 def argument_size from_word(@data.byteslice(4,2)) end |
#arguments ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/telos/message/incoming.rb', line 16 def arguments pos = 6 arguments = {} argument_size.times do key = @data.byteslice(pos, 4) type = @data.byteslice(pos + 4, 1) case type when "\x02" # Array / String size = from_word(@data.byteslice(pos + 5, 2)) value = @data.byteslice(pos + 7, size - 1) pos += 7 + size when "\x01" # DWord value = from_dword(@data.byteslice(pos + 5, 4)) pos += 5 + 4 end arguments[key] = value end arguments end |
#command ⇒ Object
8 9 10 |
# File 'lib/telos/message/incoming.rb', line 8 def command from_dword(@data.byteslice(0,4)) end |
#inspect ⇒ Object
42 43 44 |
# File 'lib/telos/message/incoming.rb', line 42 def inspect %{#<Telos::Message::Incoming command="#{command}" arguments=#{arguments.inspect}>} end |
#to_hash ⇒ Object
38 39 40 |
# File 'lib/telos/message/incoming.rb', line 38 def to_hash arguments end |