File: slice.rb [parslet-1.4.0 Documentation]

Last Modified
  2014-03-06 22:10:35 +0000
Requires

## Description

A slice is a small part from the parse input. A slice mainly behaves like any other string, except that it remembers where it came from (offset in original input).

## Extracting line and column

Using the line_and_column method, you can extract the line and column in the original input where this slice starts.

Example:

    slice.line_and_column # => [1, 13]
    slice.offset          # => 12

## Likeness to strings

Parslet::Slice behaves in many ways like a Ruby String. This likeness however is not complete - many of the myriad of operations String supports are not yet in Slice. You can always extract the internal string instance by calling to_s.

These omissions are somewhat intentional. Rather than maintaining a full delegation, we opt for a partial emulation that gets the job done.