Class: YARP::InterpolatedStringNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::InterpolatedStringNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a string 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) -> InterpolatedStringNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening_loc, parts, closing_loc, location) ⇒ InterpolatedStringNode
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) ⇒ InterpolatedStringNode
def initialize: (opening_loc: Location?, parts: Array, closing_loc: Location?, location: Location) -> void
5925 5926 5927 5928 5929 5930 |
# File 'lib/yarp/node.rb', line 5925 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?
5922 5923 5924 |
# File 'lib/yarp/node.rb', line 5922 def closing_loc @closing_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
5916 5917 5918 |
# File 'lib/yarp/node.rb', line 5916 def opening_loc @opening_loc end |
#parts ⇒ Object (readonly)
attr_reader parts: Array
5919 5920 5921 |
# File 'lib/yarp/node.rb', line 5919 def parts @parts end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
5933 5934 5935 |
# File 'lib/yarp/node.rb', line 5933 def accept(visitor) visitor.visit_interpolated_string_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5943 5944 5945 |
# File 'lib/yarp/node.rb', line 5943 def child_nodes [*parts] end |
#closing ⇒ Object
def closing: () -> String?
5976 5977 5978 |
# File 'lib/yarp/node.rb', line 5976 def closing closing_loc&.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
5948 5949 5950 |
# File 'lib/yarp/node.rb', line 5948 def comment_targets [*opening_loc, *parts, *closing_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> InterpolatedStringNode
5953 5954 5955 5956 5957 5958 5959 5960 |
# File 'lib/yarp/node.rb', line 5953 def copy(**params) InterpolatedStringNode.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
5966 5967 5968 |
# File 'lib/yarp/node.rb', line 5966 def deconstruct_keys(keys) { opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
5980 5981 5982 5983 5984 5985 5986 |
# File 'lib/yarp/node.rb', line 5980 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?
5971 5972 5973 |
# File 'lib/yarp/node.rb', line 5971 def opening opening_loc&.slice end |
#set_newline_flag(newline_marked) ⇒ Object
5937 5938 5939 5940 |
# File 'lib/yarp/node.rb', line 5937 def set_newline_flag(newline_marked) first = parts.first first.set_newline_flag(newline_marked) if first end |