Class: Hocon::Impl::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/hocon/impl/token.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_type, origin, debug_string = nil) ⇒ Token

Returns a new instance of Token.



9
10
11
12
13
# File 'lib/hocon/impl/token.rb', line 9

def initialize(token_type, origin, debug_string = nil)
  @token_type = token_type
  @origin = origin
  @debug_string = debug_string
end

Instance Attribute Details

#originObject (readonly)

Returns the value of attribute origin.



15
16
17
# File 'lib/hocon/impl/token.rb', line 15

def origin
  @origin
end

Class Method Details

.new_without_origin(token_type, debug_string) ⇒ Object



5
6
7
# File 'lib/hocon/impl/token.rb', line 5

def self.new_without_origin(token_type, debug_string)
  Hocon::Impl::Token.new(token_type, nil, debug_string)
end

Instance Method Details

#line_numberObject



17
18
19
20
21
22
23
# File 'lib/hocon/impl/token.rb', line 17

def line_number
  if @origin
    @origin.line_number
  else
    -1
  end
end

#to_sObject



25
26
27
28
29
30
31
# File 'lib/hocon/impl/token.rb', line 25

def to_s
  if !@debug_string.nil?
    @debug_string
  else
    Hocon::Impl::TokenType.name(@token_type)
  end
end