Class: Strling::Core::IRClassEscape

Inherits:
IRClassItem show all
Defined in:
lib/strling/core/ir.rb

Overview

Represents an escape sequence in a character class in the IR.

Matches predefined character classes or Unicode properties.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, property: nil) ⇒ IRClassEscape

Returns a new instance of IRClassEscape.

Parameters:

  • type (String)

    The escape type

  • property (String, nil) (defaults to: nil)

    The Unicode property name



175
176
177
178
# File 'lib/strling/core/ir.rb', line 175

def initialize(type, property: nil)
  @type = type
  @property = property
end

Instance Attribute Details

#propertyString?

Returns The Unicode property name (for p and P).

Returns:

  • (String, nil)

    The Unicode property name (for p and P)



171
172
173
# File 'lib/strling/core/ir.rb', line 171

def property
  @property
end

#typeString

Returns The escape type.

Returns:

  • (String)

    The escape type



168
169
170
# File 'lib/strling/core/ir.rb', line 168

def type
  @type
end

Instance Method Details

#to_dictObject



180
181
182
183
184
# File 'lib/strling/core/ir.rb', line 180

def to_dict
  data = { 'ir' => 'Esc', 'type' => type }
  data['property'] = property if property
  data
end