Class: Regex::CharRange

Inherits:
PolyadicExpression show all
Defined in:
lib/regex/char_range.rb

Overview

A binary expression that represents a contiguous range of characters. Assumption: characters are ordered by codepoint

Instance Attribute Summary

Attributes inherited from PolyadicExpression

#children

Attributes inherited from Expression

#begin_anchor, #end_anchor

Instance Method Summary collapse

Methods inherited from PolyadicExpression

#<<, #df_visitor, #done!, #lazy!

Methods inherited from CompoundExpression

#atomic?

Methods inherited from Expression

#atomic?, #options, #to_str

Constructor Details

#initialize(theLowerBound, theUpperBound) ⇒ CharRange

Constructor. [thelowerBound] A character that will be the lower bound value for the range. [theUpperBound] A character that will be the upper bound value for the range. TODO: optimisation. Build a Character if lower bound == upper bound.



15
16
17
18
# File 'lib/regex/char_range.rb', line 15

def initialize(theLowerBound, theUpperBound)
  range = validated_range(theLowerBound, theUpperBound)
  super(range)
end

Instance Method Details

#lowerObject

Return the lower bound of the range.



21
22
23
# File 'lib/regex/char_range.rb', line 21

def lower
  children.first
end

#upperObject

Return the upper bound of the range.



26
27
28
# File 'lib/regex/char_range.rb', line 26

def upper
  children.last
end