Class: YARP::InterpolatedXStringNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::InterpolatedXStringNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents an xstring literal that contains interpolation.
`foo #{bar} baz`
^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location.
-
#parts ⇒ Object
readonly
attr_reader parts: Array.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#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) -> InterpolatedXStringNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening_loc, parts, closing_loc, location) ⇒ InterpolatedXStringNode
constructor
def initialize: (opening_loc: Location, parts: Array, closing_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#opening ⇒ Object
def opening: () -> String.
- #set_newline_flag(newline_marked) ⇒ Object
Constructor Details
#initialize(opening_loc, parts, closing_loc, location) ⇒ InterpolatedXStringNode
def initialize: (opening_loc: Location, parts: Array, closing_loc: Location, location: Location) -> void
6083 6084 6085 6086 6087 6088 |
# File 'lib/yarp/node.rb', line 6083 def initialize(opening_loc, parts, closing_loc, location) @opening_loc = opening_loc @parts = parts @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location
6080 6081 6082 |
# File 'lib/yarp/node.rb', line 6080 def closing_loc @closing_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
6074 6075 6076 |
# File 'lib/yarp/node.rb', line 6074 def opening_loc @opening_loc end |
#parts ⇒ Object (readonly)
attr_reader parts: Array
6077 6078 6079 |
# File 'lib/yarp/node.rb', line 6077 def parts @parts end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6091 6092 6093 |
# File 'lib/yarp/node.rb', line 6091 def accept(visitor) visitor.visit_interpolated_x_string_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6101 6102 6103 |
# File 'lib/yarp/node.rb', line 6101 def child_nodes [*parts] end |
#closing ⇒ Object
def closing: () -> String
6134 6135 6136 |
# File 'lib/yarp/node.rb', line 6134 def closing closing_loc.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6106 6107 6108 |
# File 'lib/yarp/node.rb', line 6106 def comment_targets [opening_loc, *parts, closing_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> InterpolatedXStringNode
6111 6112 6113 6114 6115 6116 6117 6118 |
# File 'lib/yarp/node.rb', line 6111 def copy(**params) InterpolatedXStringNode.new( params.fetch(:opening_loc) { opening_loc }, params.fetch(:parts) { parts }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
6124 6125 6126 |
# File 'lib/yarp/node.rb', line 6124 def deconstruct_keys(keys) { opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
6138 6139 6140 6141 6142 6143 6144 |
# File 'lib/yarp/node.rb', line 6138 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" inspector << "├── parts: #{inspector.list("#{inspector.prefix}│ ", parts)}" inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n" inspector.to_str end |
#opening ⇒ Object
def opening: () -> String
6129 6130 6131 |
# File 'lib/yarp/node.rb', line 6129 def opening opening_loc.slice end |
#set_newline_flag(newline_marked) ⇒ Object
6095 6096 6097 6098 |
# File 'lib/yarp/node.rb', line 6095 def set_newline_flag(newline_marked) first = parts.first first.set_newline_flag(newline_marked) if first end |