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.



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

def initialize(native_msg)
  @native_msg = native_msg
end

Instance Method Details

#as_binaryObject



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

def as_binary
  @native_msg.as_binary
end

#as_jsonObject



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

def as_json
  @native_msg.as_json
end

#as_textObject



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

def as_text
  raw = @native_msg.as_text
  return unless raw

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

#close?Boolean

Returns:

  • (Boolean)


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

def close?
  @native_msg.is_close
end