Class: Greeb::StringScanner

Inherits:
StringScanner
  • Object
show all
Defined in:
lib/greeb/strscan.rb

Overview

StringScanner provides for lexical scanning operations on a String. This implementation covers the byte slicing problem in the standard library's implementation.

Instance Method Summary collapse

Instance Method Details

#char_posFixnum

Returns the character position of the scan pointer. In the `reset` position, this value is zero. In the `terminated` position (i.e. the string is exhausted), this value is the length of the string.

Returns:

  • (Fixnum)

    the character position of the scan pointer.


17
18
19
# File 'lib/greeb/strscan.rb', line 17

def char_pos
  string.byteslice(0...pos).length
end