class Regex::CharClass
Abstract class. A n-ary matching operator. It succeeds when one child expression succeeds to match the subject text.
Constants
- Metachars
These are characters with special meaning in character classes
Attributes
negated[R]
A flag that indicates whether the character is negated
Public Class Methods
new(to_negate, *theChildren)
click to toggle source
Constructor.
Calls superclass method
# File lib/regex/char_class.rb, line 17 def initialize(to_negate, *theChildren) super(theChildren) @negated = to_negate end
Protected Instance Methods
text_repr()
click to toggle source
Conversion method re-definition. Purpose: Return the String representation of the character class.
# File lib/regex/char_class.rb, line 26 def text_repr result_children = children.inject(+'') do |sub_result, child| if child.kind_of?(Regex::Character) && Metachars.include?(child.codepoint) sub_result << '\\' # Escape meta-character... end sub_result << child.to_str end result = "[#{negated ? '^' : ''}#{result_children}]" return result end