Class: YARP::GlobalVariableWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::GlobalVariableWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents writing to a global variable.
$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) -> GlobalVariableWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, value, operator_loc, location) ⇒ GlobalVariableWriteNode
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) ⇒ GlobalVariableWriteNode
def initialize: (name: Symbol, name_loc: Location, value: Node, operator_loc: Location, location: Location) -> void
4856 4857 4858 4859 4860 4861 4862 |
# File 'lib/yarp/node.rb', line 4856 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
4844 4845 4846 |
# File 'lib/yarp/node.rb', line 4844 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
4847 4848 4849 |
# File 'lib/yarp/node.rb', line 4847 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
4853 4854 4855 |
# File 'lib/yarp/node.rb', line 4853 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
4850 4851 4852 |
# File 'lib/yarp/node.rb', line 4850 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
4865 4866 4867 |
# File 'lib/yarp/node.rb', line 4865 def accept(visitor) visitor.visit_global_variable_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4870 4871 4872 |
# File 'lib/yarp/node.rb', line 4870 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
4875 4876 4877 |
# File 'lib/yarp/node.rb', line 4875 def comment_targets [name_loc, value, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> GlobalVariableWriteNode
4880 4881 4882 4883 4884 4885 4886 4887 4888 |
# File 'lib/yarp/node.rb', line 4880 def copy(**params) GlobalVariableWriteNode.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
4894 4895 4896 |
# File 'lib/yarp/node.rb', line 4894 def deconstruct_keys(keys) { name: name, name_loc: name_loc, value: value, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
4903 4904 4905 4906 4907 4908 4909 4910 4911 |
# File 'lib/yarp/node.rb', line 4903 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
4899 4900 4901 |
# File 'lib/yarp/node.rb', line 4899 def operator operator_loc.slice end |