Class: Prism::EmbeddedVariableNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::EmbeddedVariableNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents an interpolated variable.
"foo #@bar"
^^^^^
Instance Attribute Summary collapse
-
#variable ⇒ Object
readonly
attr_reader variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#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].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, variable: self.variable) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) -> EmbeddedVariableNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, operator_loc: Location, variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode }.
-
#initialize(source, node_id, location, flags, operator_loc, variable) ⇒ EmbeddedVariableNode
constructor
Initialize a new EmbeddedVariableNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, operator_loc, variable) ⇒ EmbeddedVariableNode
Initialize a new EmbeddedVariableNode node.
5699 5700 5701 5702 5703 5704 5705 5706 |
# File 'lib/prism/node.rb', line 5699 def initialize(source, node_id, location, flags, operator_loc, variable) @source = source @node_id = node_id @location = location @flags = flags @operator_loc = operator_loc @variable = variable end |
Instance Attribute Details
#variable ⇒ Object (readonly)
attr_reader variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode
5749 5750 5751 |
# File 'lib/prism/node.rb', line 5749 def variable @variable end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
5767 5768 5769 |
# File 'lib/prism/node.rb', line 5767 def self.type :embedded_variable_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
5773 5774 5775 5776 5777 |
# File 'lib/prism/node.rb', line 5773 def ===(other) other.is_a?(EmbeddedVariableNode) && (operator_loc.nil? == other.operator_loc.nil?) && (variable === other.variable) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
5709 5710 5711 |
# File 'lib/prism/node.rb', line 5709 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5714 5715 5716 |
# File 'lib/prism/node.rb', line 5714 def child_nodes [variable] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
5724 5725 5726 |
# File 'lib/prism/node.rb', line 5724 def comment_targets [operator_loc, variable] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
5719 5720 5721 |
# File 'lib/prism/node.rb', line 5719 def compact_child_nodes [variable] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, variable: self.variable) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) -> EmbeddedVariableNode
5729 5730 5731 |
# File 'lib/prism/node.rb', line 5729 def copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, variable: self.variable) EmbeddedVariableNode.new(source, node_id, location, flags, operator_loc, variable) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, operator_loc: Location, variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode }
5737 5738 5739 |
# File 'lib/prism/node.rb', line 5737 def deconstruct_keys(keys) { node_id: node_id, location: location, operator_loc: operator_loc, variable: variable } end |
#inspect ⇒ Object
def inspect -> String
5757 5758 5759 |
# File 'lib/prism/node.rb', line 5757 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
5752 5753 5754 |
# File 'lib/prism/node.rb', line 5752 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
5742 5743 5744 5745 5746 |
# File 'lib/prism/node.rb', line 5742 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
5762 5763 5764 |
# File 'lib/prism/node.rb', line 5762 def type :embedded_variable_node end |