Method: Iri#initialize
- Defined in:
- lib/iri.rb
#initialize(uri = '', local: false, safe: true) ⇒ Iri
Creates a new Iri object for URI manipulation.
You can even ignore the argument, which will produce an empty URI (“/”).
By default, this class will never throw any exceptions, even if your URI is not valid. It will just assume that the URI is “/”. However, you can turn this safe mode off by specifying safe as FALSE, which will cause InvalidURI to be raised if the URI is malformed.
The local parameter can be used if you only want to work with the path, query, and fragment portions of a URI, without the scheme, host, and port.
63 64 65 66 67 68 |
# File 'lib/iri.rb', line 63 def initialize(uri = '', local: false, safe: true) raise ArgumentError, "The uri can't be nil" if uri.nil? @uri = uri.to_s @local = local @safe = safe end |