Method: Iri#cut
- Defined in:
- lib/iri.rb
#cut(path = '/') ⇒ Iri
Removes the entire path, query, and fragment parts and sets a new path.
This method is useful for “cutting off” everything after the host:port and setting a new path, effectively removing query string and fragment.
344 345 346 347 348 349 350 351 352 353 |
# File 'lib/iri.rb', line 344 def cut(path = '/') raise ArgumentError, "The path can't be nil" if path.nil? path = path.to_s raise ArgumentError, "The path can't be empty" if path.empty? modify do |c| c.query = nil c.path = path c.fragment = nil end end |