Class: URLWithRef
- Inherits:
-
Object
- Object
- URLWithRef
- Defined in:
- lib/url_with_ref.rb
Instance Method Summary collapse
-
#initialize(url, ref) ⇒ URLWithRef
constructor
A new instance of URLWithRef.
- #to_s ⇒ Object
Constructor Details
#initialize(url, ref) ⇒ URLWithRef
Returns a new instance of URLWithRef.
6 7 8 9 |
# File 'lib/url_with_ref.rb', line 6 def initialize(url, ref) @url = url @ref = ref end |
Instance Method Details
#to_s ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/url_with_ref.rb', line 11 def to_s uri = URI(@url&.strip).normalize params = URI.decode_www_form(uri.query || "") params << ["ref", @ref] unless params.any? { |param| param.index "ref" } uri.query = URI.encode_www_form(params) uri.to_s rescue StandardError => e @url end |