Method: Iri#scheme

Defined in:
lib/iri.rb

#scheme(val) ⇒ Iri

Replaces the scheme part of the URI.

Examples:

Changing the scheme

Iri.new('http://google.com').scheme('https')
# => "https://google.com"

Parameters:

  • val (String)

    New scheme to set, like “https” or “http”

Returns:

  • (Iri)

    A new Iri instance

Raises:

  • (ArgumentError)

See Also:



218
219
220
221
222
223
224
225
# File 'lib/iri.rb', line 218

def scheme(val)
  raise ArgumentError, "The scheme can't be nil" if val.nil?
  val = val.to_s
  raise ArgumentError, "The scheme can't be empty" if val.empty?
  modify do |c|
    c.scheme = val
  end
end