Class: YARP::InterpolatedRegularExpressionNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents a regular expression literal that contains interpolation.

/foo #{bar} baz/
^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opening_loc, parts, closing_loc, flags, location) ⇒ InterpolatedRegularExpressionNode

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



3371
3372
3373
3374
3375
3376
3377
# File 'lib/yarp/node.rb', line 3371

def initialize(opening_loc, parts, closing_loc, flags, location)
  @opening_loc = opening_loc
  @parts = parts
  @closing_loc = closing_loc
  @flags = flags
  @location = location
end

Instance Attribute Details

#closing_locObject (readonly)

attr_reader closing_loc: Location



3365
3366
3367
# File 'lib/yarp/node.rb', line 3365

def closing_loc
  @closing_loc
end

#flagsObject (readonly)

attr_reader flags: Integer



3368
3369
3370
# File 'lib/yarp/node.rb', line 3368

def flags
  @flags
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



3359
3360
3361
# File 'lib/yarp/node.rb', line 3359

def opening_loc
  @opening_loc
end

#partsObject (readonly)

attr_reader parts: Array



3362
3363
3364
# File 'lib/yarp/node.rb', line 3362

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3380
3381
3382
# File 'lib/yarp/node.rb', line 3380

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

#child_nodesObject Also known as: deconstruct

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



3390
3391
3392
# File 'lib/yarp/node.rb', line 3390

def child_nodes
  [*parts]
end

#closingObject

def closing: () -> String



3408
3409
3410
# File 'lib/yarp/node.rb', line 3408

def closing
  closing_loc.slice
end

#deconstruct_keys(keys) ⇒ Object

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



3398
3399
3400
# File 'lib/yarp/node.rb', line 3398

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

#openingObject

def opening: () -> String



3403
3404
3405
# File 'lib/yarp/node.rb', line 3403

def opening
  opening_loc.slice
end

#set_newline_flag(newline_marked) ⇒ Object



3384
3385
3386
3387
# File 'lib/yarp/node.rb', line 3384

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