Class: Cborb::Decoding::SimpleBuffer
- Inherits:
-
Object
- Object
- Cborb::Decoding::SimpleBuffer
- Extended by:
- Forwardable
- Defined in:
- lib/cborb/decoding/simple_buffer.rb
Instance Method Summary collapse
-
#initialize ⇒ SimpleBuffer
constructor
A new instance of SimpleBuffer.
- #peek ⇒ Object
- #reset! ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize ⇒ SimpleBuffer
Returns a new instance of SimpleBuffer.
7 8 9 10 |
# File 'lib/cborb/decoding/simple_buffer.rb', line 7 def initialize @buffer = StringIO.new @buffer.set_encoding(Encoding::ASCII_8BIT) end |
Instance Method Details
#peek ⇒ Object
24 25 26 27 |
# File 'lib/cborb/decoding/simple_buffer.rb', line 24 def peek pos = @buffer.pos @buffer.read.to_s.tap { @buffer.pos = pos } end |
#reset! ⇒ Object
19 20 21 22 |
# File 'lib/cborb/decoding/simple_buffer.rb', line 19 def reset! @buffer.rewind @buffer.truncate(0) end |
#write(data) ⇒ Object
13 14 15 16 17 |
# File 'lib/cborb/decoding/simple_buffer.rb', line 13 def write(data) pos = @buffer.pos @buffer << data @buffer.pos = pos end |