class Sass::Source::Position

Attributes

line[RW]

The one-based line of the document associated with the position.

@return [Integer]

offset[RW]

The one-based offset in the line of the document associated with the position.

@return [Integer]

Public Class Methods

new(line, offset) click to toggle source

@param line [Integer] The source line @param offset [Integer] The source offset

# File lib/sass/source/position.rb, line 16
def initialize(line, offset)
  @line = line
  @offset = offset
end

Public Instance Methods

after(str) click to toggle source

@param str [String] The string to move through. @return [Position] The source position after proceeding forward through

`str`.
# File lib/sass/source/position.rb, line 29
def after(str)
  newlines = str.count("\n")
  Position.new(line + newlines,
    if newlines == 0
      offset + str.length
    else
      str.length - str.rindex("\n") - 1
    end)
end
inspect() click to toggle source

@return [String] A string representation of the source position.

# File lib/sass/source/position.rb, line 22
def inspect
  "#{line.inspect}:#{offset.inspect}"
end