Class: YARP::ConstantWriteNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents writing to a constant.

Foo = 1
^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, value, operator_loc, location) ⇒ ConstantWriteNode

def initialize: (name_loc: Location, value: Node?, operator_loc: Location?, location: Location) -> void



1837
1838
1839
1840
1841
1842
# File 'lib/yarp/node.rb', line 1837

def initialize(name_loc, value, operator_loc, location)
  @name_loc = name_loc
  @value = value
  @operator_loc = operator_loc
  @location = location
end

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location



1828
1829
1830
# File 'lib/yarp/node.rb', line 1828

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



1834
1835
1836
# File 'lib/yarp/node.rb', line 1834

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node?



1831
1832
1833
# File 'lib/yarp/node.rb', line 1831

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1845
1846
1847
# File 'lib/yarp/node.rb', line 1845

def accept(visitor)
  visitor.visit_constant_write_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



1850
1851
1852
# File 'lib/yarp/node.rb', line 1850

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



1858
1859
1860
# File 'lib/yarp/node.rb', line 1858

def deconstruct_keys(keys)
  { name_loc: name_loc, value: value, operator_loc: operator_loc, location: location }
end

#nameObject

def name: () -> String



1863
1864
1865
# File 'lib/yarp/node.rb', line 1863

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String?



1868
1869
1870
# File 'lib/yarp/node.rb', line 1868

def operator
  operator_loc&.slice
end