Class: Highway::Steps::Types::Url

Inherits:
String
  • Object
show all
Defined in:
lib/highway/steps/types/url.rb

Overview

This class represents an URL parameter type.

Instance Method Summary collapse

Methods inherited from String

regex

Methods inherited from Any

#initialize, #typecheck_and_validate, #validate

Constructor Details

This class inherits a constructor from Highway::Steps::Types::Any

Instance Method Details

#typecheck(value) ⇒ URI?

Typecheck and coerce a value if possible.

This method returns a typechecked and coerced value or ‘nil` if value has invalid type and can’t be coerced.

Parameters:

  • value (Object)

    A value.

Returns:

  • (URI, nil)


25
26
27
28
29
# File 'lib/highway/steps/types/url.rb', line 25

def typecheck(value)
  typechecked = super(value)
  parsed = URI.parse(typechecked) rescue nil
  parsed if parsed && parsed.kind_of?(URI::HTTP)
end