This represents a token from the Ruby source.
Methods
- #
-
- D
-
- N
-
- P
-
Attributes
[R]
|
location |
A Location object representing the location of this token in the source. |
[R]
|
type |
The type of token that this token is. |
[R]
|
value |
A byteslice of the source that this token represents. |
Class Public methods
new(type, value, location)
Link
Create a new token object with the given type, value, and location.
Source:
show
| on GitHub
def initialize(type, value, location)
@type = type
@value = value
@location = location
end
Instance Public methods
==(other)
Link
Returns true if the given other token is equal to this token.
Source:
show
| on GitHub
def ==(other)
other.is_a?(Token) &&
other.type == type &&
other.value == value
end
deconstruct_keys(keys)
Link
Implement the hash pattern matching interface for Token
.
Source:
show
| on GitHub
def deconstruct_keys(keys)
{ type: type, value: value, location: location }
end
pretty_print(q)
Link
Implement the pretty print interface for Token
.
Source:
show
| on GitHub
def pretty_print(q)
q.group do
q.text(type.to_s)
self.location.pretty_print(q)
q.text("(")
q.nest(2) do
q.breakable("")
q.pp(value)
end
q.breakable("")
q.text(")")
end
end