Class: Regex::CharShorthand

Inherits:
AtomicExpression show all
Defined in:
lib/regex/char_shorthand.rb

Overview

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

Constant Summary collapse

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

{
  'd' => '[0-9]',
  'D' => '[^0-9]',
  'h' => '[0-9a-fA-F]',
  'H' => '[^0-9a-fA-F]',
  's' => '[ \t\r\n\f]',
  'S' => '[^ \t\r\n\f]',
  'w' => '[0-9a-zA-Z_]',
  'W' => '[^0-9a-zA-Z_]'
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Expression

#begin_anchor, #end_anchor

Instance Method Summary collapse

Methods inherited from AtomicExpression

#atomic?, #done!, #lazy!

Methods inherited from Expression

#atomic?, #options, #to_str

Constructor Details

#initialize(aShortname) ⇒ CharShorthand

Constructor



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

def initialize(aShortname)
  @shortname = valid_shortname(aShortname)
end

Instance Attribute Details

#shortnameObject (readonly)

An one-letter abbreviation



23
24
25
# File 'lib/regex/char_shorthand.rb', line 23

def shortname
  @shortname
end