Class: Strling::Core::IRAlt

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

Overview

Represents an alternation (OR) operation in the IR.

Matches any one of the provided branches. Equivalent to the | operator in traditional regex syntax.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branches) ⇒ IRAlt

Returns a new instance of IRAlt.

Parameters:

  • branches (Array<IROp>)

    The alternative branches



44
45
46
# File 'lib/strling/core/ir.rb', line 44

def initialize(branches)
  @branches = branches
end

Instance Attribute Details

#branchesArray<IROp>

Returns The alternative branches.

Returns:

  • (Array<IROp>)

    The alternative branches



41
42
43
# File 'lib/strling/core/ir.rb', line 41

def branches
  @branches
end

Instance Method Details

#to_dictObject



48
49
50
# File 'lib/strling/core/ir.rb', line 48

def to_dict
  { 'ir' => 'Alt', 'branches' => branches.map(&:to_dict) }
end