Method: Addressable::URI#fragment=

Defined in:
lib/addressable/uri.rb

#fragment=(new_fragment) ⇒ Object

Sets the fragment component for this URI.

Parameters:

  • new_fragment (String, #to_str)

    The new fragment component.



1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
# File 'lib/addressable/uri.rb', line 1835

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

  # Reset dependent values
  @normalized_fragment = NONE
  remove_composite_values

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