class Regex::CharShorthand

A pre-defined character class is in essence a name for a built-in, standard character class.

Constants

StandardCClasses

A constant Hash that defines all the predefined character shorthands. It contains pairs of the form: a pre-defined character shorthand letter => a CharRange object

Attributes

shortname[R]

An one-letter abbreviation

Public Class Methods

new(aShortname) click to toggle source

Constructor

Calls superclass method
# File lib/regex/char_shorthand.rb, line 28
def initialize(aShortname)
  super()
  @shortname = valid_shortname(aShortname)
end

Protected Instance Methods

text_repr() click to toggle source

Conversion method re-definition. Purpose: Return the String representation of the expression.

# File lib/regex/char_shorthand.rb, line 37
def text_repr
  "\\#{shortname}"
end

Private Instance Methods

valid_shortname(aShortname) click to toggle source

Return the validated short name.

# File lib/regex/char_shorthand.rb, line 44
def valid_shortname(aShortname)
  msg = "Unknown predefined character class \\#{aShortname}"
  raise StandardError, msg unless StandardCClasses.include? aShortname

  return aShortname
end