Class: Strling::Core::IRCharClass

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

Overview

Represents a character class in the IR.

Matches any character from the set defined by items.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(negated, items) ⇒ IRCharClass

Returns a new instance of IRCharClass.

Parameters:

  • negated (Boolean)

    Whether the class is negated

  • items (Array<IRClassItem>)

    The items in the character class



199
200
201
202
# File 'lib/strling/core/ir.rb', line 199

def initialize(negated, items)
  @negated = negated
  @items = items
end

Instance Attribute Details

#itemsArray<IRClassItem>

Returns The items in the character class.

Returns:

  • (Array<IRClassItem>)

    The items in the character class



195
196
197
# File 'lib/strling/core/ir.rb', line 195

def items
  @items
end

#negatedBoolean

Returns Whether the class is negated.

Returns:

  • (Boolean)

    Whether the class is negated



192
193
194
# File 'lib/strling/core/ir.rb', line 192

def negated
  @negated
end

Instance Method Details

#to_dictObject



204
205
206
207
208
209
210
# File 'lib/strling/core/ir.rb', line 204

def to_dict
  {
    'ir' => 'CharClass',
    'negated' => negated,
    'items' => items.map(&:to_dict)
  }
end