Class: YARD::Parser::Ruby::Legacy::RubyToken::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/parser/ruby/legacy/ruby_lex.rb

Overview

Represents a token in the Ruby lexer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_no, char_no) ⇒ Token

Creates a new Token object

Parameters:

  • line_no (Integer)

    the line number to initialize the token to

  • char_no (Integer)

    the char number to initialize the token to



37
38
39
40
41
# File 'lib/yard/parser/ruby/legacy/ruby_lex.rb', line 37

def initialize(line_no, char_no)
  @line_no = line_no
  @char_no = char_no
  @text    = NO_TEXT
end

Instance Attribute Details

#char_noInteger (readonly)

Returns the character number in the file/stream the token is located.

Returns:

  • (Integer)

    the character number in the file/stream the token is located.



23
24
25
# File 'lib/yard/parser/ruby/legacy/ruby_lex.rb', line 23

def char_no
  @char_no
end

#lex_stateSymbol

Returns the lexical state at the token.

Returns:

  • (Symbol)

    the lexical state at the token



29
30
31
# File 'lib/yard/parser/ruby/legacy/ruby_lex.rb', line 29

def lex_state
  @lex_state
end

#line_noInteger (readonly)

Returns the line number in the file/stream the token is located.

Returns:

  • (Integer)

    the line number in the file/stream the token is located.



19
20
21
# File 'lib/yard/parser/ruby/legacy/ruby_lex.rb', line 19

def line_no
  @line_no
end

#textString (readonly)

Returns the token text value.

Returns:

  • (String)

    the token text value



26
27
28
# File 'lib/yard/parser/ruby/legacy/ruby_lex.rb', line 26

def text
  @text
end

Instance Method Details

#set_text(text) ⇒ Token

Chainable way to sets the text attribute

Parameters:

  • text (String)

    the new text

Returns:

  • (Token)

    this token object



47
48
49
50
# File 'lib/yard/parser/ruby/legacy/ruby_lex.rb', line 47

def set_text(text)
  @text = text
  self
end