Class: Prism::LexCompat::Token

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/prism/lex_compat.rb

Overview

When we produce tokens, we produce the same arrays that Ripper does. However, we add a couple of convenience methods onto them to make them a little easier to work with. We delegate all other methods to the array.

Instance Method Summary collapse

Instance Method Details

#eventObject

The type of the token.



214
215
216
# File 'lib/prism/lex_compat.rb', line 214

def event
  self[1]
end

#locationObject

The location of the token in the source.



209
210
211
# File 'lib/prism/lex_compat.rb', line 209

def location
  self[0]
end

#stateObject

The state of the lexer when this token was produced.



224
225
226
# File 'lib/prism/lex_compat.rb', line 224

def state
  self[3]
end

#valueObject

The slice of the source that this token represents.



219
220
221
# File 'lib/prism/lex_compat.rb', line 219

def value
  self[2]
end