Class: YARP::InterpolatedSymbolNode

Inherits:
YARPNode
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(opening_loc, parts, closing_loc, location) ⇒ InterpolatedSymbolNode

def initialize: (opening_loc: Location?, parts: Array, closing_loc: Location?, location: Location) -> void



3484
3485
3486
3487
3488
3489
# File 'lib/yarp/node.rb', line 3484

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_locObject (readonly)

attr_reader closing_loc: Location?



3481
3482
3483
# File 'lib/yarp/node.rb', line 3481

def closing_loc
  @closing_loc
end

#opening_locObject (readonly)

attr_reader opening_loc: Location?



3475
3476
3477
# File 'lib/yarp/node.rb', line 3475

def opening_loc
  @opening_loc
end

#partsObject (readonly)

attr_reader parts: Array



3478
3479
3480
# File 'lib/yarp/node.rb', line 3478

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3492
3493
3494
# File 'lib/yarp/node.rb', line 3492

def accept(visitor)
  visitor.visit_interpolated_symbol_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



3502
3503
3504
# File 'lib/yarp/node.rb', line 3502

def child_nodes
  [*parts]
end

#closingObject

def closing: () -> String?



3520
3521
3522
# File 'lib/yarp/node.rb', line 3520

def closing
  closing_loc&.slice
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



3510
3511
3512
# File 'lib/yarp/node.rb', line 3510

def deconstruct_keys(keys)
  { opening_loc: opening_loc, parts: parts, closing_loc: closing_loc, location: location }
end

#openingObject

def opening: () -> String?



3515
3516
3517
# File 'lib/yarp/node.rb', line 3515

def opening
  opening_loc&.slice
end

#set_newline_flag(newline_marked) ⇒ Object



3496
3497
3498
3499
# File 'lib/yarp/node.rb', line 3496

def set_newline_flag(newline_marked)
  first = parts.first
  first.set_newline_flag(newline_marked) if first
end