Class: Coder::Cleaner::Simple::ByteBuffer
- Inherits:
-
Object
- Object
- Coder::Cleaner::Simple::ByteBuffer
- Defined in:
- lib/coder/cleaner/simple/byte_buffer.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#bytes ⇒ Object
Returns the value of attribute bytes.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#outstanding ⇒ Object
Returns the value of attribute outstanding.
Instance Method Summary collapse
- #<<(byte) ⇒ Object
-
#initialize(encoding) ⇒ ByteBuffer
constructor
A new instance of ByteBuffer.
- #to_s ⇒ Object
Constructor Details
#initialize(encoding) ⇒ ByteBuffer
Returns a new instance of ByteBuffer.
7 8 9 10 |
# File 'lib/coder/cleaner/simple/byte_buffer.rb', line 7 def initialize(encoding) @encoding, @bytes = encoding, [] clear_buffer end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
5 6 7 |
# File 'lib/coder/cleaner/simple/byte_buffer.rb', line 5 def buffer @buffer end |
#bytes ⇒ Object
Returns the value of attribute bytes.
5 6 7 |
# File 'lib/coder/cleaner/simple/byte_buffer.rb', line 5 def bytes @bytes end |
#encoding ⇒ Object
Returns the value of attribute encoding.
5 6 7 |
# File 'lib/coder/cleaner/simple/byte_buffer.rb', line 5 def encoding @encoding end |
#outstanding ⇒ Object
Returns the value of attribute outstanding.
5 6 7 |
# File 'lib/coder/cleaner/simple/byte_buffer.rb', line 5 def outstanding @outstanding end |
Instance Method Details
#<<(byte) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/coder/cleaner/simple/byte_buffer.rb', line 12 def <<(byte) if encoding.garbage? byte, buffer clear_buffer elsif encoding.single_byte? byte, buffer add(byte) elsif encoding.multibyte_body? byte, buffer fill_buffer(byte) elsif encoding.multibyte_start? byte, buffer start_buffer(byte, encoding.multibyte_size(byte, buffer)) else clear_buffer end end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/coder/cleaner/simple/byte_buffer.rb', line 26 def to_s bytes.pack('C*') end |