Module: Regexp::Expression

Included in:
Parser
Defined in:
lib/regexp_parser/expression.rb,
lib/regexp_parser/expression/quantifier.rb,
lib/regexp_parser/expression/classes/set.rb,
lib/regexp_parser/expression/classes/root.rb,
lib/regexp_parser/expression/classes/type.rb,
lib/regexp_parser/expression/classes/group.rb,
lib/regexp_parser/expression/subexpression.rb,
lib/regexp_parser/expression/classes/anchor.rb,
lib/regexp_parser/expression/classes/escape.rb,
lib/regexp_parser/expression/classes/backref.rb,
lib/regexp_parser/expression/classes/literal.rb,
lib/regexp_parser/expression/classes/property.rb,
lib/regexp_parser/expression/classes/alternation.rb

Defined Under Namespace

Modules: Anchor, Assertion, Backreference, CharacterType, EscapeSequence, Group, UnicodeProperty Classes: Alternation, Base, CharacterSet, CharacterSubSet, Literal, Quantifier, Root, Sequence, Subexpression

Class Method Summary collapse

Class Method Details

.parsed(exp) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/regexp_parser/expression.rb', line 111

def self.parsed(exp)
  case exp
  when String
    Regexp::Parser.parse(exp)
  when Regexp
    Regexp::Parser.parse(exp.source)
  when Regexp::Expression
    exp
  else
    raise "Expression.parsed accepts a String, Regexp, or " +
          "a Regexp::Expression as a value for exp, but it " +
          "was given #{exp.class.name}."
  end
end