Class: YARP::CallOrWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::CallOrWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘||=` operator on a call.
foo. ||= value
^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
attr_reader arguments: ArgumentsNode?.
-
#call_operator_loc ⇒ Object
readonly
attr_reader call_operator_loc: Location?.
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location?.
-
#flags ⇒ Object
readonly
attr_reader flags: Integer.
-
#message_loc ⇒ Object
readonly
attr_reader message_loc: Location?.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location?.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#read_name ⇒ Object
readonly
attr_reader read_name: String.
-
#receiver ⇒ Object
readonly
attr_reader receiver: Node?.
-
#value ⇒ Object
readonly
attr_reader value: Node.
-
#write_name ⇒ Object
readonly
attr_reader write_name: String.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#call_operator ⇒ Object
def call_operator: () -> String?.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String?.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> CallOrWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(receiver, call_operator_loc, message_loc, opening_loc, arguments, closing_loc, flags, read_name, write_name, operator_loc, value, location) ⇒ CallOrWriteNode
constructor
def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, flags: Integer, read_name: String, write_name: String, operator_loc: Location, value: Node, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#message ⇒ Object
def message: () -> String?.
-
#opening ⇒ Object
def opening: () -> String?.
-
#operator ⇒ Object
def operator: () -> String.
-
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool.
-
#variable_call? ⇒ Boolean
def variable_call?: () -> bool.
Constructor Details
#initialize(receiver, call_operator_loc, message_loc, opening_loc, arguments, closing_loc, flags, read_name, write_name, operator_loc, value, location) ⇒ CallOrWriteNode
def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, flags: Integer, read_name: String, write_name: String, operator_loc: Location, value: Node, location: Location) -> void
1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 |
# File 'lib/yarp/node.rb', line 1729 def initialize(receiver, call_operator_loc, , opening_loc, arguments, closing_loc, flags, read_name, write_name, operator_loc, value, location) @receiver = receiver @call_operator_loc = call_operator_loc = @opening_loc = opening_loc @arguments = arguments @closing_loc = closing_loc @flags = flags @read_name = read_name @write_name = write_name @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
1708 1709 1710 |
# File 'lib/yarp/node.rb', line 1708 def arguments @arguments end |
#call_operator_loc ⇒ Object (readonly)
attr_reader call_operator_loc: Location?
1699 1700 1701 |
# File 'lib/yarp/node.rb', line 1699 def call_operator_loc @call_operator_loc end |
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location?
1711 1712 1713 |
# File 'lib/yarp/node.rb', line 1711 def closing_loc @closing_loc end |
#flags ⇒ Object (readonly)
attr_reader flags: Integer
1714 1715 1716 |
# File 'lib/yarp/node.rb', line 1714 def flags @flags end |
#message_loc ⇒ Object (readonly)
attr_reader message_loc: Location?
1702 1703 1704 |
# File 'lib/yarp/node.rb', line 1702 def end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
1705 1706 1707 |
# File 'lib/yarp/node.rb', line 1705 def opening_loc @opening_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
1723 1724 1725 |
# File 'lib/yarp/node.rb', line 1723 def operator_loc @operator_loc end |
#read_name ⇒ Object (readonly)
attr_reader read_name: String
1717 1718 1719 |
# File 'lib/yarp/node.rb', line 1717 def read_name @read_name end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Node?
1696 1697 1698 |
# File 'lib/yarp/node.rb', line 1696 def receiver @receiver end |
#value ⇒ Object (readonly)
attr_reader value: Node
1726 1727 1728 |
# File 'lib/yarp/node.rb', line 1726 def value @value end |
#write_name ⇒ Object (readonly)
attr_reader write_name: String
1720 1721 1722 |
# File 'lib/yarp/node.rb', line 1720 def write_name @write_name end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1745 1746 1747 |
# File 'lib/yarp/node.rb', line 1745 def accept(visitor) visitor.visit_call_or_write_node(self) end |
#call_operator ⇒ Object
def call_operator: () -> String?
1786 1787 1788 |
# File 'lib/yarp/node.rb', line 1786 def call_operator call_operator_loc&.slice end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1750 1751 1752 |
# File 'lib/yarp/node.rb', line 1750 def child_nodes [receiver, arguments, value] end |
#closing ⇒ Object
def closing: () -> String?
1801 1802 1803 |
# File 'lib/yarp/node.rb', line 1801 def closing closing_loc&.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1755 1756 1757 |
# File 'lib/yarp/node.rb', line 1755 def comment_targets [*receiver, *call_operator_loc, *, *opening_loc, *arguments, *closing_loc, operator_loc, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> CallOrWriteNode
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 |
# File 'lib/yarp/node.rb', line 1760 def copy(**params) CallOrWriteNode.new( params.fetch(:receiver) { receiver }, params.fetch(:call_operator_loc) { call_operator_loc }, params.fetch(:message_loc) { }, params.fetch(:opening_loc) { opening_loc }, params.fetch(:arguments) { arguments }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:flags) { flags }, params.fetch(:read_name) { read_name }, params.fetch(:write_name) { write_name }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
1781 1782 1783 |
# File 'lib/yarp/node.rb', line 1781 def deconstruct_keys(keys) { receiver: receiver, call_operator_loc: call_operator_loc, message_loc: , opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, flags: flags, read_name: read_name, write_name: write_name, operator_loc: operator_loc, value: value, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 |
# File 'lib/yarp/node.rb', line 1820 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) if (receiver = self.receiver).nil? inspector << "├── receiver: ∅\n" else inspector << "├── receiver:\n" inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n" inspector << "├── message_loc: #{inspector.location(message_loc)}\n" inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" if (arguments = self.arguments).nil? inspector << "├── arguments: ∅\n" else inspector << "├── arguments:\n" inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n" inspector << "├── flags: #{[("safe_navigation" if safe_navigation?), ("variable_call" if variable_call?)].compact.join(", ")}\n" inspector << "├── read_name: #{read_name.inspect}\n" inspector << "├── write_name: #{write_name.inspect}\n" inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n" inspector << "└── value:\n" inspector << inspector.child_node(value, " ") inspector.to_str end |
#message ⇒ Object
def message: () -> String?
1791 1792 1793 |
# File 'lib/yarp/node.rb', line 1791 def &.slice end |
#opening ⇒ Object
def opening: () -> String?
1796 1797 1798 |
# File 'lib/yarp/node.rb', line 1796 def opening opening_loc&.slice end |
#operator ⇒ Object
def operator: () -> String
1816 1817 1818 |
# File 'lib/yarp/node.rb', line 1816 def operator operator_loc.slice end |
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool
1806 1807 1808 |
# File 'lib/yarp/node.rb', line 1806 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
1811 1812 1813 |
# File 'lib/yarp/node.rb', line 1811 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |