Class: WebSocket::Frame::Base Abstract
- Inherits:
-
Object
- Object
- WebSocket::Frame::Base
- Includes:
- ExceptionHandler, NiceInspect
- Defined in:
- lib/websocket/frame/base.rb
Overview
This class is abstract.
Subclass and override to implement custom frames
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#data ⇒ Object
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.
-
#support_type? ⇒ Boolean
Is selected type supported for selected handler?.
-
#supported_frames ⇒ Object
Implement in submodules.
Methods included from NiceInspect
Methods included from ExceptionHandler
Constructor Details
#initialize(args = {}) ⇒ Base
Initialize frame
19 20 21 22 23 24 25 26 |
# File 'lib/websocket/frame/base.rb', line 19 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 @handler = nil include_version end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
11 12 13 |
# File 'lib/websocket/frame/base.rb', line 11 def code @code end |
#data ⇒ Object
Returns the value of attribute data.
11 12 13 |
# File 'lib/websocket/frame/base.rb', line 11 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
10 11 12 |
# File 'lib/websocket/frame/base.rb', line 10 def error @error end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/websocket/frame/base.rb', line 10 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/websocket/frame/base.rb', line 10 def version @version end |
Instance Method Details
#error? ⇒ Boolean
Check if some errors occured
31 32 33 |
# File 'lib/websocket/frame/base.rb', line 31 def error? !@error.nil? end |
#support_type? ⇒ Boolean
Is selected type supported for selected handler?
36 37 38 |
# File 'lib/websocket/frame/base.rb', line 36 def support_type? @handler.supported_frames.include?(@type) end |
#supported_frames ⇒ Object
Implement in submodules
41 42 43 |
# File 'lib/websocket/frame/base.rb', line 41 def supported_frames raise NotImplementedError end |