Class: Strling::Core::ClassRange

Inherits:
ClassItem show all
Defined in:
lib/strling/core/nodes.rb

Overview

Represents a character range in a character class.

Matches characters from from_ch to to_ch (inclusive).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_ch, to_ch) ⇒ ClassRange

Returns a new instance of ClassRange.

Parameters:

  • from_ch (String)

    The starting character

  • to_ch (String)

    The ending character



228
229
230
231
# File 'lib/strling/core/nodes.rb', line 228

def initialize(from_ch, to_ch)
  @from_ch = from_ch
  @to_ch = to_ch
end

Instance Attribute Details

#from_chString

Returns The starting character.

Returns:

  • (String)

    The starting character



221
222
223
# File 'lib/strling/core/nodes.rb', line 221

def from_ch
  @from_ch
end

#to_chString

Returns The ending character.

Returns:

  • (String)

    The ending character



224
225
226
# File 'lib/strling/core/nodes.rb', line 224

def to_ch
  @to_ch
end

Instance Method Details

#to_dictObject



233
234
235
# File 'lib/strling/core/nodes.rb', line 233

def to_dict
  { 'kind' => 'Range', 'from' => from_ch, 'to' => to_ch }
end