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



4270
4271
4272
4273
4274
4275
4276
# File 'lib/yarp/node.rb', line 4270

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



4264
4265
4266
# File 'lib/yarp/node.rb', line 4264

def closing_loc
  @closing_loc
end

#flagsObject (readonly)

attr_reader flags: Integer



4267
4268
4269
# File 'lib/yarp/node.rb', line 4267

def flags
  @flags
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



4258
4259
4260
# File 'lib/yarp/node.rb', line 4258

def opening_loc
  @opening_loc
end

#partsObject (readonly)

attr_reader parts: Array



4261
4262
4263
# File 'lib/yarp/node.rb', line 4261

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4279
4280
4281
# File 'lib/yarp/node.rb', line 4279

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

#ascii_8bit?Boolean

def ascii_8bit?: () -> bool

Returns:

  • (Boolean)


4343
4344
4345
# File 'lib/yarp/node.rb', line 4343

def ascii_8bit?
  flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
end

#child_nodesObject Also known as: deconstruct

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



4289
4290
4291
# File 'lib/yarp/node.rb', line 4289

def child_nodes
  [*parts]
end

#closingObject

def closing: () -> String



4318
4319
4320
# File 'lib/yarp/node.rb', line 4318

def closing
  closing_loc.slice
end

#copy(**params) ⇒ Object

def copy: (**params) -> InterpolatedRegularExpressionNode



4294
4295
4296
4297
4298
4299
4300
4301
4302
# File 'lib/yarp/node.rb', line 4294

def copy(**params)
  InterpolatedRegularExpressionNode.new(
    params.fetch(:opening_loc) { opening_loc },
    params.fetch(:parts) { parts },
    params.fetch(:closing_loc) { closing_loc },
    params.fetch(:flags) { flags },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



4308
4309
4310
# File 'lib/yarp/node.rb', line 4308

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

#euc_jp?Boolean

def euc_jp?: () -> bool

Returns:

  • (Boolean)


4338
4339
4340
# File 'lib/yarp/node.rb', line 4338

def euc_jp?
  flags.anybits?(RegularExpressionFlags::EUC_JP)
end

#extended?Boolean

def extended?: () -> bool

Returns:

  • (Boolean)


4333
4334
4335
# File 'lib/yarp/node.rb', line 4333

def extended?
  flags.anybits?(RegularExpressionFlags::EXTENDED)
end

#ignore_case?Boolean

def ignore_case?: () -> bool

Returns:

  • (Boolean)


4323
4324
4325
# File 'lib/yarp/node.rb', line 4323

def ignore_case?
  flags.anybits?(RegularExpressionFlags::IGNORE_CASE)
end

#multi_line?Boolean

def multi_line?: () -> bool

Returns:

  • (Boolean)


4328
4329
4330
# File 'lib/yarp/node.rb', line 4328

def multi_line?
  flags.anybits?(RegularExpressionFlags::MULTI_LINE)
end

#once?Boolean

def once?: () -> bool

Returns:

  • (Boolean)


4358
4359
4360
# File 'lib/yarp/node.rb', line 4358

def once?
  flags.anybits?(RegularExpressionFlags::ONCE)
end

#openingObject

def opening: () -> String



4313
4314
4315
# File 'lib/yarp/node.rb', line 4313

def opening
  opening_loc.slice
end

#set_newline_flag(newline_marked) ⇒ Object



4283
4284
4285
4286
# File 'lib/yarp/node.rb', line 4283

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

#utf_8?Boolean

def utf_8?: () -> bool

Returns:

  • (Boolean)


4353
4354
4355
# File 'lib/yarp/node.rb', line 4353

def utf_8?
  flags.anybits?(RegularExpressionFlags::UTF_8)
end

#windows_31j?Boolean

def windows_31j?: () -> bool

Returns:

  • (Boolean)


4348
4349
4350
# File 'lib/yarp/node.rb', line 4348

def windows_31j?
  flags.anybits?(RegularExpressionFlags::WINDOWS_31J)
end