Method: Addressable::URI#scheme=

Defined in:
lib/vendor/addressable/lib/addressable/uri.rb

#scheme=(new_scheme) ⇒ Object

Sets the scheme component for this URI.

Parameters:

  • new_scheme (String, #to_str)

    The new scheme component.

Raises:

  • (TypeError)


646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/vendor/addressable/lib/addressable/uri.rb', line 646

def scheme=(new_scheme)
  # Check for frozenness
  raise TypeError, "Can't modify frozen URI." if self.frozen?

  if new_scheme && !new_scheme.respond_to?(:to_str)
    raise TypeError, "Can't convert #{new_scheme.class} into String."
  end
  @scheme = new_scheme ? new_scheme.to_str : nil
  @scheme = nil if @scheme.to_s.strip == ""

  # Reset dependant values
  @normalized_scheme = nil
  @uri_string = nil

  # Ensure we haven't created an invalid URI
  validate()
end