class SCSSLint::Location

Stores a location of {Lint} in a source.

Attributes

column[R]
length[R]
line[R]

Public Class Methods

new(line = 1, column = 1, length = 1) click to toggle source

@param line [Integer] One-based index @param column [Integer] One-based index @param length [Integer] Number of characters, including the first character

# File lib/scss_lint/location.rb, line 11
def initialize(line = 1, column = 1, length = 1)
  raise ArgumentError, "Line must be more than 0, passed #{line}" if line < 1
  raise ArgumentError, "Column must be more than 0, passed #{column}" if column < 1
  raise ArgumentError, "Length must be more than 0, passed #{length}" if length < 1

  @line   = line
  @column = column
  @length = length
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/scss_lint/location.rb, line 29
def <=>(other)
  [:line, :column, :length].each do |attr|
    result = send(attr) <=> other.send(attr)
    return result unless result == 0
  end

  0
end
==(other) click to toggle source
# File lib/scss_lint/location.rb, line 21
def ==(other)
  [:line, :column, :length].all? do |attr|
    send(attr) == other.send(attr)
  end
end
Also aliased as: eql?
eql?(other)
Alias for: ==