s33r 0.4.2 → 0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. data/examples/cli/instant_download_server.rb +88 -0
  2. data/examples/cli/s3cli.rb +31 -52
  3. data/examples/cli/simple.rb +16 -6
  4. data/examples/fores33r/app/controllers/browser_controller.rb +12 -10
  5. data/examples/fores33r/app/helpers/application_helper.rb +2 -1
  6. data/examples/fores33r/app/views/browser/_upload.rhtml +1 -1
  7. data/examples/fores33r/app/views/browser/index.rhtml +4 -4
  8. data/examples/fores33r/config/environment.rb +5 -3
  9. data/examples/fores33r/log/development.log +2259 -0
  10. data/examples/fores33r/log/mongrel.log +59 -0
  11. data/examples/s3.yaml +2 -6
  12. data/lib/s33r/bucket.rb +103 -0
  13. data/lib/s33r/bucket_listing.rb +33 -76
  14. data/lib/s33r/client.rb +305 -446
  15. data/lib/s33r/networking.rb +197 -0
  16. data/lib/s33r/s33r_exception.rb +29 -18
  17. data/lib/s33r/s33r_http.rb +36 -18
  18. data/lib/s33r/s3_acl.rb +32 -52
  19. data/lib/s33r/s3_logging.rb +117 -0
  20. data/lib/s33r/s3_obj.rb +124 -69
  21. data/lib/s33r/utility.rb +447 -0
  22. data/test/cases/spec_acl.rb +10 -40
  23. data/test/cases/spec_bucket_listing.rb +12 -32
  24. data/test/cases/spec_logging.rb +47 -0
  25. data/test/cases/spec_networking.rb +11 -0
  26. data/test/cases/spec_s3_object.rb +44 -5
  27. data/test/cases/spec_utility.rb +264 -0
  28. data/test/files/acl.xml +0 -6
  29. data/test/files/config.yaml +5 -0
  30. data/test/files/logging_status_disabled.xml +3 -0
  31. data/test/files/logging_status_enabled.xml +7 -0
  32. data/test/test_setup.rb +7 -2
  33. metadata +16 -94
  34. data/examples/cli/acl_x.rb +0 -41
  35. data/examples/cli/logging_x.rb +0 -20
  36. data/examples/fores33r/README +0 -183
  37. data/html/classes/MIME.html +0 -120
  38. data/html/classes/MIME/InvalidContentType.html +0 -119
  39. data/html/classes/MIME/Type.html +0 -1173
  40. data/html/classes/MIME/Types.html +0 -566
  41. data/html/classes/Net.html +0 -108
  42. data/html/classes/Net/HTTPGenericRequest.html +0 -233
  43. data/html/classes/Net/HTTPResponse.html +0 -271
  44. data/html/classes/S33r.html +0 -986
  45. data/html/classes/S33r/BucketListing.html +0 -434
  46. data/html/classes/S33r/Client.html +0 -1575
  47. data/html/classes/S33r/LoggingResource.html +0 -222
  48. data/html/classes/S33r/NamedBucket.html +0 -693
  49. data/html/classes/S33r/OrderlyXmlMarkup.html +0 -165
  50. data/html/classes/S33r/S33rException.html +0 -124
  51. data/html/classes/S33r/S33rException/BucketListingMaxKeysError.html +0 -111
  52. data/html/classes/S33r/S33rException/BucketNotLogTargetable.html +0 -119
  53. data/html/classes/S33r/S33rException/InvalidBucketListing.html +0 -111
  54. data/html/classes/S33r/S33rException/InvalidPermission.html +0 -111
  55. data/html/classes/S33r/S33rException/InvalidS3GroupType.html +0 -111
  56. data/html/classes/S33r/S33rException/MalformedBucketName.html +0 -111
  57. data/html/classes/S33r/S33rException/MethodNotAvailable.html +0 -111
  58. data/html/classes/S33r/S33rException/MissingBucketName.html +0 -111
  59. data/html/classes/S33r/S33rException/MissingRequiredHeaders.html +0 -111
  60. data/html/classes/S33r/S33rException/MissingResource.html +0 -111
  61. data/html/classes/S33r/S33rException/S3FallenOver.html +0 -111
  62. data/html/classes/S33r/S33rException/TryingToPutEmptyResource.html +0 -117
  63. data/html/classes/S33r/S33rException/UnsupportedCannedACL.html +0 -111
  64. data/html/classes/S33r/S33rException/UnsupportedHTTPMethod.html +0 -111
  65. data/html/classes/S33r/S3ACL.html +0 -125
  66. data/html/classes/S33r/S3ACL/ACLDoc.html +0 -521
  67. data/html/classes/S33r/S3ACL/AmazonCustomer.html +0 -168
  68. data/html/classes/S33r/S3ACL/CanonicalUser.html +0 -212
  69. data/html/classes/S33r/S3ACL/Grant.html +0 -403
  70. data/html/classes/S33r/S3ACL/Grantee.html +0 -239
  71. data/html/classes/S33r/S3ACL/Group.html +0 -178
  72. data/html/classes/S33r/S3Object.html +0 -618
  73. data/html/classes/S33r/Sync.html +0 -152
  74. data/html/classes/XML.html +0 -202
  75. data/html/classes/XML/Document.html +0 -125
  76. data/html/classes/XML/Node.html +0 -124
  77. data/html/created.rid +0 -1
  78. data/html/files/CHANGELOG.html +0 -107
  79. data/html/files/MIT-LICENSE.html +0 -129
  80. data/html/files/README_txt.html +0 -259
  81. data/html/files/lib/s33r/bucket_listing_rb.html +0 -101
  82. data/html/files/lib/s33r/builder_rb.html +0 -108
  83. data/html/files/lib/s33r/client_rb.html +0 -111
  84. data/html/files/lib/s33r/core_rb.html +0 -113
  85. data/html/files/lib/s33r/libxml_extensions_rb.html +0 -101
  86. data/html/files/lib/s33r/libxml_loader_rb.html +0 -109
  87. data/html/files/lib/s33r/logging_rb.html +0 -108
  88. data/html/files/lib/s33r/mimetypes_rb.html +0 -120
  89. data/html/files/lib/s33r/named_bucket_rb.html +0 -101
  90. data/html/files/lib/s33r/s33r_exception_rb.html +0 -101
  91. data/html/files/lib/s33r/s33r_http_rb.html +0 -108
  92. data/html/files/lib/s33r/s3_acl_rb.html +0 -108
  93. data/html/files/lib/s33r/s3_obj_rb.html +0 -108
  94. data/html/files/lib/s33r/sync_rb.html +0 -101
  95. data/html/files/lib/s33r_rb.html +0 -101
  96. data/html/fr_class_index.html +0 -66
  97. data/html/fr_file_index.html +0 -44
  98. data/html/fr_method_index.html +0 -183
  99. data/html/index.html +0 -24
  100. data/html/rdoc-style.css +0 -208
  101. data/lib/s33r/core.rb +0 -296
  102. data/lib/s33r/logging.rb +0 -43
  103. data/lib/s33r/named_bucket.rb +0 -148
  104. data/lib/s33r/sync.rb +0 -13
  105. data/test/cases/spec_all_buckets.rb +0 -28
  106. data/test/cases/spec_client.rb +0 -101
  107. data/test/cases/spec_core.rb +0 -128
  108. data/test/cases/spec_namedbucket.rb +0 -46
  109. data/test/cases/spec_sync.rb +0 -34
  110. data/test/files/all_buckets.xml +0 -21
  111. data/test/files/client_config.yml +0 -5
  112. data/test/files/namedbucket_config.yml +0 -8
  113. data/test/files/namedbucket_config2.yml +0 -8
  114. data/test/test_bucket_setup.rb +0 -41
@@ -1,120 +0,0 @@
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: MIME</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">MIME</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/s33r/mimetypes_rb.html">
59
- lib/s33r/mimetypes.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
- <div id="description">
76
- <p>
77
- The namespace for <a href="MIME.html">MIME</a> applications, tools, and
78
- libraries.
79
- </p>
80
-
81
- </div>
82
-
83
-
84
- </div>
85
-
86
-
87
- </div>
88
-
89
-
90
- <!-- if includes -->
91
-
92
- <div id="section">
93
-
94
- <div id="class-list">
95
- <h3 class="section-bar">Classes and Modules</h3>
96
-
97
- Class <a href="MIME/InvalidContentType.html" class="link">MIME::InvalidContentType</a><br />
98
- Class <a href="MIME/Type.html" class="link">MIME::Type</a><br />
99
- Class <a href="MIME/Types.html" class="link">MIME::Types</a><br />
100
-
101
- </div>
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
- <!-- if method_list -->
110
-
111
-
112
- </div>
113
-
114
-
115
- <div id="validator-badges">
116
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
117
- </div>
118
-
119
- </body>
120
- </html>
@@ -1,119 +0,0 @@
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: MIME::InvalidContentType</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">MIME::InvalidContentType</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/s33r/mimetypes_rb.html">
59
- lib/s33r/mimetypes.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
- RuntimeError
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
- Reflects a <a href="../MIME.html">MIME</a> Content-<a
84
- href="Type.html">Type</a> which is in invalid format (e.g., it isn&#8217;t
85
- in the form of type/subtype).
86
- </p>
87
-
88
- </div>
89
-
90
-
91
- </div>
92
-
93
-
94
- </div>
95
-
96
-
97
- <!-- if includes -->
98
-
99
- <div id="section">
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
- <!-- if method_list -->
109
-
110
-
111
- </div>
112
-
113
-
114
- <div id="validator-badges">
115
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
116
- </div>
117
-
118
- </body>
119
- </html>
@@ -1,1173 +0,0 @@
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: MIME::Type</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">MIME::Type</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/s33r/mimetypes_rb.html">
59
- lib/s33r/mimetypes.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
- The definition of one <a href="../MIME.html">MIME</a> content-type.
84
- </p>
85
- <h2>Usage</h2>
86
- <pre>
87
- require 'mime/types'
88
-
89
- plaintext = MIME::Types['text/plain']
90
- print plaintext.media_type # =&gt; 'text'
91
- print plaintext.sub_type # =&gt; 'plain'
92
-
93
- puts plaintext.extensions.join(&quot; &quot;) # =&gt; 'asc txt c cc h hh cpp'
94
-
95
- puts plaintext.encoding # =&gt; 8bit
96
- puts plaintext.binary? # =&gt; false
97
- puts plaintext.ascii? # =&gt; true
98
- puts plaintext == 'text/plain' # =&gt; true
99
- puts MIME::Type.simplified('x-appl/x-zip') # =&gt; 'appl/zip'
100
- </pre>
101
-
102
- </div>
103
-
104
-
105
- </div>
106
-
107
- <div id="method-list">
108
- <h3 class="section-bar">Methods</h3>
109
-
110
- <div class="name-list">
111
- <a href="#M000032">ascii?</a>&nbsp;&nbsp;
112
- <a href="#M000031">binary?</a>&nbsp;&nbsp;
113
- <a href="#M000036">complete?</a>&nbsp;&nbsp;
114
- <a href="#M000020">default_encoding</a>&nbsp;&nbsp;
115
- <a href="#M000023">docs=</a>&nbsp;&nbsp;
116
- <a href="#M000026">from_array</a>&nbsp;&nbsp;
117
- <a href="#M000027">from_hash</a>&nbsp;&nbsp;
118
- <a href="#M000028">from_mime_type</a>&nbsp;&nbsp;
119
- <a href="#M000019">like?</a>&nbsp;&nbsp;
120
- <a href="#M000029">new</a>&nbsp;&nbsp;
121
- <a href="#M000022">obsolete?</a>&nbsp;&nbsp;
122
- <a href="#M000035">platform?</a>&nbsp;&nbsp;
123
- <a href="#M000030">registered?</a>&nbsp;&nbsp;
124
- <a href="#M000033">signature?</a>&nbsp;&nbsp;
125
- <a href="#M000025">simplified</a>&nbsp;&nbsp;
126
- <a href="#M000034">system?</a>&nbsp;&nbsp;
127
- <a href="#M000039">to_a</a>&nbsp;&nbsp;
128
- <a href="#M000040">to_hash</a>&nbsp;&nbsp;
129
- <a href="#M000037">to_s</a>&nbsp;&nbsp;
130
- <a href="#M000038">to_str</a>&nbsp;&nbsp;
131
- <a href="#M000024">urls</a>&nbsp;&nbsp;
132
- <a href="#M000021">use_instead</a>&nbsp;&nbsp;
133
- </div>
134
- </div>
135
-
136
- </div>
137
-
138
-
139
- <!-- if includes -->
140
- <div id="includes">
141
- <h3 class="section-bar">Included Modules</h3>
142
-
143
- <div id="includes-list">
144
- <span class="include-name">Comparable</span>
145
- </div>
146
- </div>
147
-
148
- <div id="section">
149
-
150
-
151
- <div id="constants-list">
152
- <h3 class="section-bar">Constants</h3>
153
-
154
- <div class="name-list">
155
- <table summary="Constants">
156
- <tr class="top-aligned-row context-row">
157
- <td class="context-item-name">VERSION</td>
158
- <td>=</td>
159
- <td class="context-item-value">'1.15'</td>
160
- </tr>
161
- <tr class="top-aligned-row context-row">
162
- <td class="context-item-name">IANA_URL</td>
163
- <td>=</td>
164
- <td class="context-item-value">&quot;http://www.iana.org/assignments/media-types/%s/%s&quot;</td>
165
- </tr>
166
- <tr class="top-aligned-row context-row">
167
- <td class="context-item-name">RFC_URL</td>
168
- <td>=</td>
169
- <td class="context-item-value">&quot;http://rfc-editor.org/rfc/rfc%s.txt&quot;</td>
170
- </tr>
171
- <tr class="top-aligned-row context-row">
172
- <td class="context-item-name">DRAFT_URL</td>
173
- <td>=</td>
174
- <td class="context-item-value">&quot;http://datatracker.ietf.org/public/idindex.cgi?command=id_details&amp;filename=%s&quot;</td>
175
- </tr>
176
- <tr class="top-aligned-row context-row">
177
- <td class="context-item-name">LTSW_URL</td>
178
- <td>=</td>
179
- <td class="context-item-value">&quot;http://www.ltsw.se/knbase/internet/%s.htp&quot;</td>
180
- </tr>
181
- <tr class="top-aligned-row context-row">
182
- <td class="context-item-name">CONTACT_URL</td>
183
- <td>=</td>
184
- <td class="context-item-value">&quot;http://www.iana.org/assignments/contact-people.htm#%s&quot;</td>
185
- </tr>
186
- </table>
187
- </div>
188
- </div>
189
-
190
-
191
-
192
- <div id="attribute-list">
193
- <h3 class="section-bar">Attributes</h3>
194
-
195
- <div class="name-list">
196
- <table>
197
- <tr class="top-aligned-row context-row">
198
- <td class="context-item-name">content_type</td>
199
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
200
- <td class="context-item-desc">
201
- Returns the whole <a href="../MIME.html">MIME</a> content-type string.
202
-
203
- <pre>
204
- text/plain =&gt; text/plain
205
- x-chemical/x-pdb =&gt; x-chemical/x-pdb
206
- </pre>
207
- </td>
208
- </tr>
209
- <tr class="top-aligned-row context-row">
210
- <td class="context-item-name">default_encoding</td>
211
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
212
- <td class="context-item-desc">
213
- Returns the default encoding for the <a href="Type.html">MIME::Type</a>
214
- based on the media type.
215
-
216
- </td>
217
- </tr>
218
- <tr class="top-aligned-row context-row">
219
- <td class="context-item-name">docs</td>
220
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
221
- <td class="context-item-desc">
222
- The documentation for this <a href="Type.html">MIME::Type</a>.
223
- Documentation about media types will be found on a media type definition as
224
- a comment. Documentation will be found through docs.
225
-
226
- </td>
227
- </tr>
228
- <tr class="top-aligned-row context-row">
229
- <td class="context-item-name">encoding</td>
230
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
231
- <td class="context-item-desc">
232
- The encoding (7bit, 8bit, quoted-printable, or base64) required to
233
- transport the data of this content type safely across a network, which
234
- roughly corresponds to Content-Transfer-Encoding. A value of <tt>nil</tt>
235
- or <tt>:default</tt> will reset the encoding to the <a
236
- href="Type.html#M000020">default_encoding</a> for the <a
237
- href="Type.html">MIME::Type</a>. Raises ArgumentError if the encoding
238
- provided is invalid.
239
-
240
- <p>
241
- If the encoding is not provided on construction, this will be either
242
- &#8216;quoted-printable&#8217; (for text/* media types) and
243
- &#8216;base64&#8217; for eveything else.
244
- </p>
245
- </td>
246
- </tr>
247
- <tr class="top-aligned-row context-row">
248
- <td class="context-item-name">extensions</td>
249
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
250
- <td class="context-item-desc">
251
- The list of extensions which are known to be used for this <a
252
- href="Type.html">MIME::Type</a>. Non-array values will be coerced into an
253
- array with <a href="Type.html#M000039">to_a</a>. Array values will be
254
- flattened and <tt>nil</tt> values removed.
255
-
256
- </td>
257
- </tr>
258
- <tr class="top-aligned-row context-row">
259
- <td class="context-item-name">media_type</td>
260
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
261
- <td class="context-item-desc">
262
- Returns the media type of the simplified <a href="../MIME.html">MIME</a>
263
- type.
264
-
265
- <pre>
266
- text/plain =&gt; text
267
- x-chemical/x-pdb =&gt; chemical
268
- </pre>
269
- </td>
270
- </tr>
271
- <tr class="top-aligned-row context-row">
272
- <td class="context-item-name">obsolete</td>
273
- <td class="context-item-value">&nbsp;[W]&nbsp;</td>
274
- <td class="context-item-desc">
275
- Sets the obsolescence indicator for this media type.
276
-
277
- </td>
278
- </tr>
279
- <tr class="top-aligned-row context-row">
280
- <td class="context-item-name">raw_media_type</td>
281
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
282
- <td class="context-item-desc">
283
- Returns the media type of the unmodified <a href="../MIME.html">MIME</a>
284
- type.
285
-
286
- <pre>
287
- text/plain =&gt; text
288
- x-chemical/x-pdb =&gt; x-chemical
289
- </pre>
290
- </td>
291
- </tr>
292
- <tr class="top-aligned-row context-row">
293
- <td class="context-item-name">raw_sub_type</td>
294
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
295
- <td class="context-item-desc">
296
- Returns the media type of the unmodified <a href="../MIME.html">MIME</a>
297
- type.
298
-
299
- <pre>
300
- text/plain =&gt; plain
301
- x-chemical/x-pdb =&gt; x-pdb
302
- </pre>
303
- </td>
304
- </tr>
305
- <tr class="top-aligned-row context-row">
306
- <td class="context-item-name">simplified</td>
307
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
308
- <td class="context-item-desc">
309
- The <a href="../MIME.html">MIME</a> types main- and sub-label can both
310
- start with <tt>x-</tt>, which indicates that it is a non-registered name.
311
- Of course, after registration this flag can disappear, adds to the
312
- confusing proliferation of <a href="../MIME.html">MIME</a> types. The
313
- simplified string has the <tt>x-</tt> removed and are translated to
314
- lowercase.
315
-
316
- <pre>
317
- text/plain =&gt; text/plain
318
- x-chemical/x-pdb =&gt; chemical/pdb
319
- </pre>
320
- </td>
321
- </tr>
322
- <tr class="top-aligned-row context-row">
323
- <td class="context-item-name">sub_type</td>
324
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
325
- <td class="context-item-desc">
326
- Returns the sub-type of the simplified <a href="../MIME.html">MIME</a>
327
- type.
328
-
329
- <pre>
330
- text/plain =&gt; plain
331
- x-chemical/x-pdb =&gt; pdb
332
- </pre>
333
- </td>
334
- </tr>
335
- <tr class="top-aligned-row context-row">
336
- <td class="context-item-name">system</td>
337
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
338
- <td class="context-item-desc">
339
- The regexp for the operating system that this <a
340
- href="Type.html">MIME::Type</a> is specific to.
341
-
342
- </td>
343
- </tr>
344
- <tr class="top-aligned-row context-row">
345
- <td class="context-item-name">url</td>
346
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
347
- <td class="context-item-desc">
348
- The encoded URL list for this <a href="Type.html">MIME::Type</a>. See <a
349
- href="Type.html#M000024">urls</a> for
350
-
351
- </td>
352
- </tr>
353
- <tr class="top-aligned-row context-row">
354
- <td class="context-item-name">use_instead</td>
355
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
356
- <td class="context-item-desc">
357
- Returns the media type or types that should be used instead of this media
358
- type, if it is obsolete. If there is no replacement media type, or it is
359
- not obsolete, <tt>nil</tt> will be returned.
360
-
361
- </td>
362
- </tr>
363
- </table>
364
- </div>
365
- </div>
366
-
367
-
368
-
369
- <!-- if method_list -->
370
- <div id="methods">
371
- <h3 class="section-bar">Public Class methods</h3>
372
-
373
- <div id="method-M000026" class="method-detail">
374
- <a name="M000026"></a>
375
-
376
- <div class="method-heading">
377
- <a href="#M000026" class="method-signature">
378
- <span class="method-name">from_array</span><span class="method-args">(*args) {|m if block_given?| ...}</span>
379
- </a>
380
- </div>
381
-
382
- <div class="method-description">
383
- <p>
384
- Creates a <a href="Type.html">MIME::Type</a> from an array in the form of:
385
- </p>
386
- <pre>
387
- [type-name, [extensions], encoding, system]
388
- </pre>
389
- <p>
390
- <tt>extensions</tt>, <tt>encoding</tt>, and <tt>system</tt> are optional.
391
- </p>
392
- <pre>
393
- MIME::Type.from_array(&quot;application/x-ruby&quot;, ['rb'], '8bit')
394
- MIME::Type.from_array([&quot;application/x-ruby&quot;, ['rb'], '8bit'])
395
- </pre>
396
- <p>
397
- These are equivalent to:
398
- </p>
399
- <pre>
400
- MIME::Type.new('application/x-ruby') do |t|
401
- t.extensions = %w(rb)
402
- t.encoding = '8bit'
403
- end
404
- </pre>
405
- <p><a class="source-toggle" href="#"
406
- onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
407
- <div class="method-source-code" id="M000026-source">
408
- <pre>
409
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 276</span>
410
- 276: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">from_array</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) <span class="ruby-comment cmt">#:yields MIME::Type.new:</span>
411
- 277: <span class="ruby-comment cmt"># Dereferences the array one level, if necessary.</span>
412
- 278: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>)
413
- 279:
414
- 280: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-value">1</span>, <span class="ruby-value">8</span>)
415
- 281: <span class="ruby-identifier">m</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
416
- 282: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
417
- 283: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">2</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>
418
- 284: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">system</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">3</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">3</span>
419
- 285: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">obsolete</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">4</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">4</span>
420
- 286: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">docs</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">5</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">5</span>
421
- 287: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">url</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">6</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">6</span>
422
- 288: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">registered</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">7</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">7</span>
423
- 289: <span class="ruby-keyword kw">end</span>
424
- 290: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">m</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
425
- 291: <span class="ruby-keyword kw">else</span>
426
- 292: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;Array provided must contain between one and eight elements.&quot;</span>
427
- 293: <span class="ruby-keyword kw">end</span>
428
- 294: <span class="ruby-identifier">m</span>
429
- 295: <span class="ruby-keyword kw">end</span>
430
- </pre>
431
- </div>
432
- </div>
433
- </div>
434
-
435
- <div id="method-M000027" class="method-detail">
436
- <a name="M000027"></a>
437
-
438
- <div class="method-heading">
439
- <a href="#M000027" class="method-signature">
440
- <span class="method-name">from_hash</span><span class="method-args">(hash) {|m if block_given?| ...}</span>
441
- </a>
442
- </div>
443
-
444
- <div class="method-description">
445
- <p>
446
- Creates a <a href="Type.html">MIME::Type</a> from a hash. Keys are
447
- case-insensitive, dashes may be replaced with underscores, and the internal
448
- Symbol of the lowercase-underscore version can be used as well. That is,
449
- Content-<a href="Type.html">Type</a> can be provided as content-type,
450
- Content_Type, content_type, or :content_type.
451
- </p>
452
- <p>
453
- Known keys are <tt>Content-<a href="Type.html">Type</a></tt>,
454
- <tt>Content-Transfer-Encoding</tt>, <tt>Extensions</tt>, and
455
- <tt>System</tt>.
456
- </p>
457
- <pre>
458
- MIME::Type.from_hash('Content-Type' =&gt; 'text/x-yaml',
459
- 'Content-Transfer-Encoding' =&gt; '8bit',
460
- 'System' =&gt; 'linux',
461
- 'Extensions' =&gt; ['yaml', 'yml'])
462
- </pre>
463
- <p>
464
- This is equivalent to:
465
- </p>
466
- <pre>
467
- MIME::Type.new('text/x-yaml') do |t|
468
- t.encoding = '8bit'
469
- t.system = 'linux'
470
- t.extensions = ['yaml', 'yml']
471
- end
472
- </pre>
473
- <p><a class="source-toggle" href="#"
474
- onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
475
- <div class="method-source-code" id="M000027-source">
476
- <pre>
477
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 319</span>
478
- 319: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">from_hash</span>(<span class="ruby-identifier">hash</span>) <span class="ruby-comment cmt">#:yields MIME::Type.new:</span>
479
- 320: <span class="ruby-identifier">type</span> = {}
480
- 321: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
481
- 322: <span class="ruby-identifier">type</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">'-A-Z'</span>, <span class="ruby-value str">'_a-z'</span>).<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">v</span>
482
- 323: <span class="ruby-keyword kw">end</span>
483
- 324:
484
- 325: <span class="ruby-identifier">m</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">type</span>[<span class="ruby-identifier">:content_type</span>]) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
485
- 326: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:extensions</span>]
486
- 327: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:content_transfer_encoding</span>]
487
- 328: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">system</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:system</span>]
488
- 329: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">obsolete</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:obsolete</span>]
489
- 330: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">docs</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:docs</span>]
490
- 331: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">url</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:url</span>]
491
- 332: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">registered</span> = <span class="ruby-identifier">type</span>[<span class="ruby-identifier">:registered</span>]
492
- 333: <span class="ruby-keyword kw">end</span>
493
- 334:
494
- 335: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">m</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
495
- 336: <span class="ruby-identifier">m</span>
496
- 337: <span class="ruby-keyword kw">end</span>
497
- </pre>
498
- </div>
499
- </div>
500
- </div>
501
-
502
- <div id="method-M000028" class="method-detail">
503
- <a name="M000028"></a>
504
-
505
- <div class="method-heading">
506
- <a href="#M000028" class="method-signature">
507
- <span class="method-name">from_mime_type</span><span class="method-args">(mime_type) {|m if block_given?| ...}</span>
508
- </a>
509
- </div>
510
-
511
- <div class="method-description">
512
- <p>
513
- Essentially a copy constructor.
514
- </p>
515
- <pre>
516
- MIME::Type.from_mime_type(plaintext)
517
- </pre>
518
- <p>
519
- is equivalent to:
520
- </p>
521
- <pre>
522
- MIME::Type.new(plaintext.content_type.dup) do |t|
523
- t.extensions = plaintext.extensions.dup
524
- t.system = plaintext.system.dup
525
- t.encoding = plaintext.encoding.dup
526
- end
527
- </pre>
528
- <p><a class="source-toggle" href="#"
529
- onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
530
- <div class="method-source-code" id="M000028-source">
531
- <pre>
532
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 350</span>
533
- 350: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">from_mime_type</span>(<span class="ruby-identifier">mime_type</span>) <span class="ruby-comment cmt">#:yields the new MIME::Type:</span>
534
- 351: <span class="ruby-identifier">m</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">dup</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span>
535
- 352: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">extensions</span>.<span class="ruby-identifier">dup</span>
536
- 353: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">system</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">system</span>.<span class="ruby-identifier">dup</span>
537
- 354: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">encoding</span>.<span class="ruby-identifier">dup</span>
538
- 355: <span class="ruby-keyword kw">end</span>
539
- 356:
540
- 357: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">m</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
541
- 358: <span class="ruby-keyword kw">end</span>
542
- </pre>
543
- </div>
544
- </div>
545
- </div>
546
-
547
- <div id="method-M000029" class="method-detail">
548
- <a name="M000029"></a>
549
-
550
- <div class="method-heading">
551
- <a href="#M000029" class="method-signature">
552
- <span class="method-name">new</span><span class="method-args">(content_type) {|self if block_given?| ...}</span>
553
- </a>
554
- </div>
555
-
556
- <div class="method-description">
557
- <p>
558
- Builds a <a href="Type.html">MIME::Type</a> object from the provided <a
559
- href="../MIME.html">MIME</a> Content <a href="Type.html">Type</a> value
560
- (e.g., &#8216;text/plain&#8217; or &#8216;applicaton/x-eruby&#8217;). The
561
- constructed object is yielded to an optional block for additional
562
- configuration, such as associating extensions and encoding information.
563
- </p>
564
- <p><a class="source-toggle" href="#"
565
- onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
566
- <div class="method-source-code" id="M000029-source">
567
- <pre>
568
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 365</span>
569
- 365: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">content_type</span>) <span class="ruby-comment cmt">#:yields self:</span>
570
- 366: <span class="ruby-identifier">matchdata</span> = <span class="ruby-constant">MEDIA_TYPE_RE</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">content_type</span>)
571
- 367:
572
- 368: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">nil?</span>
573
- 369: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidContentType</span>, <span class="ruby-node">&quot;Invalid Content-Type provided ('#{content_type}')&quot;</span>
574
- 370: <span class="ruby-keyword kw">end</span>
575
- 371:
576
- 372: <span class="ruby-ivar">@content_type</span> = <span class="ruby-identifier">content_type</span>
577
- 373: <span class="ruby-ivar">@raw_media_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
578
- 374: <span class="ruby-ivar">@raw_sub_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">1</span>]
579
- 375:
580
- 376: <span class="ruby-ivar">@simplified</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Type</span>.<span class="ruby-identifier">simplified</span>(<span class="ruby-ivar">@content_type</span>)
581
- 377: <span class="ruby-identifier">matchdata</span> = <span class="ruby-constant">MEDIA_TYPE_RE</span>.<span class="ruby-identifier">match</span>(<span class="ruby-ivar">@simplified</span>)
582
- 378: <span class="ruby-ivar">@media_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
583
- 379: <span class="ruby-ivar">@sub_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">1</span>]
584
- 380:
585
- 381: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extensions</span> = <span class="ruby-keyword kw">nil</span>
586
- 382: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-identifier">:default</span>
587
- 383: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">system</span> = <span class="ruby-keyword kw">nil</span>
588
- 384: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">registered</span> = <span class="ruby-keyword kw">true</span>
589
- 385:
590
- 386: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
591
- 387: <span class="ruby-keyword kw">end</span>
592
- </pre>
593
- </div>
594
- </div>
595
- </div>
596
-
597
- <div id="method-M000025" class="method-detail">
598
- <a name="M000025"></a>
599
-
600
- <div class="method-heading">
601
- <a href="#M000025" class="method-signature">
602
- <span class="method-name">simplified</span><span class="method-args">(content_type)</span>
603
- </a>
604
- </div>
605
-
606
- <div class="method-description">
607
- <p>
608
- The <a href="../MIME.html">MIME</a> types main- and sub-label can both
609
- start with <tt>x-</tt>, which indicates that it is a non-registered name.
610
- Of course, after registration this flag can disappear, adds to the
611
- confusing proliferation of <a href="../MIME.html">MIME</a> types. The
612
- simplified string has the <tt>x-</tt> removed and are translated to
613
- lowercase.
614
- </p>
615
- <p><a class="source-toggle" href="#"
616
- onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
617
- <div class="method-source-code" id="M000025-source">
618
- <pre>
619
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 249</span>
620
- 249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">simplified</span>(<span class="ruby-identifier">content_type</span>)
621
- 250: <span class="ruby-identifier">matchdata</span> = <span class="ruby-constant">MEDIA_TYPE_RE</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">content_type</span>)
622
- 251:
623
- 252: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">nil?</span>
624
- 253: <span class="ruby-identifier">simplified</span> = <span class="ruby-keyword kw">nil</span>
625
- 254: <span class="ruby-keyword kw">else</span>
626
- 255: <span class="ruby-identifier">media_type</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-constant">UNREG_RE</span>, <span class="ruby-value str">''</span>)
627
- 256: <span class="ruby-identifier">subtype</span> = <span class="ruby-identifier">matchdata</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-constant">UNREG_RE</span>, <span class="ruby-value str">''</span>)
628
- 257: <span class="ruby-identifier">simplified</span> = <span class="ruby-node">&quot;#{media_type}/#{subtype}&quot;</span>
629
- 258: <span class="ruby-keyword kw">end</span>
630
- 259: <span class="ruby-identifier">simplified</span>
631
- 260: <span class="ruby-keyword kw">end</span>
632
- </pre>
633
- </div>
634
- </div>
635
- </div>
636
-
637
- <h3 class="section-bar">Public Instance methods</h3>
638
-
639
- <div id="method-M000032" class="method-detail">
640
- <a name="M000032"></a>
641
-
642
- <div class="method-heading">
643
- <a href="#M000032" class="method-signature">
644
- <span class="method-name">ascii?</span><span class="method-args">()</span>
645
- </a>
646
- </div>
647
-
648
- <div class="method-description">
649
- <p>
650
- <a href="../MIME.html">MIME</a> types can be specified to be sent across a
651
- network in particular formats. This method returns <tt>false</tt> when the
652
- <a href="../MIME.html">MIME</a> type encoding is set to <tt>base64</tt>.
653
- </p>
654
- <p><a class="source-toggle" href="#"
655
- onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
656
- <div class="method-source-code" id="M000032-source">
657
- <pre>
658
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 413</span>
659
- 413: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ascii?</span>
660
- 414: <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">binary?</span>
661
- 415: <span class="ruby-keyword kw">end</span>
662
- </pre>
663
- </div>
664
- </div>
665
- </div>
666
-
667
- <div id="method-M000031" class="method-detail">
668
- <a name="M000031"></a>
669
-
670
- <div class="method-heading">
671
- <a href="#M000031" class="method-signature">
672
- <span class="method-name">binary?</span><span class="method-args">()</span>
673
- </a>
674
- </div>
675
-
676
- <div class="method-description">
677
- <p>
678
- <a href="../MIME.html">MIME</a> types can be specified to be sent across a
679
- network in particular formats. This method returns <tt>true</tt> when the
680
- <a href="../MIME.html">MIME</a> type encoding is set to <tt>base64</tt>.
681
- </p>
682
- <p><a class="source-toggle" href="#"
683
- onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
684
- <div class="method-source-code" id="M000031-source">
685
- <pre>
686
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 406</span>
687
- 406: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">binary?</span>
688
- 407: <span class="ruby-ivar">@encoding</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'base64'</span>
689
- 408: <span class="ruby-keyword kw">end</span>
690
- </pre>
691
- </div>
692
- </div>
693
- </div>
694
-
695
- <div id="method-M000036" class="method-detail">
696
- <a name="M000036"></a>
697
-
698
- <div class="method-heading">
699
- <a href="#M000036" class="method-signature">
700
- <span class="method-name">complete?</span><span class="method-args">()</span>
701
- </a>
702
- </div>
703
-
704
- <div class="method-description">
705
- <p>
706
- Returns <tt>true</tt> if the <a href="Type.html">MIME::Type</a> specifies
707
- an extension list, indicating that it is a complete <a
708
- href="Type.html">MIME::Type</a>.
709
- </p>
710
- <p><a class="source-toggle" href="#"
711
- onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
712
- <div class="method-source-code" id="M000036-source">
713
- <pre>
714
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 436</span>
715
- 436: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">complete?</span>
716
- 437: <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@extensions</span>.<span class="ruby-identifier">empty?</span>
717
- 438: <span class="ruby-keyword kw">end</span>
718
- </pre>
719
- </div>
720
- </div>
721
- </div>
722
-
723
- <div id="method-M000020" class="method-detail">
724
- <a name="M000020"></a>
725
-
726
- <div class="method-heading">
727
- <a href="#M000020" class="method-signature">
728
- <span class="method-name">default_encoding</span><span class="method-args">()</span>
729
- </a>
730
- </div>
731
-
732
- <div class="method-description">
733
- <p><a class="source-toggle" href="#"
734
- onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
735
- <div class="method-source-code" id="M000020-source">
736
- <pre>
737
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 165</span>
738
- 165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default_encoding</span>
739
- 166: (<span class="ruby-ivar">@media_type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'text'</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">'quoted-printable'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'base64'</span>
740
- 167: <span class="ruby-keyword kw">end</span>
741
- </pre>
742
- </div>
743
- </div>
744
- </div>
745
-
746
- <div id="method-M000023" class="method-detail">
747
- <a name="M000023"></a>
748
-
749
- <div class="method-heading">
750
- <a href="#M000023" class="method-signature">
751
- <span class="method-name">docs=</span><span class="method-args">(d)</span>
752
- </a>
753
- </div>
754
-
755
- <div class="method-description">
756
- <p><a class="source-toggle" href="#"
757
- onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
758
- <div class="method-source-code" id="M000023-source">
759
- <pre>
760
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 191</span>
761
- 191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">docs=</span>(<span class="ruby-identifier">d</span>)
762
- 192: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">d</span>
763
- 193: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-node">%r{use-instead:#{MEDIA_TYPE_RE}}</span>)
764
- 194:
765
- 195: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">empty?</span>
766
- 196: <span class="ruby-ivar">@use_instead</span> = <span class="ruby-keyword kw">nil</span>
767
- 197: <span class="ruby-keyword kw">else</span>
768
- 198: <span class="ruby-ivar">@use_instead</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">el</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{el[0]}/#{el[1]}&quot;</span> }
769
- 199: <span class="ruby-keyword kw">end</span>
770
- 200: <span class="ruby-keyword kw">end</span>
771
- 201: <span class="ruby-keyword kw">end</span>
772
- </pre>
773
- </div>
774
- </div>
775
- </div>
776
-
777
- <div id="method-M000019" class="method-detail">
778
- <a name="M000019"></a>
779
-
780
- <div class="method-heading">
781
- <a href="#M000019" class="method-signature">
782
- <span class="method-name">like?</span><span class="method-args">(other)</span>
783
- </a>
784
- </div>
785
-
786
- <div class="method-description">
787
- <p>
788
- Returns <tt>true</tt> if the simplified type matches the current
789
- </p>
790
- <p><a class="source-toggle" href="#"
791
- onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
792
- <div class="method-source-code" id="M000019-source">
793
- <pre>
794
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 58</span>
795
- 58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">like?</span>(<span class="ruby-identifier">other</span>)
796
- 59: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:simplified</span>)
797
- 60: <span class="ruby-ivar">@simplified</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">simplified</span>
798
- 61: <span class="ruby-keyword kw">else</span>
799
- 62: <span class="ruby-ivar">@simplified</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">simplified</span>(<span class="ruby-identifier">other</span>)
800
- 63: <span class="ruby-keyword kw">end</span>
801
- 64: <span class="ruby-keyword kw">end</span>
802
- </pre>
803
- </div>
804
- </div>
805
- </div>
806
-
807
- <div id="method-M000022" class="method-detail">
808
- <a name="M000022"></a>
809
-
810
- <div class="method-heading">
811
- <a href="#M000022" class="method-signature">
812
- <span class="method-name">obsolete?</span><span class="method-args">()</span>
813
- </a>
814
- </div>
815
-
816
- <div class="method-description">
817
- <p>
818
- Returns <tt>true</tt> if the media type is obsolete.
819
- </p>
820
- <p><a class="source-toggle" href="#"
821
- onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
822
- <div class="method-source-code" id="M000022-source">
823
- <pre>
824
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 180</span>
825
- 180: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">obsolete?</span>
826
- 181: <span class="ruby-ivar">@obsolete</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
827
- 182: <span class="ruby-keyword kw">end</span>
828
- </pre>
829
- </div>
830
- </div>
831
- </div>
832
-
833
- <div id="method-M000035" class="method-detail">
834
- <a name="M000035"></a>
835
-
836
- <div class="method-heading">
837
- <a href="#M000035" class="method-signature">
838
- <span class="method-name">platform?</span><span class="method-args">()</span>
839
- </a>
840
- </div>
841
-
842
- <div class="method-description">
843
- <p>
844
- Returns <tt>true</tt> if the <a href="Type.html">MIME::Type</a> is specific
845
- to the current operating system as represented by RUBY_PLATFORM.
846
- </p>
847
- <p><a class="source-toggle" href="#"
848
- onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
849
- <div class="method-source-code" id="M000035-source">
850
- <pre>
851
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 430</span>
852
- 430: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">platform?</span>
853
- 431: <span class="ruby-identifier">system?</span> <span class="ruby-keyword kw">and</span> (<span class="ruby-constant">RUBY_PLATFORM</span> <span class="ruby-operator">=~</span> <span class="ruby-ivar">@system</span>)
854
- 432: <span class="ruby-keyword kw">end</span>
855
- </pre>
856
- </div>
857
- </div>
858
- </div>
859
-
860
- <div id="method-M000030" class="method-detail">
861
- <a name="M000030"></a>
862
-
863
- <div class="method-heading">
864
- <a href="#M000030" class="method-signature">
865
- <span class="method-name">registered?</span><span class="method-args">()</span>
866
- </a>
867
- </div>
868
-
869
- <div class="method-description">
870
- <p>
871
- <a href="../MIME.html">MIME</a> content-types which are not regestered by
872
- IANA nor defined in RFCs are required to start with <tt>x-</tt>. This
873
- counts as well for a new media type as well as a new sub-type of an
874
- existing media type. If either the media-type or the content-type begins
875
- with <tt>x-</tt>, this method will return <tt>false</tt>.
876
- </p>
877
- <p><a class="source-toggle" href="#"
878
- onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
879
- <div class="method-source-code" id="M000030-source">
880
- <pre>
881
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 394</span>
882
- 394: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">registered?</span>
883
- 395: <span class="ruby-keyword kw">if</span> (<span class="ruby-ivar">@raw_media_type</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">UNREG_RE</span>) <span class="ruby-operator">||</span> (<span class="ruby-ivar">@raw_sub_type</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">UNREG_RE</span>)
884
- 396: <span class="ruby-keyword kw">false</span>
885
- 397: <span class="ruby-keyword kw">else</span>
886
- 398: <span class="ruby-ivar">@registered</span>
887
- 399: <span class="ruby-keyword kw">end</span>
888
- 400: <span class="ruby-keyword kw">end</span>
889
- </pre>
890
- </div>
891
- </div>
892
- </div>
893
-
894
- <div id="method-M000033" class="method-detail">
895
- <a name="M000033"></a>
896
-
897
- <div class="method-heading">
898
- <a href="#M000033" class="method-signature">
899
- <span class="method-name">signature?</span><span class="method-args">()</span>
900
- </a>
901
- </div>
902
-
903
- <div class="method-description">
904
- <p>
905
- Returns <tt>true</tt> when the simplified <a href="../MIME.html">MIME</a>
906
- type is in the list of known digital signatures.
907
- </p>
908
- <p><a class="source-toggle" href="#"
909
- onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
910
- <div class="method-source-code" id="M000033-source">
911
- <pre>
912
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 419</span>
913
- 419: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">signature?</span>
914
- 420: <span class="ruby-constant">SIGNATURES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@simplified</span>.<span class="ruby-identifier">downcase</span>)
915
- 421: <span class="ruby-keyword kw">end</span>
916
- </pre>
917
- </div>
918
- </div>
919
- </div>
920
-
921
- <div id="method-M000034" class="method-detail">
922
- <a name="M000034"></a>
923
-
924
- <div class="method-heading">
925
- <a href="#M000034" class="method-signature">
926
- <span class="method-name">system?</span><span class="method-args">()</span>
927
- </a>
928
- </div>
929
-
930
- <div class="method-description">
931
- <p>
932
- Returns <tt>true</tt> if the <a href="Type.html">MIME::Type</a> is specific
933
- to an operating system.
934
- </p>
935
- <p><a class="source-toggle" href="#"
936
- onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
937
- <div class="method-source-code" id="M000034-source">
938
- <pre>
939
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 424</span>
940
- 424: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">system?</span>
941
- 425: <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@system</span>.<span class="ruby-identifier">nil?</span>
942
- 426: <span class="ruby-keyword kw">end</span>
943
- </pre>
944
- </div>
945
- </div>
946
- </div>
947
-
948
- <div id="method-M000039" class="method-detail">
949
- <a name="M000039"></a>
950
-
951
- <div class="method-heading">
952
- <a href="#M000039" class="method-signature">
953
- <span class="method-name">to_a</span><span class="method-args">()</span>
954
- </a>
955
- </div>
956
-
957
- <div class="method-description">
958
- <p>
959
- Returns the <a href="../MIME.html">MIME</a> type as an array suitable for
960
- use with <a href="Type.html#M000026">MIME::Type.from_array</a>.
961
- </p>
962
- <p><a class="source-toggle" href="#"
963
- onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
964
- <div class="method-source-code" id="M000039-source">
965
- <pre>
966
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 452</span>
967
- 452: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_a</span>
968
- 453: [ <span class="ruby-ivar">@content_type</span>, <span class="ruby-ivar">@extensions</span>, <span class="ruby-ivar">@encoding</span>, <span class="ruby-ivar">@system</span>, <span class="ruby-ivar">@obsolete</span>, <span class="ruby-ivar">@docs</span>,
969
- 454: <span class="ruby-ivar">@url</span>, <span class="ruby-identifier">registered?</span> ]
970
- 455: <span class="ruby-keyword kw">end</span>
971
- </pre>
972
- </div>
973
- </div>
974
- </div>
975
-
976
- <div id="method-M000040" class="method-detail">
977
- <a name="M000040"></a>
978
-
979
- <div class="method-heading">
980
- <a href="#M000040" class="method-signature">
981
- <span class="method-name">to_hash</span><span class="method-args">()</span>
982
- </a>
983
- </div>
984
-
985
- <div class="method-description">
986
- <p>
987
- Returns the <a href="../MIME.html">MIME</a> type as an array suitable for
988
- use with <a href="Type.html#M000027">MIME::Type.from_hash</a>.
989
- </p>
990
- <p><a class="source-toggle" href="#"
991
- onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
992
- <div class="method-source-code" id="M000040-source">
993
- <pre>
994
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 459</span>
995
- 459: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
996
- 460: { <span class="ruby-value str">'Content-Type'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@content_type</span>,
997
- 461: <span class="ruby-value str">'Content-Transfer-Encoding'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@encoding</span>,
998
- 462: <span class="ruby-value str">'Extensions'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@extensions</span>,
999
- 463: <span class="ruby-value str">'System'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@system</span>,
1000
- 464: <span class="ruby-value str">'Obsolete'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@obsolete</span>,
1001
- 465: <span class="ruby-value str">'Docs'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@docs</span>,
1002
- 466: <span class="ruby-value str">'URL'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@url</span>,
1003
- 467: <span class="ruby-value str">'Registered'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">registered?</span>,
1004
- 468: }
1005
- 469: <span class="ruby-keyword kw">end</span>
1006
- </pre>
1007
- </div>
1008
- </div>
1009
- </div>
1010
-
1011
- <div id="method-M000037" class="method-detail">
1012
- <a name="M000037"></a>
1013
-
1014
- <div class="method-heading">
1015
- <a href="#M000037" class="method-signature">
1016
- <span class="method-name">to_s</span><span class="method-args">()</span>
1017
- </a>
1018
- </div>
1019
-
1020
- <div class="method-description">
1021
- <p>
1022
- Returns the <a href="../MIME.html">MIME</a> type as a string.
1023
- </p>
1024
- <p><a class="source-toggle" href="#"
1025
- onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
1026
- <div class="method-source-code" id="M000037-source">
1027
- <pre>
1028
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 441</span>
1029
- 441: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
1030
- 442: <span class="ruby-ivar">@content_type</span>
1031
- 443: <span class="ruby-keyword kw">end</span>
1032
- </pre>
1033
- </div>
1034
- </div>
1035
- </div>
1036
-
1037
- <div id="method-M000038" class="method-detail">
1038
- <a name="M000038"></a>
1039
-
1040
- <div class="method-heading">
1041
- <a href="#M000038" class="method-signature">
1042
- <span class="method-name">to_str</span><span class="method-args">()</span>
1043
- </a>
1044
- </div>
1045
-
1046
- <div class="method-description">
1047
- <p>
1048
- Returns the <a href="../MIME.html">MIME</a> type as a string for implicit
1049
- conversions.
1050
- </p>
1051
- <p><a class="source-toggle" href="#"
1052
- onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
1053
- <div class="method-source-code" id="M000038-source">
1054
- <pre>
1055
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 446</span>
1056
- 446: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_str</span>
1057
- 447: <span class="ruby-ivar">@content_type</span>
1058
- 448: <span class="ruby-keyword kw">end</span>
1059
- </pre>
1060
- </div>
1061
- </div>
1062
- </div>
1063
-
1064
- <div id="method-M000024" class="method-detail">
1065
- <a name="M000024"></a>
1066
-
1067
- <div class="method-heading">
1068
- <a href="#M000024" class="method-signature">
1069
- <span class="method-name">urls</span><span class="method-args">()</span>
1070
- </a>
1071
- </div>
1072
-
1073
- <div class="method-description">
1074
- <p>
1075
- The decoded URL list for this <a href="Type.html">MIME::Type</a>. The
1076
- special URL value IANA will be translated into:
1077
- </p>
1078
- <pre>
1079
- http://www.iana.org/assignments/media-types/&lt;mediatype&gt;/&lt;subtype&gt;
1080
- </pre>
1081
- <p>
1082
- The special URL value RFC### will be translated into:
1083
- </p>
1084
- <pre>
1085
- http://www.rfc-editor.org/rfc/rfc###.txt
1086
- </pre>
1087
- <p>
1088
- The special URL value DRAFT:name will be translated into:
1089
- </p>
1090
- <pre>
1091
- https://datatracker.ietf.org/public/idindex.cgi?
1092
- command=id_detail&amp;filename=&lt;name&gt;
1093
- </pre>
1094
- <p>
1095
- The special URL value LTSW will be translated into:
1096
- </p>
1097
- <pre>
1098
- http://www.ltsw.se/knbase/internet/&lt;mediatype&gt;.htp
1099
- </pre>
1100
- <p>
1101
- The special URL value [token] will be translated into:
1102
- </p>
1103
- <pre>
1104
- http://www.iana.org/assignments/contact-people.htm#&lt;token&gt;
1105
- </pre>
1106
- <p>
1107
- These values will be accessible through url, which always returns an array.
1108
- </p>
1109
- <p><a class="source-toggle" href="#"
1110
- onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
1111
- <div class="method-source-code" id="M000024-source">
1112
- <pre>
1113
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 224</span>
1114
- 224: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">urls</span>
1115
- 225: <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">el</span><span class="ruby-operator">|</span>
1116
- 226: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">el</span>
1117
- 227: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^IANA$}</span>
1118
- 228: <span class="ruby-constant">IANA_URL</span> <span class="ruby-operator">%</span> [ <span class="ruby-ivar">@media_type</span>, <span class="ruby-ivar">@sub_type</span> ]
1119
- 229: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^RFC(\d+)$}</span>
1120
- 230: <span class="ruby-constant">RFC_URL</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">$1</span>
1121
- 231: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^DRAFT:(.+)$}</span>
1122
- 232: <span class="ruby-constant">DRAFT_URL</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">$1</span>
1123
- 233: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^LTSW$}</span>
1124
- 234: <span class="ruby-constant">LTSW_URL</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@media_type</span>
1125
- 235: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">%r{^\[([^\]]+)\]}</span>
1126
- 236: <span class="ruby-constant">CONTACT_URL</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">$1</span>
1127
- 237: <span class="ruby-keyword kw">else</span>
1128
- 238: <span class="ruby-identifier">el</span>
1129
- 239: <span class="ruby-keyword kw">end</span>
1130
- 240: }
1131
- 241: <span class="ruby-keyword kw">end</span>
1132
- </pre>
1133
- </div>
1134
- </div>
1135
- </div>
1136
-
1137
- <div id="method-M000021" class="method-detail">
1138
- <a name="M000021"></a>
1139
-
1140
- <div class="method-heading">
1141
- <a href="#M000021" class="method-signature">
1142
- <span class="method-name">use_instead</span><span class="method-args">()</span>
1143
- </a>
1144
- </div>
1145
-
1146
- <div class="method-description">
1147
- <p><a class="source-toggle" href="#"
1148
- onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
1149
- <div class="method-source-code" id="M000021-source">
1150
- <pre>
1151
- <span class="ruby-comment cmt"># File lib/s33r/mimetypes.rb, line 174</span>
1152
- 174: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_instead</span>
1153
- 175: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@obsolete</span>
1154
- 176: <span class="ruby-ivar">@use_instead</span>
1155
- 177: <span class="ruby-keyword kw">end</span>
1156
- </pre>
1157
- </div>
1158
- </div>
1159
- </div>
1160
-
1161
-
1162
- </div>
1163
-
1164
-
1165
- </div>
1166
-
1167
-
1168
- <div id="validator-badges">
1169
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
1170
- </div>
1171
-
1172
- </body>
1173
- </html>