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.



181
182
183
# File 'lib/spikard/testing.rb', line 181

def initialize(native_msg)
  @native_msg = native_msg
end

Instance Method Details

#as_binaryObject



198
199
200
# File 'lib/spikard/testing.rb', line 198

def as_binary
  @native_msg.as_binary
end

#as_jsonObject



194
195
196
# File 'lib/spikard/testing.rb', line 194

def as_json
  @native_msg.as_json
end

#as_textObject



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

def as_text
  raw = @native_msg.as_text
  return unless raw

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

#close?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/spikard/testing.rb', line 202

def close?
  @native_msg.is_close
end