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.
-
#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.
-
#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
4510 4511 4512 4513 4514 4515 |
# File 'lib/yarp/node.rb', line 4510 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
4507 4508 4509 |
# File 'lib/yarp/node.rb', line 4507 def closing_loc @closing_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
4501 4502 4503 |
# File 'lib/yarp/node.rb', line 4501 def opening_loc @opening_loc end |
#parts ⇒ Object (readonly)
attr_reader parts: Array
4504 4505 4506 |
# File 'lib/yarp/node.rb', line 4504 def parts @parts end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
4518 4519 4520 |
# File 'lib/yarp/node.rb', line 4518 def accept(visitor) visitor.visit_interpolated_x_string_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4528 4529 4530 |
# File 'lib/yarp/node.rb', line 4528 def child_nodes [*parts] end |
#closing ⇒ Object
def closing: () -> String
4556 4557 4558 |
# File 'lib/yarp/node.rb', line 4556 def closing closing_loc.slice end |
#copy(**params) ⇒ Object
def copy: (**params) -> InterpolatedXStringNode
4533 4534 4535 4536 4537 4538 4539 4540 |
# File 'lib/yarp/node.rb', line 4533 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
4546 4547 4548 |
# File 'lib/yarp/node.rb', line 4546 def deconstruct_keys(keys) { opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String
4551 4552 4553 |
# File 'lib/yarp/node.rb', line 4551 def opening opening_loc.slice end |
#set_newline_flag(newline_marked) ⇒ Object
4522 4523 4524 4525 |
# File 'lib/yarp/node.rb', line 4522 def set_newline_flag(newline_marked) first = parts.first first.set_newline_flag(newline_marked) if first end |