Class: YARP::ConstantWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ConstantWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents writing to a constant.
Foo = 1
^^^^^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol.
-
#name_loc ⇒ Object
readonly
attr_reader name_loc: Location.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#value ⇒ Object
readonly
attr_reader value: Node.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, value, operator_loc, location) ⇒ ConstantWriteNode
constructor
def initialize: (name: Symbol, name_loc: Location, value: Node, operator_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name, name_loc, value, operator_loc, location) ⇒ ConstantWriteNode
def initialize: (name: Symbol, name_loc: Location, value: Node, operator_loc: Location, location: Location) -> void
3338 3339 3340 3341 3342 3343 3344 |
# File 'lib/yarp/node.rb', line 3338 def initialize(name, name_loc, value, operator_loc, location) @name = name @name_loc = name_loc @value = value @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol
3326 3327 3328 |
# File 'lib/yarp/node.rb', line 3326 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
3329 3330 3331 |
# File 'lib/yarp/node.rb', line 3329 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
3335 3336 3337 |
# File 'lib/yarp/node.rb', line 3335 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
3332 3333 3334 |
# File 'lib/yarp/node.rb', line 3332 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
3347 3348 3349 |
# File 'lib/yarp/node.rb', line 3347 def accept(visitor) visitor.visit_constant_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3352 3353 3354 |
# File 'lib/yarp/node.rb', line 3352 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
3357 3358 3359 |
# File 'lib/yarp/node.rb', line 3357 def comment_targets [name_loc, value, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantWriteNode
3362 3363 3364 3365 3366 3367 3368 3369 3370 |
# File 'lib/yarp/node.rb', line 3362 def copy(**params) ConstantWriteNode.new( params.fetch(:name) { name }, params.fetch(:name_loc) { name_loc }, params.fetch(:value) { value }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
3376 3377 3378 |
# File 'lib/yarp/node.rb', line 3376 def deconstruct_keys(keys) { name: name, name_loc: name_loc, value: value, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
3385 3386 3387 3388 3389 3390 3391 3392 3393 |
# File 'lib/yarp/node.rb', line 3385 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── name: #{name.inspect}\n" inspector << "├── name_loc: #{inspector.location(name_loc)}\n" inspector << "├── value:\n" inspector << inspector.child_node(value, "│ ") inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n" inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
3381 3382 3383 |
# File 'lib/yarp/node.rb', line 3381 def operator operator_loc.slice end |