class WebSocket::Frame::Handler::Base

Public Class Methods

new(frame) click to toggle source
# File lib/websocket/frame/handler/base.rb, line 7
def initialize(frame)
  @frame = frame
end

Public Instance Methods

decode_frame() click to toggle source

Convert raw data to decoded frame @return [WebSocket::Frame::Incoming] Frame if found, nil otherwise

# File lib/websocket/frame/handler/base.rb, line 19
def decode_frame
  raise NotImplementedError
end
encode_frame() click to toggle source

Convert data to raw frame ready to send to client @return [String] Encoded frame

# File lib/websocket/frame/handler/base.rb, line 13
def encode_frame
  raise NotImplementedError
end

Private Instance Methods

control_frame?(frame_type) click to toggle source

Check if frame is one of control frames @param [Symbol] frame_type Frame type @return [Boolean] True if given frame type is control frame

# File lib/websocket/frame/handler/base.rb, line 28
def control_frame?(frame_type)
  !%i[text binary continuation].include?(frame_type)
end
data_frame?(frame_type) click to toggle source

Check if frame is one of data frames @param [Symbol] frame_type Frame type @return [Boolean] True if given frame type is data frame

# File lib/websocket/frame/handler/base.rb, line 35
def data_frame?(frame_type)
  %i[text binary].include?(frame_type)
end