class SourceMap::Offset

a source file.
Public: Offset is an immutable structure representing a position in

def self.new(*args)

Returns Offset instance.

Public: Construct Offset value.
def self.new(*args)
  case args.first
  when Offset
    args.first
  when Array
    super(*args.first)
  else
    super(*args)
  end
end

def +(other)

Returns a new Offset instance.

Or an Integer to add by line
other - An Offset to add by its line and column

Public: Shift the offset by some value.
def +(other)
  case other
  when Offset
    Offset.new(self.line + other.line, self.column + other.column)
  when Integer
    Offset.new(self.line + other, self.column)
  else
    raise ArgumentError, "can't convert #{other} into #{self.class}"
  end
end

def <=>(other)

when its greater. Implements the Comparable#<=> protocol.
Returns a negative number when other is smaller and a positive number

other - Another Offset

Useful for determining if a position in a few is between two offsets.

Public: Compare Offset to another.
def <=>(other)
  case other
  when Offset
    diff = self.line - other.line
    diff.zero? ? self.column - other.column : diff
  else
    raise ArgumentError, "can't convert #{other.class} into #{self.class}"
  end
end

def initialize(line, column)

column - Integer column number
line - Integer line number

Public: Initialize an Offset.
def initialize(line, column)
  @line, @column = line, column
end

def inspect

Returns a String.

Public: Get a pretty inspect output for debugging purposes.
def inspect
  "#<#{self.class} line=#{line}, column=#{column}>"
end

def to_s

Returns a String.

Public: Get a simple string representation of the offset
def to_s
  if column == 0
    "#{line}"
  else
    "#{line}:#{column}"
  end
end