Class: WebSocket::Frame::Base Abstract
- Inherits:
-
Object
- Object
- WebSocket::Frame::Base
- Defined in:
- lib/websocket/frame/base.rb
Overview
This class is abstract.
Subclass and override to implement custom frames
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Check if some errors occured.
-
#initialize(args = {}) ⇒ Base
constructor
Initialize frame.
-
#inspect ⇒ Object
Recreate inspect as #to_s was overwritten.
-
#support_type? ⇒ Boolean
Is selected type supported for selected handler?.
-
#supported_frames ⇒ Object
Implement in submodules.
Constructor Details
#initialize(args = {}) ⇒ Base
Initialize frame
13 14 15 16 17 18 |
# File 'lib/websocket/frame/base.rb', line 13 def initialize(args = {}) @type = args[:type] @data = Data.new(args[:data].to_s) @version = args[:version] || DEFAULT_VERSION include_version end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/websocket/frame/base.rb', line 6 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
6 7 8 |
# File 'lib/websocket/frame/base.rb', line 6 def error @error end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/websocket/frame/base.rb', line 6 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/websocket/frame/base.rb', line 6 def version @version end |
Instance Method Details
#error? ⇒ Boolean
Check if some errors occured
22 23 24 |
# File 'lib/websocket/frame/base.rb', line 22 def error? !!@error end |
#inspect ⇒ Object
Recreate inspect as #to_s was overwritten
37 38 39 40 41 |
# File 'lib/websocket/frame/base.rb', line 37 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? ⇒ Boolean
Is selected type supported for selected handler?
27 28 29 |
# File 'lib/websocket/frame/base.rb', line 27 def support_type? supported_frames.include?(@type) end |
#supported_frames ⇒ Object
Implement in submodules
32 33 34 |
# File 'lib/websocket/frame/base.rb', line 32 def supported_frames raise NotImplementedError end |