lib/iri.rb in iri-0.5.0 vs lib/iri.rb in iri-0.5.1

- old
+ new

@@ -1,10 +1,10 @@ # frozen_string_literal: true # (The MIT License) # -# Copyright (c) 2019 Yegor Bugayenko +# Copyright (c) 2019-2021 Yegor Bugayenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -40,11 +40,11 @@ # # For more information read # {README}[https://github.com/yegor256/iri/blob/master/README.md] file. # # Author:: Yegor Bugayenko (yegor256@gmail.com) -# Copyright:: Copyright (c) 2019 Yegor Bugayenko +# Copyright:: Copyright (c) 2019-2021 Yegor Bugayenko # License:: MIT class Iri # When URI is not valid. class InvalidURI < StandardError; end @@ -68,12 +68,14 @@ # Convert it to an object of class +URI+. def to_uri the_uri.clone end - # Add a few query arguments. For example: + # Add a few query arguments. # + # For example: + # # Iri.new('https://google.com').add(q: 'test', limit: 10) # # You can add many of them and they will all be present in the resulting # URI, even if their names are the same. In order to make sure you have # only one instance of a query argument, use +del+ first: @@ -87,12 +89,14 @@ params[k.to_s] << v end end end - # Delete a few query arguments. For example: + # Delete a few query arguments. # + # For example: + # # Iri.new('https://google.com?q=test').del(:q) # def del(*keys) modify_query do |params| keys.each do |k| @@ -154,12 +158,14 @@ modify do |c| c.query = val end end - # Remove the entire path+query+fragment part. For example: + # Remove the entire path+query+fragment part. # + # For example: + # # Iri.new('https://google.com/a/b?q=test').cut('/hello') # # The result will contain "https://google.com/hello". def cut(path = '/') modify do |c| @@ -167,10 +173,12 @@ c.path = path c.fragment = nil end end - # Append something new to the path: + # Append something new to the path. + # + # For example: # # Iri.new('https://google.com/a/b?q=test').append('/hello') # # The result will contain "https://google.com/a/b/hello?q=test". def append(part)