Class: Parameters::Types::Regexp Private

Inherits:
Object show all
Defined in:
lib/parameters/types/regexp.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

Class Method Summary collapse

Methods inherited from Object

#===, ===, to_ruby

Methods inherited from Type

#<, #<=, #==, ===, #===, #coerce, #to_ruby, to_ruby

Class Method Details

.coerce(value) ⇒ ::Regexp

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerces a value into a Regular Expression.

Parameters:

  • value (#to_regexp, #to_s)

    The value to coerce.

Returns:

  • (::Regexp)

    The coerced Regular Expression.

Since:

  • 0.3.0



16
17
18
19
20
21
22
# File 'lib/parameters/types/regexp.rb', line 16

def self.coerce(value)
  if value.respond_to?(:to_regexp)
    value.to_regexp
  else
    ::Regexp.new(value.to_s)
  end
end