Sha256: 885cd445ed70310fcb8cd25030931460018cd543da129c417456cc472b306775

Contents?: true

Size: 388 Bytes

Versions: 1

Compression:

Stored size: 388 Bytes

Contents

# frozen_string_literal: true

class Position
  attr_reader :idx, :ln, :col, :ftxt

  def initialize(idx, ln, col, ftxt)
    @idx = idx
    @ln = ln
    @col = col
    @ftxt = ftxt
  end

  def advance(current_char)
    @idx += 1
    @col += 1
    if current_char == '\n'
      @ln += 1
      @col = 0
    end
    self
  end

  def copy
    Position.new(@idx, @ln, @col, @ftxt)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simpler_lexer-0.1.0 lib/simpler_lexer/position.rb