class AdLint::Token

DESCRIPTION

Token.

Attributes

location[R]

VALUE

LocationLocation of this token.

type[R]

VALUE

Symbol | String – Type of this token.

type_hint[R]

VALUE

Symbol | String – Hint of the type of this token.

value[R]

VALUE

String – Value of this token.

Public Class Methods

new(type, val, loc, type_hint = nil) click to toggle source

DESCRIPTION

Constructs a token.

PARAMETER

type

Symbol | String – Type of the token.

val

StringString value of the token.

loc

LocationLocation of the token.

type_hint

Symbol | String – Hint of the token type.

# File lib/adlint/token.rb, line 50
def initialize(type, val, loc, type_hint = nil)
  @type, @value, @location = type, val, loc
  @type_hint = type_hint
end

Public Instance Methods

<=>(rhs) click to toggle source

DESCRIPTION

Compares tokens.

PARAMETER

rhs

Token – Right-hand-side token.

RETURN VALUE

Integer – Comparision result.

# File lib/adlint/token.rb, line 87
def <=>(rhs)
  case rhs
  when Symbol, String
    @type <=> rhs
  when Token
    if (type_diff = @type <=> rhs.type) == 0
      if (val_diff = @value <=> rhs.value) == 0
        @location <=> rhs.location
      else
        val_diff
      end
    else
      type_diff
    end
  else
    raise TypeError
  end
end
eql?(rhs_tok) click to toggle source
# File lib/adlint/token.rb, line 106
def eql?(rhs_tok)
  @type == rhs_tok.type && @value == rhs_tok.value &&
    @location == rhs_tok.location
end
hash() click to toggle source
# File lib/adlint/token.rb, line 111
def hash
  [@type, @value, @location].hash
end
need_no_further_replacement?() click to toggle source
# File lib/adlint/token.rb, line 75
def need_no_further_replacement?
  false
end
replaced?() click to toggle source
# File lib/adlint/token.rb, line 71
def replaced?
  false
end