Class: YARP::Token
- Inherits:
-
Object
- Object
- YARP::Token
- Defined in:
- lib/yarp.rb,
ext/yarp/extension.c
Overview
This represents a token from the Ruby source.
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(type, value, location) ⇒ Token
constructor
A new instance of Token.
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(type, value, location) ⇒ Token
Returns a new instance of Token.
257 258 259 260 261 |
# File 'lib/yarp.rb', line 257 def initialize(type, value, location) @type = type @value = value @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
255 256 257 |
# File 'lib/yarp.rb', line 255 def location @location end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
255 256 257 |
# File 'lib/yarp.rb', line 255 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
255 256 257 |
# File 'lib/yarp.rb', line 255 def value @value end |
Instance Method Details
#==(other) ⇒ Object
281 282 283 284 285 |
# File 'lib/yarp.rb', line 281 def ==(other) other.is_a?(Token) && other.type == type && other.value == value end |
#deconstruct_keys(keys) ⇒ Object
263 264 265 |
# File 'lib/yarp.rb', line 263 def deconstruct_keys(keys) { type: type, value: value, location: location } end |
#pretty_print(q) ⇒ Object
267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/yarp.rb', line 267 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 |