Sha256: 09fe12255acd6d2b320582996c6dcdf79de74840ca190aaa8851cdf16f672341

Contents?: true

Size: 504 Bytes

Versions: 6

Compression:

Stored size: 504 Bytes

Contents

require 'parameters/types/object'

module Parameters
  module Types
    class Regexp < Object

      #
      # Coerces a value into a Regular Expression.
      #
      # @param [#to_regexp, #to_s] value
      #   The value to coerce.
      #
      # @return [::Regexp]
      #   The coerced Regular Expression.
      #
      def self.coerce(value)
        if value.respond_to?(:to_regexp)
          value.to_regexp
        else
          ::Regexp.new(value.to_s)
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parameters-0.4.4 lib/parameters/types/regexp.rb
parameters-0.4.3 lib/parameters/types/regexp.rb
parameters-0.4.2 lib/parameters/types/regexp.rb
parameters-0.4.0 lib/parameters/types/regexp.rb
parameters-0.3.1 lib/parameters/types/regexp.rb
parameters-0.3.0 lib/parameters/types/regexp.rb