Class: WebSocketClient::FrameWriter
- Inherits:
-
Object
- Object
- WebSocketClient::FrameWriter
- Defined in:
- lib/websocket_client/frame_io.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#sink ⇒ Object
readonly
Returns the value of attribute sink.
Instance Method Summary collapse
-
#initialize(sink, debug = false) ⇒ FrameWriter
constructor
A new instance of FrameWriter.
- #write_as_text_frame(text) ⇒ Object
- #write_close_frame ⇒ Object
- #write_frame(frame) ⇒ Object
Constructor Details
#initialize(sink, debug = false) ⇒ FrameWriter
Returns a new instance of FrameWriter.
45 46 47 48 |
# File 'lib/websocket_client/frame_io.rb', line 45 def initialize(sink,debug=false) @sink = sink @debug = debug end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
43 44 45 |
# File 'lib/websocket_client/frame_io.rb', line 43 def debug @debug end |
#sink ⇒ Object (readonly)
Returns the value of attribute sink.
42 43 44 |
# File 'lib/websocket_client/frame_io.rb', line 42 def sink @sink end |
Instance Method Details
#write_as_text_frame(text) ⇒ Object
54 55 56 |
# File 'lib/websocket_client/frame_io.rb', line 54 def write_as_text_frame(text) write_frame( TextFrame.new( text ) ) end |
#write_close_frame ⇒ Object
50 51 52 |
# File 'lib/websocket_client/frame_io.rb', line 50 def write_close_frame() write_frame( CloseFrame::INSTANCE ) end |
#write_frame(frame) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/websocket_client/frame_io.rb', line 58 def write_frame(frame) frame.bytes.each do |b| @sink.write( b ) end @sink.flush end |