Class: GraphQL::Language::Token
- Inherits:
-
Object
- Object
- GraphQL::Language::Token
- 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
-
#col ⇒ Object
readonly
Returns the value of attribute col.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#name ⇒ Symbol
readonly
The kind of token this is.
-
#prev_token ⇒ Object
readonly
Returns the value of attribute prev_token.
-
#value ⇒ String
(also: #to_s)
readonly
The text of this token.
Instance Method Summary collapse
-
#initialize(value:, name:, line:, col:, prev_token:) ⇒ Token
constructor
A new instance of Token.
-
#inspect ⇒ Object
-
#line_and_column ⇒ Object
-
#to_f ⇒ Object
-
#to_i ⇒ Object
Constructor Details
#initialize(value:, name:, line:, col:, prev_token:) ⇒ Token
Returns a new instance of Token
13 14 15 16 17 18 19 |
# File 'lib/graphql/language/token.rb', line 13 def initialize(value:, name:, line:, col:, prev_token:) @name = name @value = value.freeze @line = line @col = col @prev_token = prev_token end |
Instance Attribute Details
#col ⇒ Object (readonly)
Returns the value of attribute col
11 12 13 |
# File 'lib/graphql/language/token.rb', line 11 def col @col end |
#line ⇒ Object (readonly)
Returns the value of attribute line
11 12 13 |
# File 'lib/graphql/language/token.rb', line 11 def line @line end |
#name ⇒ Symbol (readonly)
Returns The kind of token this is
8 9 10 |
# File 'lib/graphql/language/token.rb', line 8 def name @name end |
#prev_token ⇒ Object (readonly)
Returns the value of attribute prev_token
11 12 13 |
# File 'lib/graphql/language/token.rb', line 11 def prev_token @prev_token end |
#value ⇒ String (readonly) Also known as: to_s
Returns The text of this token
10 11 12 |
# File 'lib/graphql/language/token.rb', line 10 def value @value end |
Instance Method Details
#inspect ⇒ Object
29 30 31 |
# File 'lib/graphql/language/token.rb', line 29 def inspect "(#{@name} #{@value.inspect} [#{@line}:#{@col}])" end |
#line_and_column ⇒ Object
25 26 27 |
# File 'lib/graphql/language/token.rb', line 25 def line_and_column [@line, @col] end |
#to_f ⇒ Object
23 |
# File 'lib/graphql/language/token.rb', line 23 def to_f; @value.to_f; end |
#to_i ⇒ Object
22 |
# File 'lib/graphql/language/token.rb', line 22 def to_i; @value.to_i; end |