Class: Tina4::Drivers::BoltConnection::StringScanner
- Inherits:
-
Object
- Object
- Tina4::Drivers::BoltConnection::StringScanner
- Defined in:
- lib/tina4/drivers/bolt_graph_driver.rb
Overview
A tiny forward-only byte cursor over a binary string (avoids pulling in StringScanner, which is text-oriented and not binary-safe for our needs).
Instance Method Summary collapse
- #byte ⇒ Object
-
#initialize(bytes) ⇒ StringScanner
constructor
A new instance of StringScanner.
- #str(n) ⇒ Object
Constructor Details
#initialize(bytes) ⇒ StringScanner
Returns a new instance of StringScanner.
410 411 412 413 |
# File 'lib/tina4/drivers/bolt_graph_driver.rb', line 410 def initialize(bytes) @bytes = bytes @pos = 0 end |
Instance Method Details
#byte ⇒ Object
415 416 417 418 419 |
# File 'lib/tina4/drivers/bolt_graph_driver.rb', line 415 def byte b = @bytes.getbyte(@pos) @pos += 1 b end |
#str(n) ⇒ Object
421 422 423 424 425 |
# File 'lib/tina4/drivers/bolt_graph_driver.rb', line 421 def str(n) s = @bytes.byteslice(@pos, n) @pos += n s end |