Sha256: bacf7e215069147ebb790af826accf016b000b46287245a80f58dabd3424a2e2

Contents?: true

Size: 343 Bytes

Versions: 3

Compression:

Stored size: 343 Bytes

Contents

module Attentive
  class Cursor
    attr_reader :tokens, :pos

    def initialize(tokens, pos=0)
      @tokens = tokens
      @pos = pos
    end

    def peek
      tokens[pos]
    end

    def pop
      @pos += 1
      tokens[pos - 1]
    end

    def to_s
      tokens[pos..-1].join
    end

    def offset
      peek.pos
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attentive-0.1.1 lib/attentive/cursor.rb
attentive-0.1.0 lib/attentive/cursor.rb
attentive-0.1.0.beta1 lib/attentive/cursor.rb