Class: Protocol::Jsonrpc::Framer
- Inherits:
-
Object
- Object
- Protocol::Jsonrpc::Framer
- Defined in:
- lib/protocol/jsonrpc/framer.rb
Instance Method Summary collapse
-
#close ⇒ Object
Close the stream.
-
#flush ⇒ Object
Flush the stream.
-
#initialize(stream, frame_class: Frame) ⇒ Framer
constructor
A new instance of Framer.
-
#read_frame {|frame| ... } ⇒ Frame
Read a frame from the stream.
-
#write_frame(frame) ⇒ Object
Write a frame to the stream.
Constructor Details
#initialize(stream, frame_class: Frame) ⇒ Framer
Returns a new instance of Framer.
11 12 13 14 |
# File 'lib/protocol/jsonrpc/framer.rb', line 11 def initialize(stream, frame_class: Frame) @stream = stream @frame_class = frame_class end |
Instance Method Details
#close ⇒ Object
Close the stream
36 37 38 |
# File 'lib/protocol/jsonrpc/framer.rb', line 36 def close @stream.close end |
#flush ⇒ Object
Flush the stream
31 32 33 |
# File 'lib/protocol/jsonrpc/framer.rb', line 31 def flush @stream.flush end |
#read_frame {|frame| ... } ⇒ Frame
Read a frame from the stream
18 19 20 21 22 |
# File 'lib/protocol/jsonrpc/framer.rb', line 18 def read_frame(&block) frame = @frame_class.read(@stream) yield frame if block_given? frame end |
#write_frame(frame) ⇒ Object
Write a frame to the stream
26 27 28 |
# File 'lib/protocol/jsonrpc/framer.rb', line 26 def write_frame(frame) frame.write(@stream) end |