Class: YARP::InterpolatedXStringNode

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

Instance Method Summary collapse

Constructor Details

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

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



3581
3582
3583
3584
3585
3586
# File 'lib/yarp/node.rb', line 3581

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



3578
3579
3580
# File 'lib/yarp/node.rb', line 3578

def closing_loc
  @closing_loc
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



3572
3573
3574
# File 'lib/yarp/node.rb', line 3572

def opening_loc
  @opening_loc
end

#partsObject (readonly)

attr_reader parts: Array



3575
3576
3577
# File 'lib/yarp/node.rb', line 3575

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3589
3590
3591
# File 'lib/yarp/node.rb', line 3589

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

#child_nodesObject Also known as: deconstruct

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



3599
3600
3601
# File 'lib/yarp/node.rb', line 3599

def child_nodes
  [*parts]
end

#closingObject

def closing: () -> String



3617
3618
3619
# File 'lib/yarp/node.rb', line 3617

def closing
  closing_loc.slice
end

#deconstruct_keys(keys) ⇒ Object

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



3607
3608
3609
# File 'lib/yarp/node.rb', line 3607

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

#openingObject

def opening: () -> String



3612
3613
3614
# File 'lib/yarp/node.rb', line 3612

def opening
  opening_loc.slice
end

#set_newline_flag(newline_marked) ⇒ Object



3593
3594
3595
3596
# File 'lib/yarp/node.rb', line 3593

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