Class: Protocol::WebSocket::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/protocol/websocket/message.rb

Direct Known Subclasses

BinaryMessage, TextMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ Message

Returns a new instance of Message.



11
12
13
# File 'lib/protocol/websocket/message.rb', line 11

def initialize(buffer)
	@buffer = buffer
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



15
16
17
# File 'lib/protocol/websocket/message.rb', line 15

def buffer
  @buffer
end

Instance Method Details

#==(other) ⇒ Object

This can be helpful for writing tests.



22
23
24
# File 'lib/protocol/websocket/message.rb', line 22

def == other
	@buffer == other.to_str
end

#encodingObject



30
31
32
# File 'lib/protocol/websocket/message.rb', line 30

def encoding
	@buffer.encoding
end

#sizeObject



17
18
19
# File 'lib/protocol/websocket/message.rb', line 17

def size
	@buffer.bytesize
end

#to_strObject



26
27
28
# File 'lib/protocol/websocket/message.rb', line 26

def to_str
	@buffer
end