Class: Aws::EventStream::BytesBuffer Private
- Inherits:
-
Object
- Object
- Aws::EventStream::BytesBuffer
- Defined in:
- lib/aws-eventstream/bytes_buffer.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #bytesize ⇒ Object private
- #clear! ⇒ Object private
- #eof? ⇒ Boolean private
-
#initialize(data) ⇒ BytesBuffer
constructor
private
This Util class is for Decoder/Encoder usage only Not for public common bytes buffer usage.
- #read(len = nil, offset = 0) ⇒ Object private
- #readbyte ⇒ Object private
- #rewind ⇒ Object private
- #tell ⇒ Object private
- #write(bytes) ⇒ Object (also: #<<) private
Constructor Details
#initialize(data) ⇒ BytesBuffer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This Util class is for Decoder/Encoder usage only Not for public common bytes buffer usage
9 10 11 12 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 9 def initialize(data) @data = data @pos = 0 end |
Instance Method Details
#bytesize ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 51 def bytesize @data.bytesize end |
#clear! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 59 def clear! @data = '' @pos = 0 end |
#eof? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 47 def eof? @pos == bytesize end |
#read(len = nil, offset = 0) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 14 def read(len = nil, offset = 0) return '' if len == 0 || bytesize == 0 unless eof? start_byte = @pos + offset end_byte = len ? start_byte + len - 1 : bytesize - 1 error = Errors::ReadBytesExceedLengthError.new(end_byte, bytesize) raise error if end_byte >= bytesize @pos = end_byte + 1 @data[start_byte..end_byte] end end |
#readbyte ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 30 def readbyte unless eof? @pos += 1 @data[@pos - 1] end end |
#rewind ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 43 def rewind @pos = 0 end |
#tell ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 55 def tell @pos end |
#write(bytes) ⇒ Object Also known as: <<
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 |
# File 'lib/aws-eventstream/bytes_buffer.rb', line 37 def write(bytes) @data <<= bytes bytes.bytesize end |