Method: Iri#append
- Defined in:
- lib/iri.rb
#append(part) ⇒ Iri
Appends a new segment to the existing path.
This method adds a new segment to the existing path, automatically handling the slash between segments and URL encoding the new segment.
375 376 377 378 379 380 381 382 383 |
# File 'lib/iri.rb', line 375 def append(part) raise ArgumentError, "The part can't be nil" if part.nil? part = part.to_s raise ArgumentError, "The part can't be empty" if part.empty? modify do |c| tail = (c.path.end_with?('/') ? '' : '/') + CGI.escape(part.to_s) c.path = c.path + tail end end |