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(name, value, line, col, prev_token) ⇒ Token


17
18
19
20
21
22
23
# File 'lib/graphql/language/token.rb', line 17

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

Instance Attribute Details

#colObject (readonly)

Returns the value of attribute col


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

def col
  @col
end

#lineObject (readonly)

Returns the value of attribute line


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

def line
  @line
end

#nameSymbol (readonly)


12
13
14
# File 'lib/graphql/language/token.rb', line 12

def name
  @name
end

#prev_tokenObject (readonly)

Returns the value of attribute prev_token


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

def prev_token
  @prev_token
end

#valueString (readonly) Also known as: to_s


14
15
16
# File 'lib/graphql/language/token.rb', line 14

def value
  @value
end

Instance Method Details

#inspectObject


33
34
35
# File 'lib/graphql/language/token.rb', line 33

def inspect
  "(#{@name} #{@value.inspect} [#{@line}:#{@col}])"
end

#line_and_columnObject


29
30
31
# File 'lib/graphql/language/token.rb', line 29

def line_and_column
  [@line, @col]
end

#to_fObject


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

def to_f; @value.to_f; end

#to_iObject


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

def to_i; @value.to_i; end