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.



114
115
116
# File 'lib/spikard/testing.rb', line 114

def initialize(native_msg)
  @native_msg = native_msg
end

Instance Method Details

#as_binaryObject



131
132
133
# File 'lib/spikard/testing.rb', line 131

def as_binary
  @native_msg.as_binary
end

#as_jsonObject



127
128
129
# File 'lib/spikard/testing.rb', line 127

def as_json
  @native_msg.as_json
end

#as_textObject



118
119
120
121
122
123
124
125
# File 'lib/spikard/testing.rb', line 118

def as_text
  raw = @native_msg.as_text
  return unless raw

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

#close?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/spikard/testing.rb', line 135

def close?
  @native_msg.is_close
end