Class: Protocol::WebSocket::JSONMessage
Instance Attribute Summary
Attributes inherited from Message
#buffer
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from TextMessage
#send
Methods inherited from Message
#==, #encoding, #initialize, #size, #to_str
Class Method Details
.generate(object) ⇒ Object
19
20
21
|
# File 'lib/protocol/websocket/json_message.rb', line 19
def self.generate(object)
self.new(JSON.generate(object))
end
|
.wrap(message) ⇒ Object
13
14
15
16
17
|
# File 'lib/protocol/websocket/json_message.rb', line 13
def self.wrap(message)
if message.is_a?(TextMessage)
self.new(message.buffer)
end
end
|
Instance Method Details
#parse(symbolize_names: true, **options) ⇒ Object
23
24
25
|
# File 'lib/protocol/websocket/json_message.rb', line 23
def parse(symbolize_names: true, **options)
JSON.parse(@buffer, symbolize_names: symbolize_names, **options)
end
|
#to_h ⇒ Object
27
28
29
|
# File 'lib/protocol/websocket/json_message.rb', line 27
def to_h
parse.to_h
end
|