addressable 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,115 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Addressable</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Addressable</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/addressable/uri_rb.html">
59
+ lib/addressable/uri.rb
60
+ </a>
61
+ <br />
62
+ <a href="../files/lib/addressable/version_rb.html">
63
+ lib/addressable/version.rb
64
+ </a>
65
+ <br />
66
+ </td>
67
+ </tr>
68
+
69
+ </table>
70
+ </div>
71
+ <!-- banner header -->
72
+
73
+ <div id="bodyContent">
74
+
75
+
76
+
77
+ <div id="contextContent">
78
+
79
+
80
+
81
+ </div>
82
+
83
+
84
+ </div>
85
+
86
+
87
+ <!-- if includes -->
88
+
89
+ <div id="section">
90
+
91
+ <div id="class-list">
92
+ <h3 class="section-bar">Classes and Modules</h3>
93
+
94
+ Class <a href="Addressable/URI.html" class="link">Addressable::URI</a><br />
95
+
96
+ </div>
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+ <!-- if method_list -->
105
+
106
+
107
+ </div>
108
+
109
+
110
+ <div id="validator-badges">
111
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
112
+ </div>
113
+
114
+ </body>
115
+ </html>
@@ -0,0 +1,2294 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Addressable::URI</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Addressable::URI</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/addressable/uri_rb.html">
59
+ lib/addressable/uri.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ This is an implementation of a <a href="URI.html">URI</a> parser based on
84
+ RFC 3986.
85
+ </p>
86
+
87
+ </div>
88
+
89
+
90
+ </div>
91
+
92
+ <div id="method-list">
93
+ <h3 class="section-bar">Methods</h3>
94
+
95
+ <div class="name-list">
96
+ <a href="#M000039">+</a>&nbsp;&nbsp;
97
+ <a href="#M000048">==</a>&nbsp;&nbsp;
98
+ <a href="#M000047">===</a>&nbsp;&nbsp;
99
+ <a href="#M000038">absolute?</a>&nbsp;&nbsp;
100
+ <a href="#M000021">authority</a>&nbsp;&nbsp;
101
+ <a href="#M000022">authority=</a>&nbsp;&nbsp;
102
+ <a href="#M000030">basename</a>&nbsp;&nbsp;
103
+ <a href="#M000002">convert_path</a>&nbsp;&nbsp;
104
+ <a href="#M000046">display_uri</a>&nbsp;&nbsp;
105
+ <a href="#M000050">dup</a>&nbsp;&nbsp;
106
+ <a href="#M000007">encode</a>&nbsp;&nbsp;
107
+ <a href="#M000005">encode_segment</a>&nbsp;&nbsp;
108
+ <a href="#M000049">eql?</a>&nbsp;&nbsp;
109
+ <a href="#M000003">expand_template</a>&nbsp;&nbsp;
110
+ <a href="#M000031">extname</a>&nbsp;&nbsp;
111
+ <a href="#M000009">extract</a>&nbsp;&nbsp;
112
+ <a href="#M000034">fragment</a>&nbsp;&nbsp;
113
+ <a href="#M000035">fragment=</a>&nbsp;&nbsp;
114
+ <a href="#M000019">host</a>&nbsp;&nbsp;
115
+ <a href="#M000020">host=</a>&nbsp;&nbsp;
116
+ <a href="#M000053">inspect</a>&nbsp;&nbsp;
117
+ <a href="#M000036">ip_based?</a>&nbsp;&nbsp;
118
+ <a href="#M000023">ip_based_schemes</a>&nbsp;&nbsp;
119
+ <a href="#M000004">join</a>&nbsp;&nbsp;
120
+ <a href="#M000040">merge</a>&nbsp;&nbsp;
121
+ <a href="#M000041">merge!</a>&nbsp;&nbsp;
122
+ <a href="#M000010">new</a>&nbsp;&nbsp;
123
+ <a href="#M000044">normalize</a>&nbsp;&nbsp;
124
+ <a href="#M000045">normalize!</a>&nbsp;&nbsp;
125
+ <a href="#M000008">normalized_encode</a>&nbsp;&nbsp;
126
+ <a href="#M000001">parse</a>&nbsp;&nbsp;
127
+ <a href="#M000015">password</a>&nbsp;&nbsp;
128
+ <a href="#M000016">password=</a>&nbsp;&nbsp;
129
+ <a href="#M000028">path</a>&nbsp;&nbsp;
130
+ <a href="#M000029">path=</a>&nbsp;&nbsp;
131
+ <a href="#M000025">port</a>&nbsp;&nbsp;
132
+ <a href="#M000026">port=</a>&nbsp;&nbsp;
133
+ <a href="#M000032">query</a>&nbsp;&nbsp;
134
+ <a href="#M000033">query=</a>&nbsp;&nbsp;
135
+ <a href="#M000037">relative?</a>&nbsp;&nbsp;
136
+ <a href="#M000042">route_from</a>&nbsp;&nbsp;
137
+ <a href="#M000043">route_to</a>&nbsp;&nbsp;
138
+ <a href="#M000011">scheme</a>&nbsp;&nbsp;
139
+ <a href="#M000012">scheme=</a>&nbsp;&nbsp;
140
+ <a href="#M000024">scheme_mapping</a>&nbsp;&nbsp;
141
+ <a href="#M000027">specified_port</a>&nbsp;&nbsp;
142
+ <a href="#M000052">to_h</a>&nbsp;&nbsp;
143
+ <a href="#M000051">to_s</a>&nbsp;&nbsp;
144
+ <a href="#M000006">unencode_segment</a>&nbsp;&nbsp;
145
+ <a href="#M000013">user</a>&nbsp;&nbsp;
146
+ <a href="#M000014">user=</a>&nbsp;&nbsp;
147
+ <a href="#M000017">userinfo</a>&nbsp;&nbsp;
148
+ <a href="#M000018">userinfo=</a>&nbsp;&nbsp;
149
+ </div>
150
+ </div>
151
+
152
+ </div>
153
+
154
+
155
+ <!-- if includes -->
156
+
157
+ <div id="section">
158
+
159
+ <div id="class-list">
160
+ <h3 class="section-bar">Classes and Modules</h3>
161
+
162
+ Module <a href="URI/CharacterClasses.html" class="link">Addressable::URI::CharacterClasses</a><br />
163
+ Module <a href="URI/IDNA.html" class="link">Addressable::URI::IDNA</a><br />
164
+ Class <a href="URI/InvalidOptionError.html" class="link">Addressable::URI::InvalidOptionError</a><br />
165
+ Class <a href="URI/InvalidTemplateValue.html" class="link">Addressable::URI::InvalidTemplateValue</a><br />
166
+ Class <a href="URI/InvalidURIError.html" class="link">Addressable::URI::InvalidURIError</a><br />
167
+
168
+ </div>
169
+
170
+
171
+ <div id="aliases-list">
172
+ <h3 class="section-bar">External Aliases</h3>
173
+
174
+ <div class="name-list">
175
+ <table summary="aliases">
176
+ <tr class="top-aligned-row context-row">
177
+ <td class="context-item-name">encode</td>
178
+ <td>-&gt;</td>
179
+ <td class="context-item-value">escape</td>
180
+ </tr>
181
+ </table>
182
+ </div>
183
+ </div>
184
+
185
+
186
+
187
+
188
+
189
+ <!-- if method_list -->
190
+ <div id="methods">
191
+ <h3 class="section-bar">Public Class methods</h3>
192
+
193
+ <div id="method-M000002" class="method-detail">
194
+ <a name="M000002"></a>
195
+
196
+ <div class="method-heading">
197
+ <a href="#M000002" class="method-signature">
198
+ <span class="method-name">convert_path</span><span class="method-args">(path)</span>
199
+ </a>
200
+ </div>
201
+
202
+ <div class="method-description">
203
+ <p>
204
+ Converts a <a href="URI.html#M000028">path</a> to a file protocol <a
205
+ href="URI.html">URI</a>. If the <a href="URI.html#M000028">path</a>
206
+ supplied is relative, it will be returned as a relative <a
207
+ href="URI.html">URI</a>. If the <a href="URI.html#M000028">path</a>
208
+ supplied is actually a <a href="URI.html">URI</a>, it will return the
209
+ parsed <a href="URI.html">URI</a>.
210
+ </p>
211
+ <p><a class="source-toggle" href="#"
212
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
213
+ <div class="method-source-code" id="M000002-source">
214
+ <pre>
215
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 119</span>
216
+ 119: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">convert_path</span>(<span class="ruby-identifier">path</span>)
217
+ 120: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">nil?</span>
218
+ 121:
219
+ 122: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">strip</span>
220
+ 123: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">converted_uri</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>
221
+ 124: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-value str">&quot;file://&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">converted_uri</span>
222
+ 125: <span class="ruby-keyword kw">end</span>
223
+ 126: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span>
224
+ 127: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^[a-zA-Z]:[\\\/]/</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
225
+ 128: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-value str">&quot;file:///&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">converted_uri</span>
226
+ 129: <span class="ruby-keyword kw">end</span>
227
+ 130: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^file:\/*/i</span>, <span class="ruby-value str">&quot;file:///&quot;</span>)
228
+ 131: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">converted_uri</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^file:/i</span>
229
+ 132: <span class="ruby-comment cmt"># Adjust windows-style uris</span>
230
+ 133: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^file:\/\/\/([a-zA-Z])\|/i</span>, <span class="ruby-value str">'file:///\1:'</span>)
231
+ 134: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\\/</span>, <span class="ruby-value str">'/'</span>)
232
+ 135: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">converted_uri</span>).<span class="ruby-identifier">normalize</span>
233
+ 136: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span>) <span class="ruby-operator">&amp;&amp;</span>
234
+ 137: <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">directory?</span>
235
+ 138: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\/$/</span>, <span class="ruby-value str">&quot;&quot;</span>)
236
+ 139: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span> = <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span>
237
+ 140: <span class="ruby-keyword kw">end</span>
238
+ 141: <span class="ruby-keyword kw">else</span>
239
+ 142: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">converted_uri</span>)
240
+ 143: <span class="ruby-keyword kw">end</span>
241
+ 144:
242
+ 145: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">converted_uri</span>
243
+ 146: <span class="ruby-keyword kw">end</span>
244
+ </pre>
245
+ </div>
246
+ </div>
247
+ </div>
248
+
249
+ <div id="method-M000007" class="method-detail">
250
+ <a name="M000007"></a>
251
+
252
+ <div class="method-heading">
253
+ <a href="#M000007" class="method-signature">
254
+ <span class="method-name">encode</span><span class="method-args">(uri)</span>
255
+ </a>
256
+ </div>
257
+
258
+ <div class="method-description">
259
+ <p>
260
+ Percent encodes any special characters in the <a href="URI.html">URI</a>.
261
+ This method does not take IRIs or IDNs into account.
262
+ </p>
263
+ <p><a class="source-toggle" href="#"
264
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
265
+ <div class="method-source-code" id="M000007-source">
266
+ <pre>
267
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 250</span>
268
+ 250: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">uri</span>)
269
+ 251: <span class="ruby-identifier">uri_object</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
270
+ 252: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
271
+ 253: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">scheme</span>,
272
+ 254: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">SCHEME</span>),
273
+ 255: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">user</span>,
274
+ 256: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
275
+ 257: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">password</span>,
276
+ 258: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
277
+ 259: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">host</span>,
278
+ 260: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
279
+ 261: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">specified_port</span>,
280
+ 262: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
281
+ 263: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">path</span>,
282
+ 264: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH</span>),
283
+ 265: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">query</span>,
284
+ 266: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">QUERY</span>),
285
+ 267: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">fragment</span>,
286
+ 268: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">FRAGMENT</span>)
287
+ 269: ).<span class="ruby-identifier">to_s</span>
288
+ 270: <span class="ruby-keyword kw">end</span>
289
+ </pre>
290
+ </div>
291
+ </div>
292
+ </div>
293
+
294
+ <div id="method-M000005" class="method-detail">
295
+ <a name="M000005"></a>
296
+
297
+ <div class="method-heading">
298
+ <a href="#M000005" class="method-signature">
299
+ <span class="method-name">encode_segment</span><span class="method-args">(segment, character_class= Addressable::URI::CharacterClasses::RESERVED + Addressable::URI::CharacterClasses::UNRESERVED)</span>
300
+ </a>
301
+ </div>
302
+
303
+ <div class="method-description">
304
+ <p>
305
+ Percent encodes a <a href="URI.html">URI</a> segment. Returns a string.
306
+ Takes an optional character class parameter, which should be specified as a
307
+ string containing a regular expression character class (not including the
308
+ surrounding square brackets). The character class parameter defaults to the
309
+ reserved plus unreserved character classes specified in RFC 3986. Usage of
310
+ the constants within the <a
311
+ href="URI/CharacterClasses.html">CharacterClasses</a> module is highly
312
+ recommended when using this method.
313
+ </p>
314
+ <p>
315
+ An example:
316
+ </p>
317
+ <pre>
318
+ Addressable::URI.escape_segment(&quot;simple-example&quot;, &quot;b-zB-Z0-9&quot;)
319
+ =&gt; &quot;simple%2Dex%61mple&quot;
320
+ </pre>
321
+ <p><a class="source-toggle" href="#"
322
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
323
+ <div class="method-source-code" id="M000005-source">
324
+ <pre>
325
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 228</span>
326
+ 228: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segment</span>, <span class="ruby-identifier">character_class</span>=
327
+ 229: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">RESERVED</span> <span class="ruby-operator">+</span>
328
+ 230: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">UNRESERVED</span>)
329
+ 231: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">nil?</span>
330
+ 232: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">gsub</span>(
331
+ 233: <span class="ruby-node">/[^#{character_class}]/</span>
332
+ 234: ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sequence</span><span class="ruby-operator">|</span>
333
+ 235: (<span class="ruby-value str">&quot;%&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">sequence</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'C'</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span>(<span class="ruby-value">16</span>).<span class="ruby-identifier">upcase</span>)
334
+ 236: <span class="ruby-keyword kw">end</span>
335
+ 237: <span class="ruby-keyword kw">end</span>
336
+ </pre>
337
+ </div>
338
+ </div>
339
+ </div>
340
+
341
+ <div id="method-M000003" class="method-detail">
342
+ <a name="M000003"></a>
343
+
344
+ <div class="method-heading">
345
+ <a href="#M000003" class="method-signature">
346
+ <span class="method-name">expand_template</span><span class="method-args">(pattern, mapping, processor=nil)</span>
347
+ </a>
348
+ </div>
349
+
350
+ <div class="method-description">
351
+ <p>
352
+ Expands a <a href="URI.html">URI</a> template into a full <a
353
+ href="URI.html">URI</a>.
354
+ </p>
355
+ <p>
356
+ An optional processor object may be supplied. The object should respond to
357
+ either the :validate or :transform messages or both. Both the :validate and
358
+ :transform methods should take two parameters: :name and :value. The
359
+ :validate method should return true or false; true if the value of the
360
+ variable is valid, false otherwise. The :transform method should return the
361
+ transformed variable value as a string.
362
+ </p>
363
+ <p>
364
+ An example:
365
+ </p>
366
+ <pre>
367
+ class ExampleProcessor
368
+ def self.validate(name, value)
369
+ return !!(value =~ /^[\w ]+$/) if name == &quot;query&quot;
370
+ return true
371
+ end
372
+
373
+ def self.transform(name, value)
374
+ return value.gsub(/ /, &quot;+&quot;) if name == &quot;query&quot;
375
+ return value
376
+ end
377
+ end
378
+
379
+ Addressable::URI.expand_template(
380
+ &quot;http://example.com/search/{query}/&quot;,
381
+ {&quot;query&quot; =&gt; &quot;an example search query&quot;},
382
+ ExampleProcessor).to_s
383
+ =&gt; &quot;http://example.com/search/an+example+search+query/&quot;
384
+ </pre>
385
+ <p><a class="source-toggle" href="#"
386
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
387
+ <div class="method-source-code" id="M000003-source">
388
+ <pre>
389
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 177</span>
390
+ 177: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">expand_template</span>(<span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">mapping</span>, <span class="ruby-identifier">processor</span>=<span class="ruby-keyword kw">nil</span>)
391
+ 178: <span class="ruby-identifier">result</span> = <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">dup</span>
392
+ 179: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">mapping</span>
393
+ 180: <span class="ruby-identifier">transformed_value</span> = <span class="ruby-identifier">value</span>
394
+ 181: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
395
+ 182: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:validate</span>)
396
+ 183: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">processor</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
397
+ 184: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidTemplateValue</span>,
398
+ 185: <span class="ruby-node">&quot;(#{name}, #{value}) is an invalid template value.&quot;</span>
399
+ 186: <span class="ruby-keyword kw">end</span>
400
+ 187: <span class="ruby-keyword kw">end</span>
401
+ 188: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:transform</span>)
402
+ 189: <span class="ruby-identifier">transformed_value</span> = <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">transform</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
403
+ 190: <span class="ruby-keyword kw">end</span>
404
+ 191: <span class="ruby-keyword kw">end</span>
405
+ 192:
406
+ 193: <span class="ruby-comment cmt"># Handle percent escaping</span>
407
+ 194: <span class="ruby-identifier">transformed_value</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">transformed_value</span>,
408
+ 195: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">RESERVED</span> <span class="ruby-operator">+</span>
409
+ 196: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">UNRESERVED</span>)
410
+ 197:
411
+ 198: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-node">/\{#{Regexp.escape(name)}\}/</span>, <span class="ruby-identifier">transformed_value</span>)
412
+ 199: <span class="ruby-keyword kw">end</span>
413
+ 200: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-node">/\{[#{CharacterClasses::UNRESERVED}]+\}/</span>, <span class="ruby-value str">&quot;&quot;</span>)
414
+ 201: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">result</span>)
415
+ 202: <span class="ruby-keyword kw">end</span>
416
+ </pre>
417
+ </div>
418
+ </div>
419
+ </div>
420
+
421
+ <div id="method-M000009" class="method-detail">
422
+ <a name="M000009"></a>
423
+
424
+ <div class="method-heading">
425
+ <a href="#M000009" class="method-signature">
426
+ <span class="method-name">extract</span><span class="method-args">(text, options={})</span>
427
+ </a>
428
+ </div>
429
+
430
+ <div class="method-description">
431
+ <p>
432
+ Extracts uris from an arbitrary body of text.
433
+ </p>
434
+ <p><a class="source-toggle" href="#"
435
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
436
+ <div class="method-source-code" id="M000009-source">
437
+ <pre>
438
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 316</span>
439
+ 316: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extract</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">options</span>={})
440
+ 317: <span class="ruby-identifier">defaults</span> = {<span class="ruby-identifier">:base</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">:parse</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>}
441
+ 318: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
442
+ 319: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidOptionError</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">options</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">keys</span>).<span class="ruby-identifier">empty?</span>
443
+ 320: <span class="ruby-comment cmt"># This regular expression needs to be less forgiving or else it would</span>
444
+ 321: <span class="ruby-comment cmt"># match virtually all text. Which isn't exactly what we're going for.</span>
445
+ 322: <span class="ruby-identifier">extract_regex</span> = <span class="ruby-regexp re">/((([a-z\+]+):)[^ \n\&lt;\&gt;\&quot;\\]+[\w\/])/</span>
446
+ 323: <span class="ruby-identifier">extracted_uris</span> =
447
+ 324: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">extract_regex</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">0</span>] }
448
+ 325: <span class="ruby-identifier">sgml_extract_regex</span> = <span class="ruby-regexp re">/&lt;[^&gt;]+href=\&quot;([^\&quot;]+?)\&quot;[^&gt;]*&gt;/</span>
449
+ 326: <span class="ruby-identifier">sgml_extracted_uris</span> =
450
+ 327: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">sgml_extract_regex</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">0</span>] }
451
+ 328: <span class="ruby-identifier">extracted_uris</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">sgml_extracted_uris</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">extracted_uris</span>)
452
+ 329: <span class="ruby-identifier">textile_extract_regex</span> = <span class="ruby-regexp re">/\&quot;.+?\&quot;:([^ ]+\/[^ ]+)[ \,\.\;\:\?\!\&lt;\&gt;\&quot;]/i</span>
453
+ 330: <span class="ruby-identifier">textile_extracted_uris</span> =
454
+ 331: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">textile_extract_regex</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">0</span>] }
455
+ 332: <span class="ruby-identifier">extracted_uris</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">textile_extracted_uris</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">extracted_uris</span>)
456
+ 333: <span class="ruby-identifier">parsed_uris</span> = []
457
+ 334: <span class="ruby-identifier">base_uri</span> = <span class="ruby-keyword kw">nil</span>
458
+ 335: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
459
+ 336: <span class="ruby-identifier">base_uri</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>].<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>)
460
+ 337: <span class="ruby-identifier">base_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>].<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base_uri</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
461
+ 338: <span class="ruby-keyword kw">end</span>
462
+ 339: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">uri_string</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">extracted_uris</span>
463
+ 340: <span class="ruby-keyword kw">begin</span>
464
+ 341: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base_uri</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
465
+ 342: <span class="ruby-identifier">parsed_uris</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri_string</span>)
466
+ 343: <span class="ruby-keyword kw">else</span>
467
+ 344: <span class="ruby-identifier">parsed_uris</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">base_uri</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri_string</span>))
468
+ 345: <span class="ruby-keyword kw">end</span>
469
+ 346: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
470
+ 347: <span class="ruby-keyword kw">nil</span>
471
+ 348: <span class="ruby-keyword kw">end</span>
472
+ 349: <span class="ruby-keyword kw">end</span>
473
+ 350: <span class="ruby-identifier">parsed_uris</span>.<span class="ruby-identifier">reject!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">uri</span><span class="ruby-operator">|</span>
474
+ 351: (<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/T\d+/</span> <span class="ruby-operator">||</span>
475
+ 352: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xmlns&quot;</span> <span class="ruby-operator">||</span>
476
+ 353: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;xml&quot;</span> <span class="ruby-operator">||</span>
477
+ 354: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;thr&quot;</span> <span class="ruby-operator">||</span>
478
+ 355: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;this&quot;</span> <span class="ruby-operator">||</span>
479
+ 356: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;float&quot;</span> <span class="ruby-operator">||</span>
480
+ 357: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;user&quot;</span> <span class="ruby-operator">||</span>
481
+ 358: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;username&quot;</span> <span class="ruby-operator">||</span>
482
+ 359: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;out&quot;</span>)
483
+ 360: <span class="ruby-keyword kw">end</span>
484
+ 361: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:parse</span>]
485
+ 362: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed_uris</span>
486
+ 363: <span class="ruby-keyword kw">else</span>
487
+ 364: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed_uris</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">uri</span><span class="ruby-operator">|</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span> }
488
+ 365: <span class="ruby-keyword kw">end</span>
489
+ 366: <span class="ruby-keyword kw">end</span>
490
+ </pre>
491
+ </div>
492
+ </div>
493
+ </div>
494
+
495
+ <div id="method-M000023" class="method-detail">
496
+ <a name="M000023"></a>
497
+
498
+ <div class="method-heading">
499
+ <a href="#M000023" class="method-signature">
500
+ <span class="method-name">ip_based_schemes</span><span class="method-args">()</span>
501
+ </a>
502
+ </div>
503
+
504
+ <div class="method-description">
505
+ <p>
506
+ Returns an array of known ip-based schemes. These schemes typically use a
507
+ similar <a href="URI.html">URI</a> form: //&lt;<a
508
+ href="URI.html#M000013">user</a>&gt;:&lt;<a
509
+ href="URI.html#M000015">password</a>&gt;@&lt;<a
510
+ href="URI.html#M000019">host</a>&gt;:&lt;<a
511
+ href="URI.html#M000025">port</a>&gt;/&lt;url-<a
512
+ href="URI.html#M000028">path</a>&gt;
513
+ </p>
514
+ <p><a class="source-toggle" href="#"
515
+ onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
516
+ <div class="method-source-code" id="M000023-source">
517
+ <pre>
518
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 541</span>
519
+ 541: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">ip_based_schemes</span>
520
+ 542: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme_mapping</span>.<span class="ruby-identifier">keys</span>
521
+ 543: <span class="ruby-keyword kw">end</span>
522
+ </pre>
523
+ </div>
524
+ </div>
525
+ </div>
526
+
527
+ <div id="method-M000004" class="method-detail">
528
+ <a name="M000004"></a>
529
+
530
+ <div class="method-heading">
531
+ <a href="#M000004" class="method-signature">
532
+ <span class="method-name">join</span><span class="method-args">(*uris)</span>
533
+ </a>
534
+ </div>
535
+
536
+ <div class="method-description">
537
+ <p>
538
+ Joins several uris together.
539
+ </p>
540
+ <p><a class="source-toggle" href="#"
541
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
542
+ <div class="method-source-code" id="M000004-source">
543
+ <pre>
544
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 205</span>
545
+ 205: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">uris</span>)
546
+ 206: <span class="ruby-identifier">uri_objects</span> = <span class="ruby-identifier">uris</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">uri</span><span class="ruby-operator">|</span>
547
+ 207: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
548
+ 208: <span class="ruby-keyword kw">end</span>
549
+ 209: <span class="ruby-identifier">result</span> = <span class="ruby-identifier">uri_objects</span>.<span class="ruby-identifier">shift</span>.<span class="ruby-identifier">dup</span>
550
+ 210: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">uri</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">uri_objects</span>
551
+ 211: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">uri</span>)
552
+ 212: <span class="ruby-keyword kw">end</span>
553
+ 213: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
554
+ 214: <span class="ruby-keyword kw">end</span>
555
+ </pre>
556
+ </div>
557
+ </div>
558
+ </div>
559
+
560
+ <div id="method-M000010" class="method-detail">
561
+ <a name="M000010"></a>
562
+
563
+ <div class="method-heading">
564
+ <a href="#M000010" class="method-signature">
565
+ <span class="method-name">new</span><span class="method-args">(scheme, user, password, host, port, path, query, fragment)</span>
566
+ </a>
567
+ </div>
568
+
569
+ <div class="method-description">
570
+ <p>
571
+ Creates a <a href="URI.html#M000010">new</a> uri object from component
572
+ parts. Passing nil for any of these parameters is acceptable.
573
+ </p>
574
+ <p><a class="source-toggle" href="#"
575
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
576
+ <div class="method-source-code" id="M000010-source">
577
+ <pre>
578
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 370</span>
579
+ 370: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">scheme</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">query</span>, <span class="ruby-identifier">fragment</span>)
580
+ 371: <span class="ruby-ivar">@scheme</span> = <span class="ruby-identifier">scheme</span>
581
+ 372: <span class="ruby-ivar">@scheme</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@scheme</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
582
+ 373: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">user</span>
583
+ 374: <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">password</span>
584
+ 375: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
585
+ 376: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_s</span>
586
+ 377: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
587
+ 378: <span class="ruby-ivar">@port</span> = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>)
588
+ 379: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@port</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span>(<span class="ruby-ivar">@port</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^\d+$/</span>)
589
+ 380: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
590
+ 381: <span class="ruby-node">&quot;Invalid port number: #{@port.inspect}&quot;</span>
591
+ 382: <span class="ruby-keyword kw">end</span>
592
+ 383: <span class="ruby-ivar">@port</span> = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span>
593
+ 384: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@port</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
594
+ 385: <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">path</span>
595
+ 386: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">query</span>
596
+ 387: <span class="ruby-ivar">@fragment</span> = <span class="ruby-identifier">fragment</span>
597
+ 388:
598
+ 389: <span class="ruby-identifier">validate</span>()
599
+ 390: <span class="ruby-keyword kw">end</span>
600
+ </pre>
601
+ </div>
602
+ </div>
603
+ </div>
604
+
605
+ <div id="method-M000008" class="method-detail">
606
+ <a name="M000008"></a>
607
+
608
+ <div class="method-heading">
609
+ <a href="#M000008" class="method-signature">
610
+ <span class="method-name">normalized_encode</span><span class="method-args">(uri)</span>
611
+ </a>
612
+ </div>
613
+
614
+ <div class="method-description">
615
+ <p>
616
+ Normalizes the encoding of a <a href="URI.html">URI</a>. Characters within
617
+ a hostname are not percent encoded to allow for internationalized domain
618
+ names.
619
+ </p>
620
+ <p><a class="source-toggle" href="#"
621
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
622
+ <div class="method-source-code" id="M000008-source">
623
+ <pre>
624
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 278</span>
625
+ 278: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalized_encode</span>(<span class="ruby-identifier">uri</span>)
626
+ 279: <span class="ruby-identifier">uri_object</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
627
+ 280: <span class="ruby-identifier">segments</span> = {
628
+ 281: <span class="ruby-identifier">:scheme</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">scheme</span>),
629
+ 282: <span class="ruby-identifier">:user</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">user</span>),
630
+ 283: <span class="ruby-identifier">:password</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">password</span>),
631
+ 284: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">host</span>),
632
+ 285: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">specified_port</span>),
633
+ 286: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">path</span>),
634
+ 287: <span class="ruby-identifier">:query</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">query</span>),
635
+ 288: <span class="ruby-identifier">:fragment</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">fragment</span>)
636
+ 289: }
637
+ 290: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">IDNA</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:use_libidn?</span>)
638
+ 291: <span class="ruby-identifier">segments</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
639
+ 292: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
640
+ 293: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-constant">IDN</span><span class="ruby-operator">::</span><span class="ruby-constant">Stringprep</span>.<span class="ruby-identifier">nfkc_normalize</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>)
641
+ 294: <span class="ruby-keyword kw">end</span>
642
+ 295: <span class="ruby-keyword kw">end</span>
643
+ 296: <span class="ruby-keyword kw">end</span>
644
+ 297: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
645
+ 298: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>],
646
+ 299: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">SCHEME</span>),
647
+ 300: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>],
648
+ 301: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
649
+ 302: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>],
650
+ 303: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
651
+ 304: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>],
652
+ 305: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>],
653
+ 306: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>],
654
+ 307: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH</span>),
655
+ 308: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>],
656
+ 309: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">QUERY</span>),
657
+ 310: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:fragment</span>],
658
+ 311: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">FRAGMENT</span>)
659
+ 312: ).<span class="ruby-identifier">to_s</span>
660
+ 313: <span class="ruby-keyword kw">end</span>
661
+ </pre>
662
+ </div>
663
+ </div>
664
+ </div>
665
+
666
+ <div id="method-M000001" class="method-detail">
667
+ <a name="M000001"></a>
668
+
669
+ <div class="method-heading">
670
+ <a href="#M000001" class="method-signature">
671
+ <span class="method-name">parse</span><span class="method-args">(uri_string)</span>
672
+ </a>
673
+ </div>
674
+
675
+ <div class="method-description">
676
+ <p>
677
+ Returns a <a href="URI.html">URI</a> object based on the parsed string.
678
+ </p>
679
+ <p><a class="source-toggle" href="#"
680
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
681
+ <div class="method-source-code" id="M000001-source">
682
+ <pre>
683
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 55</span>
684
+ 55: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri_string</span>)
685
+ 56: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri_string</span>.<span class="ruby-identifier">nil?</span>
686
+ 57:
687
+ 58: <span class="ruby-comment cmt"># If a URI object is passed, just return itself.</span>
688
+ 59: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">uri_string</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri_string</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>)
689
+ 60:
690
+ 61: <span class="ruby-comment cmt"># If a URI object of the Ruby standard library variety is passed,</span>
691
+ 62: <span class="ruby-comment cmt"># convert it to a string, then parse the string.</span>
692
+ 63: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri_string</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^URI::/</span>
693
+ 64: <span class="ruby-identifier">uri_string</span> = <span class="ruby-identifier">uri_string</span>.<span class="ruby-identifier">to_s</span>
694
+ 65: <span class="ruby-keyword kw">end</span>
695
+ 66:
696
+ 67: <span class="ruby-identifier">uri_regex</span> =
697
+ 68: <span class="ruby-regexp re">/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/</span>
698
+ 69: <span class="ruby-identifier">scan</span> = <span class="ruby-identifier">uri_string</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">uri_regex</span>)
699
+ 70: <span class="ruby-identifier">fragments</span> = <span class="ruby-identifier">scan</span>[<span class="ruby-value">0</span>]
700
+ 71: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fragments</span>.<span class="ruby-identifier">nil?</span>
701
+ 72: <span class="ruby-identifier">scheme</span> = <span class="ruby-identifier">fragments</span>[<span class="ruby-value">1</span>]
702
+ 73: <span class="ruby-identifier">authority</span> = <span class="ruby-identifier">fragments</span>[<span class="ruby-value">3</span>]
703
+ 74: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">fragments</span>[<span class="ruby-value">4</span>]
704
+ 75: <span class="ruby-identifier">query</span> = <span class="ruby-identifier">fragments</span>[<span class="ruby-value">6</span>]
705
+ 76: <span class="ruby-identifier">fragment</span> = <span class="ruby-identifier">fragments</span>[<span class="ruby-value">8</span>]
706
+ 77: <span class="ruby-identifier">userinfo</span> = <span class="ruby-keyword kw">nil</span>
707
+ 78: <span class="ruby-identifier">user</span> = <span class="ruby-keyword kw">nil</span>
708
+ 79: <span class="ruby-identifier">password</span> = <span class="ruby-keyword kw">nil</span>
709
+ 80: <span class="ruby-identifier">host</span> = <span class="ruby-keyword kw">nil</span>
710
+ 81: <span class="ruby-identifier">port</span> = <span class="ruby-keyword kw">nil</span>
711
+ 82: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authority</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
712
+ 83: <span class="ruby-identifier">userinfo</span> = <span class="ruby-identifier">authority</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^([^\[\]]*)@/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
713
+ 84: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">userinfo</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
714
+ 85: <span class="ruby-identifier">user</span> = <span class="ruby-identifier">userinfo</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^([^:]*):?/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
715
+ 86: <span class="ruby-identifier">password</span> = <span class="ruby-identifier">userinfo</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:(.*)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
716
+ 87: <span class="ruby-keyword kw">end</span>
717
+ 88: <span class="ruby-identifier">host</span> = <span class="ruby-identifier">authority</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^([^\[\]]*)@/</span>, <span class="ruby-value str">&quot;&quot;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>, <span class="ruby-value str">&quot;&quot;</span>)
718
+ 89: <span class="ruby-identifier">port</span> = <span class="ruby-identifier">authority</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
719
+ 90: <span class="ruby-keyword kw">end</span>
720
+ 91: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">port</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
721
+ 92: <span class="ruby-identifier">port</span> = <span class="ruby-keyword kw">nil</span>
722
+ 93: <span class="ruby-keyword kw">end</span>
723
+ 94:
724
+ 95: <span class="ruby-comment cmt"># WARNING: Not standards-compliant, but follows the theme</span>
725
+ 96: <span class="ruby-comment cmt"># of Postel's law:</span>
726
+ 97: <span class="ruby-comment cmt">#</span>
727
+ 98: <span class="ruby-comment cmt"># Special exception for dealing with the retarded idea of the</span>
728
+ 99: <span class="ruby-comment cmt"># feed pseudo-protocol. Without this exception, the parser will read</span>
729
+ 100: <span class="ruby-comment cmt"># the URI as having a blank port number, instead of as having a second</span>
730
+ 101: <span class="ruby-comment cmt"># URI embedded within. This exception translates these broken URIs</span>
731
+ 102: <span class="ruby-comment cmt"># and instead treats the inner URI as opaque.</span>
732
+ 103: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;feed&quot;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">host</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;http&quot;</span>
733
+ 104: <span class="ruby-identifier">userinfo</span> = <span class="ruby-keyword kw">nil</span>
734
+ 105: <span class="ruby-identifier">user</span> = <span class="ruby-keyword kw">nil</span>
735
+ 106: <span class="ruby-identifier">password</span> = <span class="ruby-keyword kw">nil</span>
736
+ 107: <span class="ruby-identifier">host</span> = <span class="ruby-keyword kw">nil</span>
737
+ 108: <span class="ruby-identifier">port</span> = <span class="ruby-keyword kw">nil</span>
738
+ 109: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">authority</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">path</span>
739
+ 110: <span class="ruby-keyword kw">end</span>
740
+ 111:
741
+ 112: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
742
+ 113: <span class="ruby-identifier">scheme</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">query</span>, <span class="ruby-identifier">fragment</span>)
743
+ 114: <span class="ruby-keyword kw">end</span>
744
+ </pre>
745
+ </div>
746
+ </div>
747
+ </div>
748
+
749
+ <div id="method-M000024" class="method-detail">
750
+ <a name="M000024"></a>
751
+
752
+ <div class="method-heading">
753
+ <a href="#M000024" class="method-signature">
754
+ <span class="method-name">scheme_mapping</span><span class="method-args">()</span>
755
+ </a>
756
+ </div>
757
+
758
+ <div class="method-description">
759
+ <p>
760
+ Returns a hash of common IP-based schemes and their default <a
761
+ href="URI.html#M000025">port</a> numbers. Adding <a
762
+ href="URI.html#M000010">new</a> schemes to this hash, as necessary, will
763
+ allow for better <a href="URI.html">URI</a> normalization.
764
+ </p>
765
+ <p><a class="source-toggle" href="#"
766
+ onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
767
+ <div class="method-source-code" id="M000024-source">
768
+ <pre>
769
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 548</span>
770
+ 548: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme_mapping</span>
771
+ 549: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@protocol_mapping</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@protocol_mapping</span>.<span class="ruby-identifier">nil?</span>
772
+ 550: <span class="ruby-ivar">@protocol_mapping</span> = {
773
+ 551: <span class="ruby-value str">&quot;http&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">80</span>,
774
+ 552: <span class="ruby-value str">&quot;https&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">443</span>,
775
+ 553: <span class="ruby-value str">&quot;ftp&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">21</span>,
776
+ 554: <span class="ruby-value str">&quot;tftp&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">69</span>,
777
+ 555: <span class="ruby-value str">&quot;ssh&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">22</span>,
778
+ 556: <span class="ruby-value str">&quot;svn+ssh&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">22</span>,
779
+ 557: <span class="ruby-value str">&quot;telnet&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span>,
780
+ 558: <span class="ruby-value str">&quot;nntp&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">119</span>,
781
+ 559: <span class="ruby-value str">&quot;gopher&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">70</span>,
782
+ 560: <span class="ruby-value str">&quot;wais&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">210</span>,
783
+ 561: <span class="ruby-value str">&quot;ldap&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">389</span>,
784
+ 562: <span class="ruby-value str">&quot;prospero&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1525</span>
785
+ 563: }
786
+ 564: <span class="ruby-keyword kw">end</span>
787
+ 565: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@protocol_mapping</span>
788
+ 566: <span class="ruby-keyword kw">end</span>
789
+ </pre>
790
+ </div>
791
+ </div>
792
+ </div>
793
+
794
+ <div id="method-M000006" class="method-detail">
795
+ <a name="M000006"></a>
796
+
797
+ <div class="method-heading">
798
+ <a href="#M000006" class="method-signature">
799
+ <span class="method-name">unencode_segment</span><span class="method-args">(segment)</span>
800
+ </a>
801
+ </div>
802
+
803
+ <div class="method-description">
804
+ <p>
805
+ Unencodes any percent encoded characters within a <a
806
+ href="URI.html">URI</a> segment. Returns a string.
807
+ </p>
808
+ <p><a class="source-toggle" href="#"
809
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
810
+ <div class="method-source-code" id="M000006-source">
811
+ <pre>
812
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 241</span>
813
+ 241: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">segment</span>)
814
+ 242: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">nil?</span>
815
+ 243: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/%[0-9a-f]{2}/i</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sequence</span><span class="ruby-operator">|</span>
816
+ 244: <span class="ruby-identifier">sequence</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>].<span class="ruby-identifier">to_i</span>(<span class="ruby-value">16</span>).<span class="ruby-identifier">chr</span>
817
+ 245: <span class="ruby-keyword kw">end</span>
818
+ 246: <span class="ruby-keyword kw">end</span>
819
+ </pre>
820
+ </div>
821
+ </div>
822
+ </div>
823
+
824
+ <h3 class="section-bar">Public Instance methods</h3>
825
+
826
+ <div id="method-M000039" class="method-detail">
827
+ <a name="M000039"></a>
828
+
829
+ <div class="method-heading">
830
+ <a href="#M000039" class="method-signature">
831
+ <span class="method-name">+</span><span class="method-args">(uri)</span>
832
+ </a>
833
+ </div>
834
+
835
+ <div class="method-description">
836
+ <p>
837
+ Joins two URIs together.
838
+ </p>
839
+ <p><a class="source-toggle" href="#"
840
+ onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
841
+ <div class="method-source-code" id="M000039-source">
842
+ <pre>
843
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 664</span>
844
+ 664: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">uri</span>)
845
+ 665: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>)
846
+ 666: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
847
+ 667: <span class="ruby-keyword kw">end</span>
848
+ 668: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
849
+ 669: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
850
+ 670: <span class="ruby-keyword kw">end</span>
851
+ 671:
852
+ 672: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-keyword kw">nil</span>
853
+ 673: <span class="ruby-identifier">joined_user</span> = <span class="ruby-keyword kw">nil</span>
854
+ 674: <span class="ruby-identifier">joined_password</span> = <span class="ruby-keyword kw">nil</span>
855
+ 675: <span class="ruby-identifier">joined_host</span> = <span class="ruby-keyword kw">nil</span>
856
+ 676: <span class="ruby-identifier">joined_port</span> = <span class="ruby-keyword kw">nil</span>
857
+ 677: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">nil</span>
858
+ 678: <span class="ruby-identifier">joined_query</span> = <span class="ruby-keyword kw">nil</span>
859
+ 679: <span class="ruby-identifier">joined_fragment</span> = <span class="ruby-keyword kw">nil</span>
860
+ 680:
861
+ 681: <span class="ruby-comment cmt"># Section 5.2.2 of RFC 3986</span>
862
+ 682: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
863
+ 683: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>
864
+ 684: <span class="ruby-identifier">joined_user</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>
865
+ 685: <span class="ruby-identifier">joined_password</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>
866
+ 686: <span class="ruby-identifier">joined_host</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>
867
+ 687: <span class="ruby-identifier">joined_port</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">specified_port</span>
868
+ 688: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
869
+ 689: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
870
+ 690: <span class="ruby-keyword kw">else</span>
871
+ 691: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
872
+ 692: <span class="ruby-identifier">joined_user</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>
873
+ 693: <span class="ruby-identifier">joined_password</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>
874
+ 694: <span class="ruby-identifier">joined_host</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>
875
+ 695: <span class="ruby-identifier">joined_port</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">specified_port</span>
876
+ 696: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
877
+ 697: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
878
+ 698: <span class="ruby-keyword kw">else</span>
879
+ 699: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
880
+ 700: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>
881
+ 701: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
882
+ 702: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
883
+ 703: <span class="ruby-keyword kw">else</span>
884
+ 704: <span class="ruby-identifier">joined_query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>
885
+ 705: <span class="ruby-keyword kw">end</span>
886
+ 706: <span class="ruby-keyword kw">else</span>
887
+ 707: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>
888
+ 708: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
889
+ 709: <span class="ruby-keyword kw">else</span>
890
+ 710: <span class="ruby-identifier">base_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span>
891
+ 711: <span class="ruby-identifier">base_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">base_path</span>)
892
+ 712: <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\/[^\/]+$/</span>, <span class="ruby-value str">&quot;/&quot;</span>)
893
+ 713: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">base_path</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
894
+ 714: <span class="ruby-keyword kw">end</span>
895
+ 715: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
896
+ 716: <span class="ruby-keyword kw">end</span>
897
+ 717: <span class="ruby-identifier">joined_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>
898
+ 718: <span class="ruby-identifier">joined_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>
899
+ 719: <span class="ruby-identifier">joined_host</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>
900
+ 720: <span class="ruby-identifier">joined_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span>
901
+ 721: <span class="ruby-keyword kw">end</span>
902
+ 722: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>
903
+ 723: <span class="ruby-keyword kw">end</span>
904
+ 724: <span class="ruby-identifier">joined_fragment</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">fragment</span>
905
+ 725:
906
+ 726: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
907
+ 727: <span class="ruby-identifier">joined_scheme</span>,
908
+ 728: <span class="ruby-identifier">joined_user</span>,
909
+ 729: <span class="ruby-identifier">joined_password</span>,
910
+ 730: <span class="ruby-identifier">joined_host</span>,
911
+ 731: <span class="ruby-identifier">joined_port</span>,
912
+ 732: <span class="ruby-identifier">joined_path</span>,
913
+ 733: <span class="ruby-identifier">joined_query</span>,
914
+ 734: <span class="ruby-identifier">joined_fragment</span>
915
+ 735: )
916
+ 736: <span class="ruby-keyword kw">end</span>
917
+ </pre>
918
+ </div>
919
+ </div>
920
+ </div>
921
+
922
+ <div id="method-M000048" class="method-detail">
923
+ <a name="M000048"></a>
924
+
925
+ <div class="method-heading">
926
+ <a href="#M000048" class="method-signature">
927
+ <span class="method-name">==</span><span class="method-args">(uri)</span>
928
+ </a>
929
+ </div>
930
+
931
+ <div class="method-description">
932
+ <p>
933
+ Returns true if the <a href="URI.html">URI</a> objects are equal. This
934
+ method normalizes both URIs before doing the comparison.
935
+ </p>
936
+ <p><a class="source-toggle" href="#"
937
+ onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
938
+ <div class="method-source-code" id="M000048-source">
939
+ <pre>
940
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 911</span>
941
+ 911: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">uri</span>)
942
+ 912: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>)
943
+ 913: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span>
944
+ 914: <span class="ruby-keyword kw">end</span>
945
+ </pre>
946
+ </div>
947
+ </div>
948
+ </div>
949
+
950
+ <div id="method-M000047" class="method-detail">
951
+ <a name="M000047"></a>
952
+
953
+ <div class="method-heading">
954
+ <a href="#M000047" class="method-signature">
955
+ <span class="method-name">===</span><span class="method-args">(uri)</span>
956
+ </a>
957
+ </div>
958
+
959
+ <div class="method-description">
960
+ <p>
961
+ Returns true if the <a href="URI.html">URI</a> objects are equal. This
962
+ method normalizes both URIs before doing the comparison, and allows
963
+ comparison against strings.
964
+ </p>
965
+ <p><a class="source-toggle" href="#"
966
+ onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
967
+ <div class="method-source-code" id="M000047-source">
968
+ <pre>
969
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 895</span>
970
+ 895: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">uri</span>)
971
+ 896: <span class="ruby-identifier">uri_string</span> = <span class="ruby-keyword kw">nil</span>
972
+ 897: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:normalize</span>)
973
+ 898: <span class="ruby-identifier">uri_string</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span>
974
+ 899: <span class="ruby-keyword kw">else</span>
975
+ 900: <span class="ruby-keyword kw">begin</span>
976
+ 901: <span class="ruby-identifier">uri_string</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span>
977
+ 902: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
978
+ 903: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
979
+ 904: <span class="ruby-keyword kw">end</span>
980
+ 905: <span class="ruby-keyword kw">end</span>
981
+ 906: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri_string</span>
982
+ 907: <span class="ruby-keyword kw">end</span>
983
+ </pre>
984
+ </div>
985
+ </div>
986
+ </div>
987
+
988
+ <div id="method-M000038" class="method-detail">
989
+ <a name="M000038"></a>
990
+
991
+ <div class="method-heading">
992
+ <a href="#M000038" class="method-signature">
993
+ <span class="method-name">absolute?</span><span class="method-args">()</span>
994
+ </a>
995
+ </div>
996
+
997
+ <div class="method-description">
998
+ <p>
999
+ Returns true if this <a href="URI.html">URI</a> is known to be absolute.
1000
+ </p>
1001
+ <p><a class="source-toggle" href="#"
1002
+ onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
1003
+ <div class="method-source-code" id="M000038-source">
1004
+ <pre>
1005
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 659</span>
1006
+ 659: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">absolute?</span>
1007
+ 660: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-identifier">relative?</span>
1008
+ 661: <span class="ruby-keyword kw">end</span>
1009
+ </pre>
1010
+ </div>
1011
+ </div>
1012
+ </div>
1013
+
1014
+ <div id="method-M000021" class="method-detail">
1015
+ <a name="M000021"></a>
1016
+
1017
+ <div class="method-heading">
1018
+ <a href="#M000021" class="method-signature">
1019
+ <span class="method-name">authority</span><span class="method-args">()</span>
1020
+ </a>
1021
+ </div>
1022
+
1023
+ <div class="method-description">
1024
+ <p>
1025
+ Returns the <a href="URI.html#M000021">authority</a> segment of this <a
1026
+ href="URI.html">URI</a>.
1027
+ </p>
1028
+ <p><a class="source-toggle" href="#"
1029
+ onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
1030
+ <div class="method-source-code" id="M000021-source">
1031
+ <pre>
1032
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 495</span>
1033
+ 495: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authority</span>
1034
+ 496: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@authority</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@authority</span>.<span class="ruby-identifier">nil?</span>
1035
+ 497: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">nil?</span>
1036
+ 498: <span class="ruby-ivar">@authority</span> = <span class="ruby-value str">&quot;&quot;</span>
1037
+ 499: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">userinfo</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1038
+ 500: <span class="ruby-ivar">@authority</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{self.userinfo}@&quot;</span>
1039
+ 501: <span class="ruby-keyword kw">end</span>
1040
+ 502: <span class="ruby-ivar">@authority</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>
1041
+ 503: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1042
+ 504: <span class="ruby-ivar">@authority</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;:#{self.specified_port}&quot;</span>
1043
+ 505: <span class="ruby-keyword kw">end</span>
1044
+ 506: <span class="ruby-keyword kw">end</span>
1045
+ 507: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@authority</span>
1046
+ 508: <span class="ruby-keyword kw">end</span>
1047
+ </pre>
1048
+ </div>
1049
+ </div>
1050
+ </div>
1051
+
1052
+ <div id="method-M000022" class="method-detail">
1053
+ <a name="M000022"></a>
1054
+
1055
+ <div class="method-heading">
1056
+ <a href="#M000022" class="method-signature">
1057
+ <span class="method-name">authority=</span><span class="method-args">(new_authority)</span>
1058
+ </a>
1059
+ </div>
1060
+
1061
+ <div class="method-description">
1062
+ <p>
1063
+ Sets the <a href="URI.html#M000021">authority</a> segment of this <a
1064
+ href="URI.html">URI</a>.
1065
+ </p>
1066
+ <p><a class="source-toggle" href="#"
1067
+ onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
1068
+ <div class="method-source-code" id="M000022-source">
1069
+ <pre>
1070
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 511</span>
1071
+ 511: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authority=</span>(<span class="ruby-identifier">new_authority</span>)
1072
+ 512: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_authority</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1073
+ 513: <span class="ruby-identifier">new_userinfo</span> = <span class="ruby-identifier">new_authority</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^([^\[\]]*)@/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
1074
+ 514: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_userinfo</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1075
+ 515: <span class="ruby-identifier">new_user</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^([^:]*):?/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
1076
+ 516: <span class="ruby-identifier">new_password</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:(.*)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
1077
+ 517: <span class="ruby-keyword kw">end</span>
1078
+ 518: <span class="ruby-identifier">new_host</span> =
1079
+ 519: <span class="ruby-identifier">new_authority</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^([^\[\]]*)@/</span>, <span class="ruby-value str">&quot;&quot;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>, <span class="ruby-value str">&quot;&quot;</span>)
1080
+ 520: <span class="ruby-identifier">new_port</span> =
1081
+ 521: <span class="ruby-identifier">new_authority</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
1082
+ 522: <span class="ruby-keyword kw">end</span>
1083
+ 523: <span class="ruby-identifier">new_port</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_port</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
1084
+ 524:
1085
+ 525: <span class="ruby-comment cmt"># Password assigned first to ensure validity in case of nil</span>
1086
+ 526: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-identifier">new_password</span>
1087
+ 527: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">new_user</span>
1088
+ 528: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span> = <span class="ruby-identifier">new_host</span>
1089
+ 529:
1090
+ 530: <span class="ruby-comment cmt"># Port reset to allow port normalization</span>
1091
+ 531: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span>
1092
+ 532: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-identifier">new_port</span>
1093
+ 533:
1094
+ 534: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
1095
+ 535: <span class="ruby-identifier">validate</span>()
1096
+ 536: <span class="ruby-keyword kw">end</span>
1097
+ </pre>
1098
+ </div>
1099
+ </div>
1100
+ </div>
1101
+
1102
+ <div id="method-M000030" class="method-detail">
1103
+ <a name="M000030"></a>
1104
+
1105
+ <div class="method-heading">
1106
+ <a href="#M000030" class="method-signature">
1107
+ <span class="method-name">basename</span><span class="method-args">()</span>
1108
+ </a>
1109
+ </div>
1110
+
1111
+ <div class="method-description">
1112
+ <p>
1113
+ Returns the <a href="URI.html#M000030">basename</a>, if any, of the file at
1114
+ the <a href="URI.html#M000028">path</a> being referenced. Returns nil if
1115
+ there is no <a href="URI.html#M000028">path</a> component.
1116
+ </p>
1117
+ <p><a class="source-toggle" href="#"
1118
+ onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
1119
+ <div class="method-source-code" id="M000030-source">
1120
+ <pre>
1121
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 614</span>
1122
+ 614: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">basename</span>
1123
+ 615: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
1124
+ 616: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/;[^\/]*$/</span>, <span class="ruby-value str">&quot;&quot;</span>)
1125
+ 617: <span class="ruby-keyword kw">end</span>
1126
+ </pre>
1127
+ </div>
1128
+ </div>
1129
+ </div>
1130
+
1131
+ <div id="method-M000046" class="method-detail">
1132
+ <a name="M000046"></a>
1133
+
1134
+ <div class="method-heading">
1135
+ <a href="#M000046" class="method-signature">
1136
+ <span class="method-name">display_uri</span><span class="method-args">()</span>
1137
+ </a>
1138
+ </div>
1139
+
1140
+ <div class="method-description">
1141
+ <p>
1142
+ Creates a <a href="URI.html">URI</a> suitable for display to users. If
1143
+ semantic attacks are likely, the application should try to detect these and
1144
+ warn the <a href="URI.html#M000013">user</a>. See RFC 3986 section 7.6 for
1145
+ more information.
1146
+ </p>
1147
+ <p><a class="source-toggle" href="#"
1148
+ onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
1149
+ <div class="method-source-code" id="M000046-source">
1150
+ <pre>
1151
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 881</span>
1152
+ 881: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_uri</span>
1153
+ 882: <span class="ruby-identifier">display_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>
1154
+ 883: <span class="ruby-keyword kw">begin</span>
1155
+ 884: <span class="ruby-identifier">display_uri</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-value str">&quot;@host&quot;</span>,
1156
+ 885: <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">IDNA</span>.<span class="ruby-identifier">to_unicode</span>(<span class="ruby-identifier">display_uri</span>.<span class="ruby-identifier">host</span>))
1157
+ 886: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
1158
+ 887: <span class="ruby-keyword kw">nil</span>
1159
+ 888: <span class="ruby-keyword kw">end</span>
1160
+ 889: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">display_uri</span>
1161
+ 890: <span class="ruby-keyword kw">end</span>
1162
+ </pre>
1163
+ </div>
1164
+ </div>
1165
+ </div>
1166
+
1167
+ <div id="method-M000050" class="method-detail">
1168
+ <a name="M000050"></a>
1169
+
1170
+ <div class="method-heading">
1171
+ <a href="#M000050" class="method-signature">
1172
+ <span class="method-name">dup</span><span class="method-args">()</span>
1173
+ </a>
1174
+ </div>
1175
+
1176
+ <div class="method-description">
1177
+ <p>
1178
+ Clones the <a href="URI.html">URI</a> object.
1179
+ </p>
1180
+ <p><a class="source-toggle" href="#"
1181
+ onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
1182
+ <div class="method-source-code" id="M000050-source">
1183
+ <pre>
1184
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 924</span>
1185
+ 924: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dup</span>
1186
+ 925: <span class="ruby-identifier">duplicated_scheme</span> = <span class="ruby-keyword kw">nil</span>
1187
+ 926: <span class="ruby-identifier">duplicated_scheme</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1188
+ 927: <span class="ruby-identifier">duplicated_user</span> = <span class="ruby-keyword kw">nil</span>
1189
+ 928: <span class="ruby-identifier">duplicated_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1190
+ 929: <span class="ruby-identifier">duplicated_password</span> = <span class="ruby-keyword kw">nil</span>
1191
+ 930: <span class="ruby-identifier">duplicated_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1192
+ 931: <span class="ruby-identifier">duplicated_host</span> = <span class="ruby-keyword kw">nil</span>
1193
+ 932: <span class="ruby-identifier">duplicated_host</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1194
+ 933: <span class="ruby-identifier">duplicated_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">port</span>
1195
+ 934: <span class="ruby-identifier">duplicated_path</span> = <span class="ruby-keyword kw">nil</span>
1196
+ 935: <span class="ruby-identifier">duplicated_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1197
+ 936: <span class="ruby-identifier">duplicated_query</span> = <span class="ruby-keyword kw">nil</span>
1198
+ 937: <span class="ruby-identifier">duplicated_query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1199
+ 938: <span class="ruby-identifier">duplicated_fragment</span> = <span class="ruby-keyword kw">nil</span>
1200
+ 939: <span class="ruby-identifier">duplicated_fragment</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1201
+ 940: <span class="ruby-identifier">duplicated_uri</span> = <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
1202
+ 941: <span class="ruby-identifier">duplicated_scheme</span>,
1203
+ 942: <span class="ruby-identifier">duplicated_user</span>,
1204
+ 943: <span class="ruby-identifier">duplicated_password</span>,
1205
+ 944: <span class="ruby-identifier">duplicated_host</span>,
1206
+ 945: <span class="ruby-identifier">duplicated_port</span>,
1207
+ 946: <span class="ruby-identifier">duplicated_path</span>,
1208
+ 947: <span class="ruby-identifier">duplicated_query</span>,
1209
+ 948: <span class="ruby-identifier">duplicated_fragment</span>
1210
+ 949: )
1211
+ 950: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@specified_port</span>)
1212
+ 951: <span class="ruby-identifier">duplicated_uri</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-value str">&quot;@specified_port&quot;</span>, <span class="ruby-ivar">@specified_port</span>)
1213
+ 952: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">duplicated_uri</span>
1214
+ 953: <span class="ruby-keyword kw">end</span>
1215
+ </pre>
1216
+ </div>
1217
+ </div>
1218
+ </div>
1219
+
1220
+ <div id="method-M000049" class="method-detail">
1221
+ <a name="M000049"></a>
1222
+
1223
+ <div class="method-heading">
1224
+ <a href="#M000049" class="method-signature">
1225
+ <span class="method-name">eql?</span><span class="method-args">(uri)</span>
1226
+ </a>
1227
+ </div>
1228
+
1229
+ <div class="method-description">
1230
+ <p>
1231
+ Returns true if the <a href="URI.html">URI</a> objects are equal. This
1232
+ method does NOT <a href="URI.html#M000044">normalize</a> either <a
1233
+ href="URI.html">URI</a> before doing the comparison.
1234
+ </p>
1235
+ <p><a class="source-toggle" href="#"
1236
+ onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
1237
+ <div class="method-source-code" id="M000049-source">
1238
+ <pre>
1239
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 918</span>
1240
+ 918: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eql?</span>(<span class="ruby-identifier">uri</span>)
1241
+ 919: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>)
1242
+ 920: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>
1243
+ 921: <span class="ruby-keyword kw">end</span>
1244
+ </pre>
1245
+ </div>
1246
+ </div>
1247
+ </div>
1248
+
1249
+ <div id="method-M000031" class="method-detail">
1250
+ <a name="M000031"></a>
1251
+
1252
+ <div class="method-heading">
1253
+ <a href="#M000031" class="method-signature">
1254
+ <span class="method-name">extname</span><span class="method-args">()</span>
1255
+ </a>
1256
+ </div>
1257
+
1258
+ <div class="method-description">
1259
+ <p>
1260
+ Returns the extension, if any, of the file at the <a
1261
+ href="URI.html#M000028">path</a> being referenced. Returns &quot;&quot; if
1262
+ there is no extension or nil if there is no <a
1263
+ href="URI.html#M000028">path</a> component.
1264
+ </p>
1265
+ <p><a class="source-toggle" href="#"
1266
+ onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
1267
+ <div class="method-source-code" id="M000031-source">
1268
+ <pre>
1269
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 622</span>
1270
+ 622: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extname</span>
1271
+ 623: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
1272
+ 624: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">basename</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/;[^\/]*$/</span>, <span class="ruby-value str">&quot;&quot;</span>))
1273
+ 625: <span class="ruby-keyword kw">end</span>
1274
+ </pre>
1275
+ </div>
1276
+ </div>
1277
+ </div>
1278
+
1279
+ <div id="method-M000034" class="method-detail">
1280
+ <a name="M000034"></a>
1281
+
1282
+ <div class="method-heading">
1283
+ <a href="#M000034" class="method-signature">
1284
+ <span class="method-name">fragment</span><span class="method-args">()</span>
1285
+ </a>
1286
+ </div>
1287
+
1288
+ <div class="method-description">
1289
+ <p>
1290
+ Returns the <a href="URI.html#M000034">fragment</a> for this <a
1291
+ href="URI.html">URI</a>.
1292
+ </p>
1293
+ <p><a class="source-toggle" href="#"
1294
+ onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
1295
+ <div class="method-source-code" id="M000034-source">
1296
+ <pre>
1297
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 638</span>
1298
+ 638: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fragment</span>
1299
+ 639: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@fragment</span>
1300
+ 640: <span class="ruby-keyword kw">end</span>
1301
+ </pre>
1302
+ </div>
1303
+ </div>
1304
+ </div>
1305
+
1306
+ <div id="method-M000035" class="method-detail">
1307
+ <a name="M000035"></a>
1308
+
1309
+ <div class="method-heading">
1310
+ <a href="#M000035" class="method-signature">
1311
+ <span class="method-name">fragment=</span><span class="method-args">(new_fragment)</span>
1312
+ </a>
1313
+ </div>
1314
+
1315
+ <div class="method-description">
1316
+ <p>
1317
+ Sets the <a href="URI.html#M000034">fragment</a> for this <a
1318
+ href="URI.html">URI</a>.
1319
+ </p>
1320
+ <p><a class="source-toggle" href="#"
1321
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
1322
+ <div class="method-source-code" id="M000035-source">
1323
+ <pre>
1324
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 643</span>
1325
+ 643: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fragment=</span>(<span class="ruby-identifier">new_fragment</span>)
1326
+ 644: <span class="ruby-ivar">@fragment</span> = <span class="ruby-identifier">new_fragment</span>
1327
+ 645: <span class="ruby-keyword kw">end</span>
1328
+ </pre>
1329
+ </div>
1330
+ </div>
1331
+ </div>
1332
+
1333
+ <div id="method-M000019" class="method-detail">
1334
+ <a name="M000019"></a>
1335
+
1336
+ <div class="method-heading">
1337
+ <a href="#M000019" class="method-signature">
1338
+ <span class="method-name">host</span><span class="method-args">()</span>
1339
+ </a>
1340
+ </div>
1341
+
1342
+ <div class="method-description">
1343
+ <p>
1344
+ Returns the <a href="URI.html#M000019">host</a> for this <a
1345
+ href="URI.html">URI</a>.
1346
+ </p>
1347
+ <p><a class="source-toggle" href="#"
1348
+ onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
1349
+ <div class="method-source-code" id="M000019-source">
1350
+ <pre>
1351
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 479</span>
1352
+ 479: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">host</span>
1353
+ 480: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@host</span>
1354
+ 481: <span class="ruby-keyword kw">end</span>
1355
+ </pre>
1356
+ </div>
1357
+ </div>
1358
+ </div>
1359
+
1360
+ <div id="method-M000020" class="method-detail">
1361
+ <a name="M000020"></a>
1362
+
1363
+ <div class="method-heading">
1364
+ <a href="#M000020" class="method-signature">
1365
+ <span class="method-name">host=</span><span class="method-args">(new_host)</span>
1366
+ </a>
1367
+ </div>
1368
+
1369
+ <div class="method-description">
1370
+ <p>
1371
+ Sets the <a href="URI.html#M000019">host</a> for this <a
1372
+ href="URI.html">URI</a>.
1373
+ </p>
1374
+ <p><a class="source-toggle" href="#"
1375
+ onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
1376
+ <div class="method-source-code" id="M000020-source">
1377
+ <pre>
1378
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 484</span>
1379
+ 484: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">host=</span>(<span class="ruby-identifier">new_host</span>)
1380
+ 485: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">new_host</span>
1381
+ 486:
1382
+ 487: <span class="ruby-comment cmt"># Reset dependant values</span>
1383
+ 488: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
1384
+ 489:
1385
+ 490: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
1386
+ 491: <span class="ruby-identifier">validate</span>()
1387
+ 492: <span class="ruby-keyword kw">end</span>
1388
+ </pre>
1389
+ </div>
1390
+ </div>
1391
+ </div>
1392
+
1393
+ <div id="method-M000053" class="method-detail">
1394
+ <a name="M000053"></a>
1395
+
1396
+ <div class="method-heading">
1397
+ <a href="#M000053" class="method-signature">
1398
+ <span class="method-name">inspect</span><span class="method-args">()</span>
1399
+ </a>
1400
+ </div>
1401
+
1402
+ <div class="method-description">
1403
+ <p>
1404
+ Returns a string representation of the <a href="URI.html">URI</a>
1405
+ object&#8216;s state.
1406
+ </p>
1407
+ <p><a class="source-toggle" href="#"
1408
+ onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
1409
+ <div class="method-source-code" id="M000053-source">
1410
+ <pre>
1411
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 981</span>
1412
+ 981: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
1413
+ 982: <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">&quot;#&lt;%s:%#0x URI:%s&gt;&quot;</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object_id</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>)
1414
+ 983: <span class="ruby-keyword kw">end</span>
1415
+ </pre>
1416
+ </div>
1417
+ </div>
1418
+ </div>
1419
+
1420
+ <div id="method-M000036" class="method-detail">
1421
+ <a name="M000036"></a>
1422
+
1423
+ <div class="method-heading">
1424
+ <a href="#M000036" class="method-signature">
1425
+ <span class="method-name">ip_based?</span><span class="method-args">()</span>
1426
+ </a>
1427
+ </div>
1428
+
1429
+ <div class="method-description">
1430
+ <p>
1431
+ Returns true if the <a href="URI.html">URI</a> uses an IP-based protocol.
1432
+ </p>
1433
+ <p><a class="source-toggle" href="#"
1434
+ onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
1435
+ <div class="method-source-code" id="M000036-source">
1436
+ <pre>
1437
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 648</span>
1438
+ 648: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ip_based?</span>
1439
+ 649: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">nil?</span>
1440
+ 650: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">ip_based_schemes</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>)
1441
+ 651: <span class="ruby-keyword kw">end</span>
1442
+ </pre>
1443
+ </div>
1444
+ </div>
1445
+ </div>
1446
+
1447
+ <div id="method-M000040" class="method-detail">
1448
+ <a name="M000040"></a>
1449
+
1450
+ <div class="method-heading">
1451
+ <a href="#M000040" class="method-signature">
1452
+ <span class="method-name">merge</span><span class="method-args">(uri)</span>
1453
+ </a>
1454
+ </div>
1455
+
1456
+ <div class="method-description">
1457
+ <p>
1458
+ Merges two URIs together.
1459
+ </p>
1460
+ <p><a class="source-toggle" href="#"
1461
+ onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
1462
+ <div class="method-source-code" id="M000040-source">
1463
+ <pre>
1464
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 739</span>
1465
+ 739: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">uri</span>)
1466
+ 740: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">uri</span>
1467
+ 741: <span class="ruby-keyword kw">end</span>
1468
+ </pre>
1469
+ </div>
1470
+ </div>
1471
+ </div>
1472
+
1473
+ <div id="method-M000041" class="method-detail">
1474
+ <a name="M000041"></a>
1475
+
1476
+ <div class="method-heading">
1477
+ <a href="#M000041" class="method-signature">
1478
+ <span class="method-name">merge!</span><span class="method-args">(uri)</span>
1479
+ </a>
1480
+ </div>
1481
+
1482
+ <div class="method-description">
1483
+ <p>
1484
+ Destructive form of <a href="URI.html#M000040">merge</a>.
1485
+ </p>
1486
+ <p><a class="source-toggle" href="#"
1487
+ onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
1488
+ <div class="method-source-code" id="M000041-source">
1489
+ <pre>
1490
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 744</span>
1491
+ 744: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">uri</span>)
1492
+ 745: <span class="ruby-identifier">replace_self</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">uri</span>))
1493
+ 746: <span class="ruby-keyword kw">end</span>
1494
+ </pre>
1495
+ </div>
1496
+ </div>
1497
+ </div>
1498
+
1499
+ <div id="method-M000044" class="method-detail">
1500
+ <a name="M000044"></a>
1501
+
1502
+ <div class="method-heading">
1503
+ <a href="#M000044" class="method-signature">
1504
+ <span class="method-name">normalize</span><span class="method-args">()</span>
1505
+ </a>
1506
+ </div>
1507
+
1508
+ <div class="method-description">
1509
+ <p>
1510
+ Returns a normalized <a href="URI.html">URI</a> object.
1511
+ </p>
1512
+ <p>
1513
+ NOTE: This method does not attempt to fully conform to specifications. It
1514
+ exists largely to correct other people&#8216;s failures to read the
1515
+ specifications, and also to deal with caching issues since several
1516
+ different URIs may represent the same resource and should not be cached
1517
+ multiple times.
1518
+ </p>
1519
+ <p><a class="source-toggle" href="#"
1520
+ onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
1521
+ <div class="method-source-code" id="M000044-source">
1522
+ <pre>
1523
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 811</span>
1524
+ 811: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalize</span>
1525
+ 812: <span class="ruby-identifier">normalized_scheme</span> = <span class="ruby-keyword kw">nil</span>
1526
+ 813: <span class="ruby-identifier">normalized_scheme</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1527
+ 814: <span class="ruby-identifier">normalized_scheme</span> = <span class="ruby-value str">&quot;svn+ssh&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;ssh+svn&quot;</span>
1528
+ 815: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;feed&quot;</span>
1529
+ 816: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^feed:\/*http:\/*/</span>
1530
+ 817: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parse</span>(
1531
+ 818: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^feed:\/*(http:\/*.*)/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">normalize</span>
1532
+ 819: <span class="ruby-keyword kw">end</span>
1533
+ 820: <span class="ruby-keyword kw">end</span>
1534
+ 821: <span class="ruby-identifier">normalized_user</span> = <span class="ruby-keyword kw">nil</span>
1535
+ 822: <span class="ruby-identifier">normalized_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1536
+ 823: <span class="ruby-identifier">normalized_password</span> = <span class="ruby-keyword kw">nil</span>
1537
+ 824: <span class="ruby-identifier">normalized_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1538
+ 825: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-keyword kw">nil</span>
1539
+ 826: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1540
+ 827: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_host</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1541
+ 828: <span class="ruby-keyword kw">begin</span>
1542
+ 829: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">IDNA</span>.<span class="ruby-identifier">to_ascii</span>(<span class="ruby-identifier">normalized_host</span>)
1543
+ 830: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
1544
+ 831: <span class="ruby-keyword kw">nil</span>
1545
+ 832: <span class="ruby-keyword kw">end</span>
1546
+ 833: <span class="ruby-keyword kw">end</span>
1547
+ 834:
1548
+ 835: <span class="ruby-identifier">normalized_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">port</span>
1549
+ 836: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">scheme_mapping</span>[<span class="ruby-identifier">normalized_scheme</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">normalized_port</span>
1550
+ 837: <span class="ruby-identifier">normalized_port</span> = <span class="ruby-keyword kw">nil</span>
1551
+ 838: <span class="ruby-keyword kw">end</span>
1552
+ 839: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-keyword kw">nil</span>
1553
+ 840: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1554
+ 841: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_path</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span>
1555
+ 842: <span class="ruby-identifier">normalized_scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span>
1556
+ 843: <span class="ruby-identifier">normalized_host</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1557
+ 844: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-value str">&quot;/&quot;</span>
1558
+ 845: <span class="ruby-keyword kw">end</span>
1559
+ 846: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_path</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1560
+ 847: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">normalized_path</span>)
1561
+ 848: <span class="ruby-keyword kw">end</span>
1562
+ 849: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_path</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
1563
+ 850: <span class="ruby-keyword kw">if</span> [<span class="ruby-value str">&quot;http&quot;</span>, <span class="ruby-value str">&quot;https&quot;</span>, <span class="ruby-value str">&quot;ftp&quot;</span>, <span class="ruby-value str">&quot;tftp&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">normalized_scheme</span>)
1564
+ 851: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-value str">&quot;/&quot;</span>
1565
+ 852: <span class="ruby-keyword kw">end</span>
1566
+ 853: <span class="ruby-keyword kw">end</span>
1567
+ 854:
1568
+ 855: <span class="ruby-identifier">normalized_query</span> = <span class="ruby-keyword kw">nil</span>
1569
+ 856: <span class="ruby-identifier">normalized_query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1570
+ 857:
1571
+ 858: <span class="ruby-identifier">normalized_fragment</span> = <span class="ruby-keyword kw">nil</span>
1572
+ 859: <span class="ruby-identifier">normalized_fragment</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1573
+ 860: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(
1574
+ 861: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">normalized_encode</span>(<span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
1575
+ 862: <span class="ruby-identifier">normalized_scheme</span>,
1576
+ 863: <span class="ruby-identifier">normalized_user</span>,
1577
+ 864: <span class="ruby-identifier">normalized_password</span>,
1578
+ 865: <span class="ruby-identifier">normalized_host</span>,
1579
+ 866: <span class="ruby-identifier">normalized_port</span>,
1580
+ 867: <span class="ruby-identifier">normalized_path</span>,
1581
+ 868: <span class="ruby-identifier">normalized_query</span>,
1582
+ 869: <span class="ruby-identifier">normalized_fragment</span>
1583
+ 870: )))
1584
+ 871: <span class="ruby-keyword kw">end</span>
1585
+ </pre>
1586
+ </div>
1587
+ </div>
1588
+ </div>
1589
+
1590
+ <div id="method-M000045" class="method-detail">
1591
+ <a name="M000045"></a>
1592
+
1593
+ <div class="method-heading">
1594
+ <a href="#M000045" class="method-signature">
1595
+ <span class="method-name">normalize!</span><span class="method-args">()</span>
1596
+ </a>
1597
+ </div>
1598
+
1599
+ <div class="method-description">
1600
+ <p>
1601
+ Destructively normalizes this <a href="URI.html">URI</a> object.
1602
+ </p>
1603
+ <p><a class="source-toggle" href="#"
1604
+ onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
1605
+ <div class="method-source-code" id="M000045-source">
1606
+ <pre>
1607
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 874</span>
1608
+ 874: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalize!</span>
1609
+ 875: <span class="ruby-identifier">replace_self</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>)
1610
+ 876: <span class="ruby-keyword kw">end</span>
1611
+ </pre>
1612
+ </div>
1613
+ </div>
1614
+ </div>
1615
+
1616
+ <div id="method-M000015" class="method-detail">
1617
+ <a name="M000015"></a>
1618
+
1619
+ <div class="method-heading">
1620
+ <a href="#M000015" class="method-signature">
1621
+ <span class="method-name">password</span><span class="method-args">()</span>
1622
+ </a>
1623
+ </div>
1624
+
1625
+ <div class="method-description">
1626
+ <p>
1627
+ Returns the <a href="URI.html#M000015">password</a> for this <a
1628
+ href="URI.html">URI</a>.
1629
+ </p>
1630
+ <p><a class="source-toggle" href="#"
1631
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
1632
+ <div class="method-source-code" id="M000015-source">
1633
+ <pre>
1634
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 425</span>
1635
+ 425: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">password</span>
1636
+ 426: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@password</span>
1637
+ 427: <span class="ruby-keyword kw">end</span>
1638
+ </pre>
1639
+ </div>
1640
+ </div>
1641
+ </div>
1642
+
1643
+ <div id="method-M000016" class="method-detail">
1644
+ <a name="M000016"></a>
1645
+
1646
+ <div class="method-heading">
1647
+ <a href="#M000016" class="method-signature">
1648
+ <span class="method-name">password=</span><span class="method-args">(new_password)</span>
1649
+ </a>
1650
+ </div>
1651
+
1652
+ <div class="method-description">
1653
+ <p>
1654
+ Sets the <a href="URI.html#M000015">password</a> for this <a
1655
+ href="URI.html">URI</a>.
1656
+ </p>
1657
+ <p><a class="source-toggle" href="#"
1658
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
1659
+ <div class="method-source-code" id="M000016-source">
1660
+ <pre>
1661
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 430</span>
1662
+ 430: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">password=</span>(<span class="ruby-identifier">new_password</span>)
1663
+ 431: <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">new_password</span>
1664
+ 432:
1665
+ 433: <span class="ruby-comment cmt"># You can't have a nil user with a non-nil password</span>
1666
+ 434: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1667
+ 435: <span class="ruby-ivar">@user</span> = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">nil?</span>
1668
+ 436: <span class="ruby-keyword kw">end</span>
1669
+ 437:
1670
+ 438: <span class="ruby-comment cmt"># Reset dependant values</span>
1671
+ 439: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
1672
+ 440: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
1673
+ 441:
1674
+ 442: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
1675
+ 443: <span class="ruby-identifier">validate</span>()
1676
+ 444: <span class="ruby-keyword kw">end</span>
1677
+ </pre>
1678
+ </div>
1679
+ </div>
1680
+ </div>
1681
+
1682
+ <div id="method-M000028" class="method-detail">
1683
+ <a name="M000028"></a>
1684
+
1685
+ <div class="method-heading">
1686
+ <a href="#M000028" class="method-signature">
1687
+ <span class="method-name">path</span><span class="method-args">()</span>
1688
+ </a>
1689
+ </div>
1690
+
1691
+ <div class="method-description">
1692
+ <p>
1693
+ Returns the <a href="URI.html#M000028">path</a> for this <a
1694
+ href="URI.html">URI</a>.
1695
+ </p>
1696
+ <p><a class="source-toggle" href="#"
1697
+ onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
1698
+ <div class="method-source-code" id="M000028-source">
1699
+ <pre>
1700
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 603</span>
1701
+ 603: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path</span>
1702
+ 604: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@path</span>
1703
+ 605: <span class="ruby-keyword kw">end</span>
1704
+ </pre>
1705
+ </div>
1706
+ </div>
1707
+ </div>
1708
+
1709
+ <div id="method-M000029" class="method-detail">
1710
+ <a name="M000029"></a>
1711
+
1712
+ <div class="method-heading">
1713
+ <a href="#M000029" class="method-signature">
1714
+ <span class="method-name">path=</span><span class="method-args">(new_path)</span>
1715
+ </a>
1716
+ </div>
1717
+
1718
+ <div class="method-description">
1719
+ <p>
1720
+ Sets the <a href="URI.html#M000028">path</a> for this <a
1721
+ href="URI.html">URI</a>.
1722
+ </p>
1723
+ <p><a class="source-toggle" href="#"
1724
+ onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
1725
+ <div class="method-source-code" id="M000029-source">
1726
+ <pre>
1727
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 608</span>
1728
+ 608: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path=</span>(<span class="ruby-identifier">new_path</span>)
1729
+ 609: <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">new_path</span>
1730
+ 610: <span class="ruby-keyword kw">end</span>
1731
+ </pre>
1732
+ </div>
1733
+ </div>
1734
+ </div>
1735
+
1736
+ <div id="method-M000025" class="method-detail">
1737
+ <a name="M000025"></a>
1738
+
1739
+ <div class="method-heading">
1740
+ <a href="#M000025" class="method-signature">
1741
+ <span class="method-name">port</span><span class="method-args">()</span>
1742
+ </a>
1743
+ </div>
1744
+
1745
+ <div class="method-description">
1746
+ <p>
1747
+ Returns the <a href="URI.html#M000025">port</a> number for this <a
1748
+ href="URI.html">URI</a>. This method will <a
1749
+ href="URI.html#M000044">normalize</a> to the default <a
1750
+ href="URI.html#M000025">port</a> for the <a href="URI.html">URI</a>&#8216;s
1751
+ <a href="URI.html#M000011">scheme</a> if the <a
1752
+ href="URI.html#M000025">port</a> isn&#8216;t explicitly specified in the <a
1753
+ href="URI.html">URI</a>.
1754
+ </p>
1755
+ <p><a class="source-toggle" href="#"
1756
+ onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
1757
+ <div class="method-source-code" id="M000025-source">
1758
+ <pre>
1759
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 571</span>
1760
+ 571: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">port</span>
1761
+ 572: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
1762
+ 573: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">nil?</span>
1763
+ 574: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span>
1764
+ 575: <span class="ruby-keyword kw">else</span>
1765
+ 576: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">scheme_mapping</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>]
1766
+ 577: <span class="ruby-keyword kw">end</span>
1767
+ 578: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@port</span>
1768
+ 579: <span class="ruby-keyword kw">else</span>
1769
+ 580: <span class="ruby-ivar">@port</span> = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span>
1770
+ 581: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@port</span>
1771
+ 582: <span class="ruby-keyword kw">end</span>
1772
+ 583: <span class="ruby-keyword kw">end</span>
1773
+ </pre>
1774
+ </div>
1775
+ </div>
1776
+ </div>
1777
+
1778
+ <div id="method-M000026" class="method-detail">
1779
+ <a name="M000026"></a>
1780
+
1781
+ <div class="method-heading">
1782
+ <a href="#M000026" class="method-signature">
1783
+ <span class="method-name">port=</span><span class="method-args">(new_port)</span>
1784
+ </a>
1785
+ </div>
1786
+
1787
+ <div class="method-description">
1788
+ <p>
1789
+ Sets the <a href="URI.html#M000025">port</a> for this <a
1790
+ href="URI.html">URI</a>.
1791
+ </p>
1792
+ <p><a class="source-toggle" href="#"
1793
+ onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
1794
+ <div class="method-source-code" id="M000026-source">
1795
+ <pre>
1796
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 586</span>
1797
+ 586: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">port=</span>(<span class="ruby-identifier">new_port</span>)
1798
+ 587: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">new_port</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_i</span>
1799
+ 588: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-ivar">@port</span>
1800
+ 589: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
1801
+ 590: <span class="ruby-keyword kw">end</span>
1802
+ </pre>
1803
+ </div>
1804
+ </div>
1805
+ </div>
1806
+
1807
+ <div id="method-M000032" class="method-detail">
1808
+ <a name="M000032"></a>
1809
+
1810
+ <div class="method-heading">
1811
+ <a href="#M000032" class="method-signature">
1812
+ <span class="method-name">query</span><span class="method-args">()</span>
1813
+ </a>
1814
+ </div>
1815
+
1816
+ <div class="method-description">
1817
+ <p>
1818
+ Returns the <a href="URI.html#M000032">query</a> string for this <a
1819
+ href="URI.html">URI</a>.
1820
+ </p>
1821
+ <p><a class="source-toggle" href="#"
1822
+ onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
1823
+ <div class="method-source-code" id="M000032-source">
1824
+ <pre>
1825
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 628</span>
1826
+ 628: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>
1827
+ 629: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@query</span>
1828
+ 630: <span class="ruby-keyword kw">end</span>
1829
+ </pre>
1830
+ </div>
1831
+ </div>
1832
+ </div>
1833
+
1834
+ <div id="method-M000033" class="method-detail">
1835
+ <a name="M000033"></a>
1836
+
1837
+ <div class="method-heading">
1838
+ <a href="#M000033" class="method-signature">
1839
+ <span class="method-name">query=</span><span class="method-args">(new_query)</span>
1840
+ </a>
1841
+ </div>
1842
+
1843
+ <div class="method-description">
1844
+ <p>
1845
+ Sets the <a href="URI.html#M000032">query</a> string for this <a
1846
+ href="URI.html">URI</a>.
1847
+ </p>
1848
+ <p><a class="source-toggle" href="#"
1849
+ onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
1850
+ <div class="method-source-code" id="M000033-source">
1851
+ <pre>
1852
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 633</span>
1853
+ 633: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query=</span>(<span class="ruby-identifier">new_query</span>)
1854
+ 634: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">new_query</span>
1855
+ 635: <span class="ruby-keyword kw">end</span>
1856
+ </pre>
1857
+ </div>
1858
+ </div>
1859
+ </div>
1860
+
1861
+ <div id="method-M000037" class="method-detail">
1862
+ <a name="M000037"></a>
1863
+
1864
+ <div class="method-heading">
1865
+ <a href="#M000037" class="method-signature">
1866
+ <span class="method-name">relative?</span><span class="method-args">()</span>
1867
+ </a>
1868
+ </div>
1869
+
1870
+ <div class="method-description">
1871
+ <p>
1872
+ Returns true if this <a href="URI.html">URI</a> is known to be relative.
1873
+ </p>
1874
+ <p><a class="source-toggle" href="#"
1875
+ onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
1876
+ <div class="method-source-code" id="M000037-source">
1877
+ <pre>
1878
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 654</span>
1879
+ 654: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">relative?</span>
1880
+ 655: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">nil?</span>
1881
+ 656: <span class="ruby-keyword kw">end</span>
1882
+ </pre>
1883
+ </div>
1884
+ </div>
1885
+ </div>
1886
+
1887
+ <div id="method-M000042" class="method-detail">
1888
+ <a name="M000042"></a>
1889
+
1890
+ <div class="method-heading">
1891
+ <a href="#M000042" class="method-signature">
1892
+ <span class="method-name">route_from</span><span class="method-args">(uri)</span>
1893
+ </a>
1894
+ </div>
1895
+
1896
+ <div class="method-description">
1897
+ <p>
1898
+ Returns the shortest normalized relative form of this <a
1899
+ href="URI.html">URI</a> that uses the supplied <a href="URI.html">URI</a>
1900
+ as a base for resolution. Returns an absolute <a href="URI.html">URI</a> if
1901
+ necessary.
1902
+ </p>
1903
+ <p><a class="source-toggle" href="#"
1904
+ onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
1905
+ <div class="method-source-code" id="M000042-source">
1906
+ <pre>
1907
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 751</span>
1908
+ 751: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_from</span>(<span class="ruby-identifier">uri</span>)
1909
+ 752: <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
1910
+ 753: <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">normalize</span>
1911
+ 754: <span class="ruby-identifier">normalized_self</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>
1912
+ 755: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">relative?</span>
1913
+ 756: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Expected absolute URI, got: #{self.to_s}&quot;</span>
1914
+ 757: <span class="ruby-keyword kw">end</span>
1915
+ 758: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">relative?</span>
1916
+ 759: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Expected absolute URI, got: #{self.to_s}&quot;</span>
1917
+ 760: <span class="ruby-keyword kw">end</span>
1918
+ 761: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>
1919
+ 762: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">&quot;##{normalized_self.fragment}&quot;</span>)
1920
+ 763: <span class="ruby-keyword kw">end</span>
1921
+ 764: <span class="ruby-identifier">segments</span> = <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">to_h</span>
1922
+ 765: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>
1923
+ 766: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] = <span class="ruby-keyword kw">nil</span>
1924
+ 767: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">authority</span>
1925
+ 768: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>] = <span class="ruby-keyword kw">nil</span>
1926
+ 769: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>] = <span class="ruby-keyword kw">nil</span>
1927
+ 770: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-keyword kw">nil</span>
1928
+ 771: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-keyword kw">nil</span>
1929
+ 772: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>
1930
+ 773: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-keyword kw">nil</span>
1931
+ 774: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
1932
+ 775: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>] = <span class="ruby-keyword kw">nil</span>
1933
+ 776: <span class="ruby-keyword kw">end</span>
1934
+ 777: <span class="ruby-keyword kw">end</span>
1935
+ 778: <span class="ruby-keyword kw">end</span>
1936
+ 779: <span class="ruby-keyword kw">end</span>
1937
+ 780: <span class="ruby-comment cmt"># Avoid network-path references.</span>
1938
+ 781: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
1939
+ 782: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] = <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">scheme</span>
1940
+ 783: <span class="ruby-keyword kw">end</span>
1941
+ 784: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
1942
+ 785: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>],
1943
+ 786: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>],
1944
+ 787: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>],
1945
+ 788: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>],
1946
+ 789: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>],
1947
+ 790: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>],
1948
+ 791: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>],
1949
+ 792: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:fragment</span>]
1950
+ 793: )
1951
+ 794: <span class="ruby-keyword kw">end</span>
1952
+ </pre>
1953
+ </div>
1954
+ </div>
1955
+ </div>
1956
+
1957
+ <div id="method-M000043" class="method-detail">
1958
+ <a name="M000043"></a>
1959
+
1960
+ <div class="method-heading">
1961
+ <a href="#M000043" class="method-signature">
1962
+ <span class="method-name">route_to</span><span class="method-args">(uri)</span>
1963
+ </a>
1964
+ </div>
1965
+
1966
+ <div class="method-description">
1967
+ <p>
1968
+ Returns the shortest normalized relative form of the supplied <a
1969
+ href="URI.html">URI</a> that uses this <a href="URI.html">URI</a> as a base
1970
+ for resolution. Returns an absolute <a href="URI.html">URI</a> if
1971
+ necessary.
1972
+ </p>
1973
+ <p><a class="source-toggle" href="#"
1974
+ onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
1975
+ <div class="method-source-code" id="M000043-source">
1976
+ <pre>
1977
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 799</span>
1978
+ 799: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_to</span>(<span class="ruby-identifier">uri</span>)
1979
+ 800: <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
1980
+ 801: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">route_from</span>(<span class="ruby-keyword kw">self</span>)
1981
+ 802: <span class="ruby-keyword kw">end</span>
1982
+ </pre>
1983
+ </div>
1984
+ </div>
1985
+ </div>
1986
+
1987
+ <div id="method-M000011" class="method-detail">
1988
+ <a name="M000011"></a>
1989
+
1990
+ <div class="method-heading">
1991
+ <a href="#M000011" class="method-signature">
1992
+ <span class="method-name">scheme</span><span class="method-args">()</span>
1993
+ </a>
1994
+ </div>
1995
+
1996
+ <div class="method-description">
1997
+ <p>
1998
+ Returns the <a href="URI.html#M000011">scheme</a> (protocol) for this <a
1999
+ href="URI.html">URI</a>.
2000
+ </p>
2001
+ <p><a class="source-toggle" href="#"
2002
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
2003
+ <div class="method-source-code" id="M000011-source">
2004
+ <pre>
2005
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 393</span>
2006
+ 393: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scheme</span>
2007
+ 394: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@scheme</span>
2008
+ 395: <span class="ruby-keyword kw">end</span>
2009
+ </pre>
2010
+ </div>
2011
+ </div>
2012
+ </div>
2013
+
2014
+ <div id="method-M000012" class="method-detail">
2015
+ <a name="M000012"></a>
2016
+
2017
+ <div class="method-heading">
2018
+ <a href="#M000012" class="method-signature">
2019
+ <span class="method-name">scheme=</span><span class="method-args">(new_scheme)</span>
2020
+ </a>
2021
+ </div>
2022
+
2023
+ <div class="method-description">
2024
+ <p>
2025
+ Sets the <a href="URI.html#M000011">scheme</a> (protocol for this <a
2026
+ href="URI.html">URI</a>.)
2027
+ </p>
2028
+ <p><a class="source-toggle" href="#"
2029
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
2030
+ <div class="method-source-code" id="M000012-source">
2031
+ <pre>
2032
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 398</span>
2033
+ 398: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scheme=</span>(<span class="ruby-identifier">new_scheme</span>)
2034
+ 399: <span class="ruby-ivar">@scheme</span> = <span class="ruby-identifier">new_scheme</span>
2035
+ 400: <span class="ruby-keyword kw">end</span>
2036
+ </pre>
2037
+ </div>
2038
+ </div>
2039
+ </div>
2040
+
2041
+ <div id="method-M000027" class="method-detail">
2042
+ <a name="M000027"></a>
2043
+
2044
+ <div class="method-heading">
2045
+ <a href="#M000027" class="method-signature">
2046
+ <span class="method-name">specified_port</span><span class="method-args">()</span>
2047
+ </a>
2048
+ </div>
2049
+
2050
+ <div class="method-description">
2051
+ <p>
2052
+ Returns the <a href="URI.html#M000025">port</a> number that was actually
2053
+ specified in the <a href="URI.html">URI</a> string.
2054
+ </p>
2055
+ <p><a class="source-toggle" href="#"
2056
+ onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
2057
+ <div class="method-source-code" id="M000027-source">
2058
+ <pre>
2059
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 593</span>
2060
+ 593: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">specified_port</span>
2061
+ 594: <span class="ruby-identifier">port</span> = <span class="ruby-ivar">@specified_port</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_i</span>
2062
+ 595: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
2063
+ 596: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
2064
+ 597: <span class="ruby-keyword kw">else</span>
2065
+ 598: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">port</span>
2066
+ 599: <span class="ruby-keyword kw">end</span>
2067
+ 600: <span class="ruby-keyword kw">end</span>
2068
+ </pre>
2069
+ </div>
2070
+ </div>
2071
+ </div>
2072
+
2073
+ <div id="method-M000052" class="method-detail">
2074
+ <a name="M000052"></a>
2075
+
2076
+ <div class="method-heading">
2077
+ <a href="#M000052" class="method-signature">
2078
+ <span class="method-name">to_h</span><span class="method-args">()</span>
2079
+ </a>
2080
+ </div>
2081
+
2082
+ <div class="method-description">
2083
+ <p>
2084
+ Returns a Hash of the <a href="URI.html">URI</a> segments.
2085
+ </p>
2086
+ <p><a class="source-toggle" href="#"
2087
+ onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
2088
+ <div class="method-source-code" id="M000052-source">
2089
+ <pre>
2090
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 967</span>
2091
+ 967: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_h</span>
2092
+ 968: <span class="ruby-keyword kw">return</span> {
2093
+ 969: <span class="ruby-identifier">:scheme</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>,
2094
+ 970: <span class="ruby-identifier">:user</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>,
2095
+ 971: <span class="ruby-identifier">:password</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>,
2096
+ 972: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>,
2097
+ 973: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span>,
2098
+ 974: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>,
2099
+ 975: <span class="ruby-identifier">:query</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>,
2100
+ 976: <span class="ruby-identifier">:fragment</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span>
2101
+ 977: }
2102
+ 978: <span class="ruby-keyword kw">end</span>
2103
+ </pre>
2104
+ </div>
2105
+ </div>
2106
+ </div>
2107
+
2108
+ <div id="method-M000051" class="method-detail">
2109
+ <a name="M000051"></a>
2110
+
2111
+ <div class="method-heading">
2112
+ <a href="#M000051" class="method-signature">
2113
+ <span class="method-name">to_s</span><span class="method-args">()</span>
2114
+ </a>
2115
+ </div>
2116
+
2117
+ <div class="method-description">
2118
+ <p>
2119
+ Returns the assembled <a href="URI.html">URI</a> as a string.
2120
+ </p>
2121
+ <p><a class="source-toggle" href="#"
2122
+ onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
2123
+ <div class="method-source-code" id="M000051-source">
2124
+ <pre>
2125
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 956</span>
2126
+ 956: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
2127
+ 957: <span class="ruby-identifier">uri_string</span> = <span class="ruby-value str">&quot;&quot;</span>
2128
+ 958: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{self.scheme}:&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
2129
+ 959: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;//#{self.authority}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
2130
+ 960: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">to_s</span>
2131
+ 961: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;?#{self.query}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
2132
+ 962: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;##{self.fragment}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
2133
+ 963: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">uri_string</span>
2134
+ 964: <span class="ruby-keyword kw">end</span>
2135
+ </pre>
2136
+ </div>
2137
+ </div>
2138
+ </div>
2139
+
2140
+ <div id="method-M000013" class="method-detail">
2141
+ <a name="M000013"></a>
2142
+
2143
+ <div class="method-heading">
2144
+ <a href="#M000013" class="method-signature">
2145
+ <span class="method-name">user</span><span class="method-args">()</span>
2146
+ </a>
2147
+ </div>
2148
+
2149
+ <div class="method-description">
2150
+ <p>
2151
+ Returns the <a href="URI.html#M000013">user</a> for this <a
2152
+ href="URI.html">URI</a>.
2153
+ </p>
2154
+ <p><a class="source-toggle" href="#"
2155
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
2156
+ <div class="method-source-code" id="M000013-source">
2157
+ <pre>
2158
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 403</span>
2159
+ 403: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user</span>
2160
+ 404: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@user</span>
2161
+ 405: <span class="ruby-keyword kw">end</span>
2162
+ </pre>
2163
+ </div>
2164
+ </div>
2165
+ </div>
2166
+
2167
+ <div id="method-M000014" class="method-detail">
2168
+ <a name="M000014"></a>
2169
+
2170
+ <div class="method-heading">
2171
+ <a href="#M000014" class="method-signature">
2172
+ <span class="method-name">user=</span><span class="method-args">(new_user)</span>
2173
+ </a>
2174
+ </div>
2175
+
2176
+ <div class="method-description">
2177
+ <p>
2178
+ Sets the <a href="URI.html#M000013">user</a> for this <a
2179
+ href="URI.html">URI</a>.
2180
+ </p>
2181
+ <p><a class="source-toggle" href="#"
2182
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
2183
+ <div class="method-source-code" id="M000014-source">
2184
+ <pre>
2185
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 408</span>
2186
+ 408: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user=</span>(<span class="ruby-identifier">new_user</span>)
2187
+ 409: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">new_user</span>
2188
+ 410:
2189
+ 411: <span class="ruby-comment cmt"># You can't have a nil user with a non-nil password</span>
2190
+ 412: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
2191
+ 413: <span class="ruby-ivar">@user</span> = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">nil?</span>
2192
+ 414: <span class="ruby-keyword kw">end</span>
2193
+ 415:
2194
+ 416: <span class="ruby-comment cmt"># Reset dependant values</span>
2195
+ 417: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
2196
+ 418: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
2197
+ 419:
2198
+ 420: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
2199
+ 421: <span class="ruby-identifier">validate</span>()
2200
+ 422: <span class="ruby-keyword kw">end</span>
2201
+ </pre>
2202
+ </div>
2203
+ </div>
2204
+ </div>
2205
+
2206
+ <div id="method-M000017" class="method-detail">
2207
+ <a name="M000017"></a>
2208
+
2209
+ <div class="method-heading">
2210
+ <a href="#M000017" class="method-signature">
2211
+ <span class="method-name">userinfo</span><span class="method-args">()</span>
2212
+ </a>
2213
+ </div>
2214
+
2215
+ <div class="method-description">
2216
+ <p>
2217
+ Returns the username and <a href="URI.html#M000015">password</a> segment of
2218
+ this <a href="URI.html">URI</a>.
2219
+ </p>
2220
+ <p><a class="source-toggle" href="#"
2221
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
2222
+ <div class="method-source-code" id="M000017-source">
2223
+ <pre>
2224
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 447</span>
2225
+ 447: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">userinfo</span>
2226
+ 448: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@userinfo</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@userinfo</span>.<span class="ruby-identifier">nil?</span>
2227
+ 449: <span class="ruby-identifier">current_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>
2228
+ 450: <span class="ruby-identifier">current_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>
2229
+ 451: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">current_user</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">current_password</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
2230
+ 452: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
2231
+ 453: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">current_user</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">current_password</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
2232
+ 454: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-node">&quot;#{current_user}&quot;</span>
2233
+ 455: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">current_user</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">current_password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
2234
+ 456: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-node">&quot;#{current_user}:#{current_password}&quot;</span>
2235
+ 457: <span class="ruby-keyword kw">end</span>
2236
+ 458: <span class="ruby-keyword kw">end</span>
2237
+ 459: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@userinfo</span>
2238
+ 460: <span class="ruby-keyword kw">end</span>
2239
+ </pre>
2240
+ </div>
2241
+ </div>
2242
+ </div>
2243
+
2244
+ <div id="method-M000018" class="method-detail">
2245
+ <a name="M000018"></a>
2246
+
2247
+ <div class="method-heading">
2248
+ <a href="#M000018" class="method-signature">
2249
+ <span class="method-name">userinfo=</span><span class="method-args">(new_userinfo)</span>
2250
+ </a>
2251
+ </div>
2252
+
2253
+ <div class="method-description">
2254
+ <p>
2255
+ Sets the username and <a href="URI.html#M000015">password</a> segment of
2256
+ this <a href="URI.html">URI</a>.
2257
+ </p>
2258
+ <p><a class="source-toggle" href="#"
2259
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
2260
+ <div class="method-source-code" id="M000018-source">
2261
+ <pre>
2262
+ <span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 463</span>
2263
+ 463: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">userinfo=</span>(<span class="ruby-identifier">new_userinfo</span>)
2264
+ 464: <span class="ruby-identifier">new_user</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^(.*):/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
2265
+ 465: <span class="ruby-identifier">new_password</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:(.*)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
2266
+ 466:
2267
+ 467: <span class="ruby-comment cmt"># Password assigned first to ensure validity in case of nil</span>
2268
+ 468: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-identifier">new_password</span>
2269
+ 469: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">new_user</span>
2270
+ 470:
2271
+ 471: <span class="ruby-comment cmt"># Reset dependant values</span>
2272
+ 472: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
2273
+ 473:
2274
+ 474: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
2275
+ 475: <span class="ruby-identifier">validate</span>()
2276
+ 476: <span class="ruby-keyword kw">end</span>
2277
+ </pre>
2278
+ </div>
2279
+ </div>
2280
+ </div>
2281
+
2282
+
2283
+ </div>
2284
+
2285
+
2286
+ </div>
2287
+
2288
+
2289
+ <div id="validator-badges">
2290
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
2291
+ </div>
2292
+
2293
+ </body>
2294
+ </html>