class Addressable::URI

def scheme=(new_scheme)

Parameters:
  • new_scheme (String, #to_str) -- The new scheme component.
def scheme=(new_scheme)
  if new_scheme && !new_scheme.respond_to?(:to_str)
    raise TypeError, "Can't convert #{new_scheme.class} into String."
  elsif new_scheme
    new_scheme = new_scheme.to_str
  end
  if new_scheme && new_scheme !~ /\A[a-z][a-z0-9\.\+\-]*\z/i
    raise InvalidURIError, "Invalid scheme format: #{new_scheme}"
  end
  @scheme = new_scheme
  @scheme = nil if @scheme.to_s.strip.empty?
  # Reset dependent values
  remove_instance_variable(:@normalized_scheme) if defined?(@normalized_scheme)
  remove_composite_values
  # Ensure we haven't created an invalid URI
  validate()
end