Parent

WebSocket::Frame::Base

@abstract Subclass and override to implement custom frames

Attributes

data[R]
error[R]
type[R]
version[R]

Public Class Methods

new(args = {}) click to toggle source

Initialize frame @param args [Hash] Arguments for frame @option args [String] :data default data for frame @option args [String] :type Type of frame - available types are "text", "binary", "ping", "pong" and "close"(support depends on draft version) @option args [Integer] :code Code for close frame. Supported by drafts > 05. @option args [Integer] :version Version of draft. Currently supported version are 75, 76 and 00-13.

# File lib/websocket/frame/base.rb, line 14
def initialize(args = {})
  @type = args[:type].to_sym if args[:type]
  @code = args[:code]
  @data = Data.new(args[:data].to_s)
  @version = args[:version] || DEFAULT_VERSION
  include_version
end

Public Instance Methods

error?() click to toggle source

Check if some errors occured @return [Boolean] True if error is set

# File lib/websocket/frame/base.rb, line 24
def error?
  !!@error
end
inspect() click to toggle source

Recreate inspect as to_s was overwritten

# File lib/websocket/frame/base.rb, line 39
def inspect
  vars = self.instance_variables.map{|v| "#{v}=#{instance_variable_get(v).inspect}"}.join(", ")
  insp = "#{self.class}:0x%08x" % (self.__id__ * 2)
  "<#{insp} #{vars}>"
end
support_type?() click to toggle source

Is selected type supported for selected handler?

# File lib/websocket/frame/base.rb, line 29
def support_type?
  supported_frames.include?(@type)
end
supported_frames() click to toggle source

Implement in submodules

# File lib/websocket/frame/base.rb, line 34
def supported_frames
  raise NotImplementedError
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.