Class: Syncro::Protocol::Message
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- Syncro::Protocol::Message
- Defined in:
- lib/syncro/protocol/message.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.fromJSON(str) ⇒ Object
6 7 8 |
# File 'lib/syncro/protocol/message.rb', line 6 def self.fromJSON(str) self.new(JSON.parse(str)) end |
Instance Method Details
#serialize ⇒ Object
18 19 20 21 |
# File 'lib/syncro/protocol/message.rb', line 18 def serialize data = self.to_json [data.length].pack('n') + data end |
#type ⇒ Object
10 11 12 |
# File 'lib/syncro/protocol/message.rb', line 10 def type self[:type].try(:to_sym) end |
#type=(sym) ⇒ Object
14 15 16 |
# File 'lib/syncro/protocol/message.rb', line 14 def type=(sym) self[:type] = sym end |