Class: FAM::Syntax::TokenObject

Inherits:
Object
  • Object
show all
Defined in:
lib/fam/syntax/tokens.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name, location) ⇒ TokenObject

Returns a new instance of TokenObject.



51
52
53
54
55
56
# File 'lib/fam/syntax/tokens.rb', line 51

def initialize type, name, location
  @type = type
  @name = name
  @line = location[:line]
  @col  = location[:col]
end

Instance Attribute Details

#colObject (readonly)

Returns the value of attribute col.



49
50
51
# File 'lib/fam/syntax/tokens.rb', line 49

def col
  @col
end

#lineObject (readonly)

Returns the value of attribute line.



49
50
51
# File 'lib/fam/syntax/tokens.rb', line 49

def line
  @line
end

#nameObject (readonly)

Returns the value of attribute name.



49
50
51
# File 'lib/fam/syntax/tokens.rb', line 49

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



49
50
51
# File 'lib/fam/syntax/tokens.rb', line 49

def type
  @type
end

Instance Method Details

#to_sObject Also known as: pretty_inspect



58
59
60
61
# File 'lib/fam/syntax/tokens.rb', line 58

def to_s
  value = @name == "\n" ? '\n' : @name
  "TOKEN<:#{@type}>(`#{value}`)"
end