123456789_123456789_123456789_123456789_123456789_

Class: Prism::LexCompat::Token

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, SimpleDelegator
Instance Chain:
self, SimpleDelegator
Inherits: SimpleDelegator
  • ::Object
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

  • #event

    The type of the token.

  • #location

    The location of the token in the source.

  • #state

    The state of the lexer when this token was produced.

  • #value

    The slice of the source that this token represents.

Instance Method Details

#event

The type of the token.

[ GitHub ]

  
# File 'lib/prism/lex_compat.rb', line 193

def event
  self[1]
end

#location

The location of the token in the source.

[ GitHub ]

  
# File 'lib/prism/lex_compat.rb', line 188

def location
  self[0]
end

#state

The state of the lexer when this token was produced.

[ GitHub ]

  
# File 'lib/prism/lex_compat.rb', line 203

def state
  self[3]
end

#value

The slice of the source that this token represents.

[ GitHub ]

  
# File 'lib/prism/lex_compat.rb', line 198

def value
  self[2]
end