Class: YARP::ConstantAndWriteNode

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

Overview

Represents the use of the ‘&&=` operator for assignment to a constant.

Target &&= value
^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



1748
1749
1750
1751
1752
1753
# File 'lib/yarp/node.rb', line 1748

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

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location



1739
1740
1741
# File 'lib/yarp/node.rb', line 1739

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1742
1743
1744
# File 'lib/yarp/node.rb', line 1742

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



1745
1746
1747
# File 'lib/yarp/node.rb', line 1745

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1756
1757
1758
# File 'lib/yarp/node.rb', line 1756

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

#child_nodesObject Also known as: deconstruct

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



1761
1762
1763
# File 'lib/yarp/node.rb', line 1761

def child_nodes
  [value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> ConstantAndWriteNode



1766
1767
1768
1769
1770
1771
1772
1773
# File 'lib/yarp/node.rb', line 1766

def copy(**params)
  ConstantAndWriteNode.new(
    params.fetch(:name_loc) { name_loc },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:value) { value },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



1779
1780
1781
# File 'lib/yarp/node.rb', line 1779

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

#nameObject

def name: () -> String



1784
1785
1786
# File 'lib/yarp/node.rb', line 1784

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String



1789
1790
1791
# File 'lib/yarp/node.rb', line 1789

def operator
  operator_loc.slice
end