module Regexp::Syntax
def self.new(name)
the given syntax version name. The special names 'any' and '*' return an
Loads and instantiates an instance of the syntax specification class for
def self.new(name) return Regexp::Syntax::Any.new if ['*', 'any'].include?( name.to_s ) raise UnknownSyntaxNameError.new(name) unless supported?(name) version_class(name).new end
def self.supported?(name)
def self.supported?(name) VERSIONS.include?(name) end
def self.version_class(version)
def self.version_class(version) raise InvalidVersionNameError.new(version) unless version =~ VERSION_REGEXP version_const_name = version.scan(/\d+/).join const_name = "Regexp::Syntax::Ruby::V#{version_const_name}" if RUBY_VERSION >= '2.0.0' Kernel.const_get(const_name) else Object.module_eval(const_name, __FILE__, __LINE__) end end