Class: Strling::Core::IRLook

Inherits:
IROp
  • Object
show all
Defined in:
lib/strling/core/ir.rb

Overview

Represents a lookaround assertion in the IR.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, neg, body) ⇒ IRLook

Returns a new instance of IRLook.

Parameters:

  • dir (String)

    The direction

  • neg (Boolean)

    Whether the assertion is negative

  • body (IROp)

    The body of the assertion



332
333
334
335
336
# File 'lib/strling/core/ir.rb', line 332

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

Instance Attribute Details

#bodyIROp

Returns The body of the assertion.

Returns:

  • (IROp)

    The body of the assertion



327
328
329
# File 'lib/strling/core/ir.rb', line 327

def body
  @body
end

#dirString

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

Returns:

  • (String)

    The direction: “Ahead” or “Behind”



321
322
323
# File 'lib/strling/core/ir.rb', line 321

def dir
  @dir
end

#negBoolean

Returns Whether the assertion is negative.

Returns:

  • (Boolean)

    Whether the assertion is negative



324
325
326
# File 'lib/strling/core/ir.rb', line 324

def neg
  @neg
end

Instance Method Details

#to_dictObject



338
339
340
341
342
343
344
345
# File 'lib/strling/core/ir.rb', line 338

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