Class: Spikard::Testing::WebSocketMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/spikard/testing.rb

Overview

WebSocket message wrapper

Instance Method Summary collapse

Constructor Details

#initialize(native_msg) ⇒ WebSocketMessage

Returns a new instance of WebSocketMessage.



183
184
185
# File 'lib/spikard/testing.rb', line 183

def initialize(native_msg)
  @native_msg = native_msg
end

Instance Method Details

#as_binaryObject



200
201
202
# File 'lib/spikard/testing.rb', line 200

def as_binary
  @native_msg.as_binary
end

#as_jsonObject



196
197
198
# File 'lib/spikard/testing.rb', line 196

def as_json
  @native_msg.as_json
end

#as_textObject



187
188
189
190
191
192
193
194
# File 'lib/spikard/testing.rb', line 187

def as_text
  raw = @native_msg.as_text
  return unless raw

  JSON.parse(raw)
rescue JSON::ParserError
  raw
end

#close?Boolean

Returns:

  • (Boolean)


204
205
206
# File 'lib/spikard/testing.rb', line 204

def close?
  @native_msg.is_close
end