Class: YARP::LocalVariableWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::LocalVariableWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents writing to a local variable.
foo = 1
^^^^^^^
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
attr_reader depth: Integer.
-
#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) -> LocalVariableWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, depth, name_loc, value, operator_loc, location) ⇒ LocalVariableWriteNode
constructor
def initialize: (name: Symbol, depth: Integer, 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, depth, name_loc, value, operator_loc, location) ⇒ LocalVariableWriteNode
def initialize: (name: Symbol, depth: Integer, name_loc: Location, value: Node, operator_loc: Location, location: Location) -> void
6836 6837 6838 6839 6840 6841 6842 6843 |
# File 'lib/yarp/node.rb', line 6836 def initialize(name, depth, name_loc, value, operator_loc, location) @name = name @depth = depth @name_loc = name_loc @value = value @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#depth ⇒ Object (readonly)
attr_reader depth: Integer
6824 6825 6826 |
# File 'lib/yarp/node.rb', line 6824 def depth @depth end |
#name ⇒ Object (readonly)
attr_reader name: Symbol
6821 6822 6823 |
# File 'lib/yarp/node.rb', line 6821 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
6827 6828 6829 |
# File 'lib/yarp/node.rb', line 6827 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
6833 6834 6835 |
# File 'lib/yarp/node.rb', line 6833 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
6830 6831 6832 |
# File 'lib/yarp/node.rb', line 6830 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6846 6847 6848 |
# File 'lib/yarp/node.rb', line 6846 def accept(visitor) visitor.visit_local_variable_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6851 6852 6853 |
# File 'lib/yarp/node.rb', line 6851 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6856 6857 6858 |
# File 'lib/yarp/node.rb', line 6856 def comment_targets [name_loc, value, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> LocalVariableWriteNode
6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 |
# File 'lib/yarp/node.rb', line 6861 def copy(**params) LocalVariableWriteNode.new( params.fetch(:name) { name }, params.fetch(:depth) { depth }, 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
6876 6877 6878 |
# File 'lib/yarp/node.rb', line 6876 def deconstruct_keys(keys) { name: name, depth: depth, name_loc: name_loc, value: value, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 |
# File 'lib/yarp/node.rb', line 6885 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── name: #{name.inspect}\n" inspector << "├── depth: #{depth.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
6881 6882 6883 |
# File 'lib/yarp/node.rb', line 6881 def operator operator_loc.slice end |