Class: YARP::InterpolatedSymbolNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::InterpolatedSymbolNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a symbol 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) -> InterpolatedSymbolNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening_loc, parts, closing_loc, location) ⇒ InterpolatedSymbolNode
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) ⇒ InterpolatedSymbolNode
def initialize: (opening_loc: Location?, parts: Array, closing_loc: Location?, location: Location) -> void
6004 6005 6006 6007 6008 6009 |
# File 'lib/yarp/node.rb', line 6004 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?
6001 6002 6003 |
# File 'lib/yarp/node.rb', line 6001 def closing_loc @closing_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
5995 5996 5997 |
# File 'lib/yarp/node.rb', line 5995 def opening_loc @opening_loc end |
#parts ⇒ Object (readonly)
attr_reader parts: Array
5998 5999 6000 |
# File 'lib/yarp/node.rb', line 5998 def parts @parts end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6012 6013 6014 |
# File 'lib/yarp/node.rb', line 6012 def accept(visitor) visitor.visit_interpolated_symbol_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6022 6023 6024 |
# File 'lib/yarp/node.rb', line 6022 def child_nodes [*parts] end |
#closing ⇒ Object
def closing: () -> String?
6055 6056 6057 |
# File 'lib/yarp/node.rb', line 6055 def closing closing_loc&.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6027 6028 6029 |
# File 'lib/yarp/node.rb', line 6027 def comment_targets [*opening_loc, *parts, *closing_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> InterpolatedSymbolNode
6032 6033 6034 6035 6036 6037 6038 6039 |
# File 'lib/yarp/node.rb', line 6032 def copy(**params) InterpolatedSymbolNode.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
6045 6046 6047 |
# File 'lib/yarp/node.rb', line 6045 def deconstruct_keys(keys) { opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
6059 6060 6061 6062 6063 6064 6065 |
# File 'lib/yarp/node.rb', line 6059 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?
6050 6051 6052 |
# File 'lib/yarp/node.rb', line 6050 def opening opening_loc&.slice end |
#set_newline_flag(newline_marked) ⇒ Object
6016 6017 6018 6019 |
# File 'lib/yarp/node.rb', line 6016 def set_newline_flag(newline_marked) first = parts.first first.set_newline_flag(newline_marked) if first end |