Class: JSON5::Token

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind, value, start_byte, end_byte, line, column, raw = nil, leading_trivia = [], source: nil) ⇒ Token

Returns a new instance of Token.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/json5/token.rb', line 7

def initialize(kind, value, start_byte, end_byte, line, column, raw = nil, leading_trivia = [], source: nil)
  @kind = kind
  @value = value
  @start_byte = start_byte
  @end_byte = end_byte
  @line = line
  @column = column
  @raw = raw&.freeze
  @source = source
  @leading_trivia = leading_trivia
  freeze
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



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

def column
  @column
end

#end_byteObject (readonly)

Returns the value of attribute end_byte.



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

def end_byte
  @end_byte
end

#kindObject (readonly)

Returns the value of attribute kind.



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

def kind
  @kind
end

#leading_triviaObject (readonly)

Returns the value of attribute leading_trivia.



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

def leading_trivia
  @leading_trivia
end

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

#start_byteObject (readonly)

Returns the value of attribute start_byte.



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

def start_byte
  @start_byte
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#rawObject



20
21
22
# File 'lib/json5/token.rb', line 20

def raw
  @raw || @source&.byteslice(start_byte...end_byte)
end