Class: GraphQL::Language::Token

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

Overview

Emitted by the lexer and passed to the parser. Contains type, value and position data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, name:, line:, col:, prev_token:) ⇒ Token

Returns a new instance of Token


9
10
11
12
13
14
15
# File 'lib/graphql/language/token.rb', line 9

def initialize(value:, name:, line:, col:, prev_token:)
  @name = name
  @value = value
  @line = line
  @col = col
  @prev_token = prev_token
end

Instance Attribute Details

#lineSymbol (readonly)

Returns The kind of token this is

Returns:

  • (Symbol)

    The kind of token this is


7
8
9
# File 'lib/graphql/language/token.rb', line 7

def line
  @line
end

#nameSymbol (readonly)

Returns The kind of token this is

Returns:

  • (Symbol)

    The kind of token this is


7
8
9
# File 'lib/graphql/language/token.rb', line 7

def name
  @name
end

#prev_tokenSymbol (readonly)

Returns The kind of token this is

Returns:

  • (Symbol)

    The kind of token this is


7
8
9
# File 'lib/graphql/language/token.rb', line 7

def prev_token
  @prev_token
end

Instance Method Details

#line_and_columnObject


21
22
23
# File 'lib/graphql/language/token.rb', line 21

def line_and_column
  [@line, @col]
end

#to_fObject


19
# File 'lib/graphql/language/token.rb', line 19

def to_f; @value.to_f; end

#to_iObject


18
# File 'lib/graphql/language/token.rb', line 18

def to_i; @value.to_i; end

#to_sObject


17
# File 'lib/graphql/language/token.rb', line 17

def to_s; @value; end