Skip to content
instance method

StringScanner#inspect

() -> ::String
inspect → string

Returns a string representation of self that may show:

  1. The current position.

  2. The size (in bytes) of the stored string.

  3. The substring preceding the current position.

  4. The substring following the current position (which is also the target substring).

Example
scanner = StringScanner.new("Fri Dec 12 1975 14:39")
scanner.pos = 11
scanner.inspect # => "#<StringScanner 11/21 \"...c 12 \" @ \"1975 ...\">"

If at beginning-of-string, item 4 above (following substring) is omitted:

Example
scanner.reset
scanner.inspect # => "#<StringScanner 0/21 @ \"Fri D...\">"

If at end-of-string, all items above are omitted:

Example
scanner.terminate
scanner.inspect # => "#<StringScanner fin>"
See also #initialize_copy #match? #getch #matched also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0