class Parameters::Types::URI

Public Class Methods

===(value) click to toggle source

Determines if the value is already a URI.

@param [Object] value

The value to inspect.

@return [Boolean]

Specifies whether the value inherits `URI::Generic`.
# File lib/parameters/types/uri.rb, line 18
def self.===(value)
  value.kind_of?(::URI::Generic)
end
coerce(value) click to toggle source

Coerces a value into a URI.

@param [#to_uri, to_s] value

The value to coerce.

@return [URI::Generic]

The coerced URI.
# File lib/parameters/types/uri.rb, line 31
def self.coerce(value)
  if value.respond_to?(:to_uri)
    value.to_uri
  else
    ::URI.parse(value.to_s)
  end
end