Class: Strling::Core::Look

Inherits:
Node
  • Object
show all
Defined in:
lib/strling/core/nodes.rb

Overview

Represents a lookaround assertion.

Asserts that a pattern does (or does not) match ahead of or behind the current position, without consuming characters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, neg, body) ⇒ Look

Returns a new instance of Look.

Parameters:

  • dir (String)

    The direction

  • neg (Boolean)

    Whether the assertion is negative

  • body (Node)

    The body of the assertion



429
430
431
432
433
# File 'lib/strling/core/nodes.rb', line 429

def initialize(dir, neg, body)
  @dir = dir
  @neg = neg
  @body = body
end

Instance Attribute Details

#bodyNode

Returns The body of the assertion.

Returns:

  • (Node)

    The body of the assertion



424
425
426
# File 'lib/strling/core/nodes.rb', line 424

def body
  @body
end

#dirString

Returns The direction: “Ahead” or “Behind”.

Returns:

  • (String)

    The direction: “Ahead” or “Behind”



418
419
420
# File 'lib/strling/core/nodes.rb', line 418

def dir
  @dir
end

#negBoolean

Returns Whether the assertion is negative.

Returns:

  • (Boolean)

    Whether the assertion is negative



421
422
423
# File 'lib/strling/core/nodes.rb', line 421

def neg
  @neg
end

Instance Method Details

#to_dictObject



435
436
437
438
439
440
441
442
# File 'lib/strling/core/nodes.rb', line 435

def to_dict
  {
    'kind' => 'Look',
    'dir' => dir,
    'neg' => neg,
    'body' => body.to_dict
  }
end