Class: Ronin::Core::Params::Types::URI
- Defined in:
- lib/ronin/core/params/types/uri.rb
Overview
Represents a URL type.
Instance Method Summary collapse
-
#coerce(value) ⇒ ::URI
private
Parses the String value.
Instance Method Details
#coerce(value) ⇒ ::URI
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.
Parses the String value.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ronin/core/params/types/uri.rb', line 46 def coerce(value) case value when ::URI then value when ::String if value.empty? raise(ValidationError,"value must not be empty") end unless value =~ /\A[a-z]+:/ raise(ValidationError,"value must start with a 'scheme:' (#{value.inspect})") end begin ::URI.parse(value) rescue ::URI::InvalidURIError raise(ValidationError,"value is not a valid URI (#{value.inspect})") end else raise(ValidationError,"value must be either a String or a URI (#{value.inspect})") end end |