Class: Tina4::Drivers::BoltConnection::StringScanner

Inherits:
Object
  • Object
show all
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

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

#byteObject



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