Class: KHL::WebSocket::Message
- Inherits:
-
Object
- Object
- KHL::WebSocket::Message
- Defined in:
- lib/khl/web_socket/message.rb
Constant Summary collapse
- TYPES =
%i[ event hello ping pong resume reconnect resume_ack ].freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#sn ⇒ Object
Returns the value of attribute sn.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type: nil, data: nil, sn: nil) ⇒ Message
constructor
A new instance of Message.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(type: nil, data: nil, sn: nil) ⇒ Message
Returns a new instance of Message.
29 30 31 32 33 |
# File 'lib/khl/web_socket/message.rb', line 29 def initialize(type: nil, data: nil, sn: nil) @type = type @data = data @sn = sn end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
16 17 18 |
# File 'lib/khl/web_socket/message.rb', line 16 def data @data end |
#sn ⇒ Object
Returns the value of attribute sn.
16 17 18 |
# File 'lib/khl/web_socket/message.rb', line 16 def sn @sn end |
#type ⇒ Object
Returns the value of attribute type.
16 17 18 |
# File 'lib/khl/web_socket/message.rb', line 16 def type @type end |
Class Method Details
Instance Method Details
#to_h ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/khl/web_socket/message.rb', line 35 def to_h { s: TYPES.index(type), d: data, sn: sn } end |
#to_json ⇒ Object
43 44 45 |
# File 'lib/khl/web_socket/message.rb', line 43 def to_json to_h.to_json end |