formattedstring 0.0.1

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 (53) hide show
  1. data/LICENSE +16 -0
  2. data/README +57 -0
  3. data/Rakefile +79 -0
  4. data/doc/classes/Enumerable.html +146 -0
  5. data/doc/classes/Enumerable.src/M000025.html +21 -0
  6. data/doc/classes/Enumerable.src/M000026.html +34 -0
  7. data/doc/classes/FormattedString/Formats/Xml.html +144 -0
  8. data/doc/classes/FormattedString/Formats/Xml.src/M000004.html +49 -0
  9. data/doc/classes/FormattedString/Formats.html +111 -0
  10. data/doc/classes/FormattedString.html +111 -0
  11. data/doc/classes/Inflector/Inflections.html +321 -0
  12. data/doc/classes/Inflector/Inflections.src/M000019.html +18 -0
  13. data/doc/classes/Inflector/Inflections.src/M000020.html +18 -0
  14. data/doc/classes/Inflector/Inflections.src/M000021.html +18 -0
  15. data/doc/classes/Inflector/Inflections.src/M000022.html +26 -0
  16. data/doc/classes/Inflector/Inflections.src/M000023.html +18 -0
  17. data/doc/classes/Inflector/Inflections.src/M000024.html +23 -0
  18. data/doc/classes/Inflector.html +516 -0
  19. data/doc/classes/Inflector.src/M000005.html +22 -0
  20. data/doc/classes/Inflector.src/M000006.html +25 -0
  21. data/doc/classes/Inflector.src/M000007.html +25 -0
  22. data/doc/classes/Inflector.src/M000008.html +22 -0
  23. data/doc/classes/Inflector.src/M000009.html +18 -0
  24. data/doc/classes/Inflector.src/M000010.html +22 -0
  25. data/doc/classes/Inflector.src/M000011.html +18 -0
  26. data/doc/classes/Inflector.src/M000012.html +18 -0
  27. data/doc/classes/Inflector.src/M000013.html +18 -0
  28. data/doc/classes/Inflector.src/M000014.html +18 -0
  29. data/doc/classes/Inflector.src/M000015.html +19 -0
  30. data/doc/classes/Inflector.src/M000016.html +18 -0
  31. data/doc/classes/Inflector.src/M000017.html +22 -0
  32. data/doc/classes/Inflector.src/M000018.html +27 -0
  33. data/doc/classes/String.html +191 -0
  34. data/doc/classes/String.src/M000001.html +18 -0
  35. data/doc/classes/String.src/M000002.html +20 -0
  36. data/doc/classes/String.src/M000003.html +19 -0
  37. data/doc/created.rid +1 -0
  38. data/doc/files/LICENSE.html +129 -0
  39. data/doc/files/README.html +196 -0
  40. data/doc/files/lib/formatted_string/formats/xml_rb.html +119 -0
  41. data/doc/files/lib/formatted_string_rb.html +108 -0
  42. data/doc/files/lib/inflections_rb.html +101 -0
  43. data/doc/files/lib/inflector_rb.html +108 -0
  44. data/doc/fr_class_index.html +33 -0
  45. data/doc/fr_file_index.html +32 -0
  46. data/doc/fr_method_index.html +52 -0
  47. data/doc/index.html +24 -0
  48. data/doc/rdoc-style.css +208 -0
  49. data/lib/formatted_string/formats/xml.rb +163 -0
  50. data/lib/formatted_string.rb +34 -0
  51. data/lib/inflections.rb +53 -0
  52. data/lib/inflector.rb +282 -0
  53. metadata +120 -0
@@ -0,0 +1,23 @@
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>
7
+ <head>
8
+ <title>clear (Inflector::Inflections)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/inflector.rb, line 77</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear</span>(<span class="ruby-identifier">scope</span> = <span class="ruby-identifier">:all</span>)
15
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">scope</span>
16
+ <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:all</span>
17
+ <span class="ruby-ivar">@plurals</span>, <span class="ruby-ivar">@singulars</span>, <span class="ruby-ivar">@uncountables</span> = [], [], []
18
+ <span class="ruby-keyword kw">else</span>
19
+ <span class="ruby-identifier">instance_variable_set</span> <span class="ruby-node">&quot;@#{scope}&quot;</span>, []
20
+ <span class="ruby-keyword kw">end</span>
21
+ <span class="ruby-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>
@@ -0,0 +1,516 @@
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: Inflector</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">Inflector</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/inflector_rb.html">
59
+ lib/inflector.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 <a href="Inflector.html">Inflector</a> transforms words from singular
78
+ to plural, class names to table names, modularized class names to ones
79
+ without, and class names to foreign keys. The default <a
80
+ href="Inflector.html#M000005">inflections</a> for pluralization,
81
+ singularization, and uncountable words are kept in inflections.rb.
82
+ </p>
83
+
84
+ </div>
85
+
86
+
87
+ </div>
88
+
89
+ <div id="method-list">
90
+ <h3 class="section-bar">Methods</h3>
91
+
92
+ <div class="name-list">
93
+ <a href="#M000008">camelize</a>&nbsp;&nbsp;
94
+ <a href="#M000015">classify</a>&nbsp;&nbsp;
95
+ <a href="#M000017">constantize</a>&nbsp;&nbsp;
96
+ <a href="#M000011">dasherize</a>&nbsp;&nbsp;
97
+ <a href="#M000013">demodulize</a>&nbsp;&nbsp;
98
+ <a href="#M000016">foreign_key</a>&nbsp;&nbsp;
99
+ <a href="#M000012">humanize</a>&nbsp;&nbsp;
100
+ <a href="#M000005">inflections</a>&nbsp;&nbsp;
101
+ <a href="#M000018">ordinalize</a>&nbsp;&nbsp;
102
+ <a href="#M000006">pluralize</a>&nbsp;&nbsp;
103
+ <a href="#M000007">singularize</a>&nbsp;&nbsp;
104
+ <a href="#M000014">tableize</a>&nbsp;&nbsp;
105
+ <a href="#M000009">titleize</a>&nbsp;&nbsp;
106
+ <a href="#M000010">underscore</a>&nbsp;&nbsp;
107
+ </div>
108
+ </div>
109
+
110
+ </div>
111
+
112
+
113
+ <!-- if includes -->
114
+
115
+ <div id="section">
116
+
117
+ <div id="class-list">
118
+ <h3 class="section-bar">Classes and Modules</h3>
119
+
120
+ Class <a href="Inflector/Inflections.html" class="link">Inflector::Inflections</a><br />
121
+
122
+ </div>
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <!-- if method_list -->
131
+ <div id="methods">
132
+ <h3 class="section-bar">Public Instance methods</h3>
133
+
134
+ <div id="method-M000008" class="method-detail">
135
+ <a name="M000008"></a>
136
+
137
+ <div class="method-heading">
138
+ <a href="Inflector.src/M000008.html" target="Code" class="method-signature"
139
+ onclick="popupCode('Inflector.src/M000008.html');return false;">
140
+ <span class="method-name">camelize</span><span class="method-args">(lower_case_and_underscored_word, first_letter_in_uppercase = true)</span>
141
+ </a>
142
+ </div>
143
+
144
+ <div class="method-description">
145
+ <p>
146
+ By default, <a href="Inflector.html#M000008">camelize</a> converts strings
147
+ to UpperCamelCase. If the argument to <a
148
+ href="Inflector.html#M000008">camelize</a> is set to &quot;:lower&quot;
149
+ then <a href="Inflector.html#M000008">camelize</a> produces lowerCamelCase.
150
+ </p>
151
+ <p>
152
+ <a href="Inflector.html#M000008">camelize</a> will also convert
153
+ &#8217;/&#8217; to &#8217;::&#8217; which is useful for converting paths to
154
+ namespaces
155
+ </p>
156
+ <p>
157
+ Examples
158
+ </p>
159
+ <pre>
160
+ &quot;active_record&quot;.camelize #=&gt; &quot;ActiveRecord&quot;
161
+ &quot;active_record&quot;.camelize(:lower) #=&gt; &quot;activeRecord&quot;
162
+ &quot;active_record/errors&quot;.camelize #=&gt; &quot;ActiveRecord::Errors&quot;
163
+ &quot;active_record/errors&quot;.camelize(:lower) #=&gt; &quot;activeRecord::Errors&quot;
164
+ </pre>
165
+ </div>
166
+ </div>
167
+
168
+ <div id="method-M000015" class="method-detail">
169
+ <a name="M000015"></a>
170
+
171
+ <div class="method-heading">
172
+ <a href="Inflector.src/M000015.html" target="Code" class="method-signature"
173
+ onclick="popupCode('Inflector.src/M000015.html');return false;">
174
+ <span class="method-name">classify</span><span class="method-args">(table_name)</span>
175
+ </a>
176
+ </div>
177
+
178
+ <div class="method-description">
179
+ <p>
180
+ Create a class name from a table name like Rails does for table names to
181
+ models. Note that this returns a string and not a Class. (To convert to an
182
+ actual class follow <a href="Inflector.html#M000015">classify</a> with <a
183
+ href="Inflector.html#M000017">constantize</a>.)
184
+ </p>
185
+ <p>
186
+ Examples
187
+ </p>
188
+ <pre>
189
+ &quot;egg_and_hams&quot;.classify #=&gt; &quot;EggAndHam&quot;
190
+ &quot;post&quot;.classify #=&gt; &quot;Post&quot;
191
+ </pre>
192
+ </div>
193
+ </div>
194
+
195
+ <div id="method-M000017" class="method-detail">
196
+ <a name="M000017"></a>
197
+
198
+ <div class="method-heading">
199
+ <a href="Inflector.src/M000017.html" target="Code" class="method-signature"
200
+ onclick="popupCode('Inflector.src/M000017.html');return false;">
201
+ <span class="method-name">constantize</span><span class="method-args">(camel_cased_word)</span>
202
+ </a>
203
+ </div>
204
+
205
+ <div class="method-description">
206
+ <p>
207
+ Constantize tries to find a declared constant with the name specified in
208
+ the string. It raises a NameError when the name is not in CamelCase or is
209
+ not initialized.
210
+ </p>
211
+ <p>
212
+ Examples
213
+ </p>
214
+ <pre>
215
+ &quot;Module&quot;.constantize #=&gt; Module
216
+ &quot;Class&quot;.constantize #=&gt; Class
217
+ </pre>
218
+ </div>
219
+ </div>
220
+
221
+ <div id="method-M000011" class="method-detail">
222
+ <a name="M000011"></a>
223
+
224
+ <div class="method-heading">
225
+ <a href="Inflector.src/M000011.html" target="Code" class="method-signature"
226
+ onclick="popupCode('Inflector.src/M000011.html');return false;">
227
+ <span class="method-name">dasherize</span><span class="method-args">(underscored_word)</span>
228
+ </a>
229
+ </div>
230
+
231
+ <div class="method-description">
232
+ <p>
233
+ Replaces underscores with dashes in the string.
234
+ </p>
235
+ <p>
236
+ Example
237
+ </p>
238
+ <pre>
239
+ &quot;puni_puni&quot; #=&gt; &quot;puni-puni&quot;
240
+ </pre>
241
+ </div>
242
+ </div>
243
+
244
+ <div id="method-M000013" class="method-detail">
245
+ <a name="M000013"></a>
246
+
247
+ <div class="method-heading">
248
+ <a href="Inflector.src/M000013.html" target="Code" class="method-signature"
249
+ onclick="popupCode('Inflector.src/M000013.html');return false;">
250
+ <span class="method-name">demodulize</span><span class="method-args">(class_name_in_module)</span>
251
+ </a>
252
+ </div>
253
+
254
+ <div class="method-description">
255
+ <p>
256
+ Removes the module part from the expression in the string
257
+ </p>
258
+ <p>
259
+ Examples
260
+ </p>
261
+ <pre>
262
+ &quot;ActiveRecord::CoreExtensions::String::Inflections&quot;.demodulize #=&gt; &quot;Inflections&quot;
263
+ &quot;Inflections&quot;.demodulize #=&gt; &quot;Inflections&quot;
264
+ </pre>
265
+ </div>
266
+ </div>
267
+
268
+ <div id="method-M000016" class="method-detail">
269
+ <a name="M000016"></a>
270
+
271
+ <div class="method-heading">
272
+ <a href="Inflector.src/M000016.html" target="Code" class="method-signature"
273
+ onclick="popupCode('Inflector.src/M000016.html');return false;">
274
+ <span class="method-name">foreign_key</span><span class="method-args">(class_name, separate_class_name_and_id_with_underscore = true)</span>
275
+ </a>
276
+ </div>
277
+
278
+ <div class="method-description">
279
+ <p>
280
+ Creates a foreign key name from a class name.
281
+ <tt>separate_class_name_and_id_with_underscore</tt> sets whether the method
282
+ should put &#8216;_&#8217; between the name and &#8216;id&#8217;.
283
+ </p>
284
+ <p>
285
+ Examples
286
+ </p>
287
+ <pre>
288
+ &quot;Message&quot;.foreign_key #=&gt; &quot;message_id&quot;
289
+ &quot;Message&quot;.foreign_key(false) #=&gt; &quot;messageid&quot;
290
+ &quot;Admin::Post&quot;.foreign_key #=&gt; &quot;post_id&quot;
291
+ </pre>
292
+ </div>
293
+ </div>
294
+
295
+ <div id="method-M000012" class="method-detail">
296
+ <a name="M000012"></a>
297
+
298
+ <div class="method-heading">
299
+ <a href="Inflector.src/M000012.html" target="Code" class="method-signature"
300
+ onclick="popupCode('Inflector.src/M000012.html');return false;">
301
+ <span class="method-name">humanize</span><span class="method-args">(lower_case_and_underscored_word)</span>
302
+ </a>
303
+ </div>
304
+
305
+ <div class="method-description">
306
+ <p>
307
+ Capitalizes the first word and turns underscores into spaces and strips
308
+ _id. Like <a href="Inflector.html#M000009">titleize</a>, this is meant for
309
+ creating pretty output.
310
+ </p>
311
+ <p>
312
+ Examples
313
+ </p>
314
+ <pre>
315
+ &quot;employee_salary&quot; #=&gt; &quot;Employee salary&quot;
316
+ &quot;author_id&quot; #=&gt; &quot;Author&quot;
317
+ </pre>
318
+ </div>
319
+ </div>
320
+
321
+ <div id="method-M000005" class="method-detail">
322
+ <a name="M000005"></a>
323
+
324
+ <div class="method-heading">
325
+ <a href="Inflector.src/M000005.html" target="Code" class="method-signature"
326
+ onclick="popupCode('Inflector.src/M000005.html');return false;">
327
+ <span class="method-name">inflections</span><span class="method-args">() {|Inflections.instance| ...}</span>
328
+ </a>
329
+ </div>
330
+
331
+ <div class="method-description">
332
+ </div>
333
+ </div>
334
+
335
+ <div id="method-M000018" class="method-detail">
336
+ <a name="M000018"></a>
337
+
338
+ <div class="method-heading">
339
+ <a href="Inflector.src/M000018.html" target="Code" class="method-signature"
340
+ onclick="popupCode('Inflector.src/M000018.html');return false;">
341
+ <span class="method-name">ordinalize</span><span class="method-args">(number)</span>
342
+ </a>
343
+ </div>
344
+
345
+ <div class="method-description">
346
+ <p>
347
+ Ordinalize turns a number into an ordinal string used to denote the
348
+ position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
349
+ </p>
350
+ <p>
351
+ Examples
352
+ </p>
353
+ <pre>
354
+ ordinalize(1) # =&gt; &quot;1st&quot;
355
+ ordinalize(2) # =&gt; &quot;2nd&quot;
356
+ ordinalize(1002) # =&gt; &quot;1002nd&quot;
357
+ ordinalize(1003) # =&gt; &quot;1003rd&quot;
358
+ </pre>
359
+ </div>
360
+ </div>
361
+
362
+ <div id="method-M000006" class="method-detail">
363
+ <a name="M000006"></a>
364
+
365
+ <div class="method-heading">
366
+ <a href="Inflector.src/M000006.html" target="Code" class="method-signature"
367
+ onclick="popupCode('Inflector.src/M000006.html');return false;">
368
+ <span class="method-name">pluralize</span><span class="method-args">(word)</span>
369
+ </a>
370
+ </div>
371
+
372
+ <div class="method-description">
373
+ <p>
374
+ Returns the plural form of the word in the string.
375
+ </p>
376
+ <p>
377
+ Examples
378
+ </p>
379
+ <pre>
380
+ &quot;post&quot;.pluralize #=&gt; &quot;posts&quot;
381
+ &quot;octopus&quot;.pluralize #=&gt; &quot;octopi&quot;
382
+ &quot;sheep&quot;.pluralize #=&gt; &quot;sheep&quot;
383
+ &quot;words&quot;.pluralize #=&gt; &quot;words&quot;
384
+ &quot;the blue mailman&quot;.pluralize #=&gt; &quot;the blue mailmen&quot;
385
+ &quot;CamelOctopus&quot;.pluralize #=&gt; &quot;CamelOctopi&quot;
386
+ </pre>
387
+ </div>
388
+ </div>
389
+
390
+ <div id="method-M000007" class="method-detail">
391
+ <a name="M000007"></a>
392
+
393
+ <div class="method-heading">
394
+ <a href="Inflector.src/M000007.html" target="Code" class="method-signature"
395
+ onclick="popupCode('Inflector.src/M000007.html');return false;">
396
+ <span class="method-name">singularize</span><span class="method-args">(word)</span>
397
+ </a>
398
+ </div>
399
+
400
+ <div class="method-description">
401
+ <p>
402
+ The reverse of <a href="Inflector.html#M000006">pluralize</a>, returns the
403
+ singular form of a word in a string.
404
+ </p>
405
+ <p>
406
+ Examples
407
+ </p>
408
+ <pre>
409
+ &quot;posts&quot;.singularize #=&gt; &quot;post&quot;
410
+ &quot;octopi&quot;.singularize #=&gt; &quot;octopus&quot;
411
+ &quot;sheep&quot;.singluarize #=&gt; &quot;sheep&quot;
412
+ &quot;word&quot;.singluarize #=&gt; &quot;word&quot;
413
+ &quot;the blue mailmen&quot;.singularize #=&gt; &quot;the blue mailman&quot;
414
+ &quot;CamelOctopi&quot;.singularize #=&gt; &quot;CamelOctopus&quot;
415
+ </pre>
416
+ </div>
417
+ </div>
418
+
419
+ <div id="method-M000014" class="method-detail">
420
+ <a name="M000014"></a>
421
+
422
+ <div class="method-heading">
423
+ <a href="Inflector.src/M000014.html" target="Code" class="method-signature"
424
+ onclick="popupCode('Inflector.src/M000014.html');return false;">
425
+ <span class="method-name">tableize</span><span class="method-args">(class_name)</span>
426
+ </a>
427
+ </div>
428
+
429
+ <div class="method-description">
430
+ <p>
431
+ Create the name of a table like Rails does for models to table names. This
432
+ method uses the <a href="Inflector.html#M000006">pluralize</a> method on
433
+ the last word in the string.
434
+ </p>
435
+ <p>
436
+ Examples
437
+ </p>
438
+ <pre>
439
+ &quot;RawScaledScorer&quot;.tableize #=&gt; &quot;raw_scaled_scorers&quot;
440
+ &quot;egg_and_ham&quot;.tableize #=&gt; &quot;egg_and_hams&quot;
441
+ &quot;fancyCategory&quot;.tableize #=&gt; &quot;fancy_categories&quot;
442
+ </pre>
443
+ </div>
444
+ </div>
445
+
446
+ <div id="method-M000009" class="method-detail">
447
+ <a name="M000009"></a>
448
+
449
+ <div class="method-heading">
450
+ <a href="Inflector.src/M000009.html" target="Code" class="method-signature"
451
+ onclick="popupCode('Inflector.src/M000009.html');return false;">
452
+ <span class="method-name">titleize</span><span class="method-args">(word)</span>
453
+ </a>
454
+ </div>
455
+
456
+ <div class="method-description">
457
+ <p>
458
+ Capitalizes all the words and replaces some characters in the string to
459
+ create a nicer looking title. Titleize is meant for creating pretty output.
460
+ It is not used in the Rails internals.
461
+ </p>
462
+ <p>
463
+ <a href="Inflector.html#M000009">titleize</a> is also aliased as as
464
+ titlecase
465
+ </p>
466
+ <p>
467
+ Examples
468
+ </p>
469
+ <pre>
470
+ &quot;man from the boondocks&quot;.titleize #=&gt; &quot;Man From The Boondocks&quot;
471
+ &quot;x-men: the last stand&quot;.titleize #=&gt; &quot;X Men: The Last Stand&quot;
472
+ </pre>
473
+ </div>
474
+ </div>
475
+
476
+ <div id="method-M000010" class="method-detail">
477
+ <a name="M000010"></a>
478
+
479
+ <div class="method-heading">
480
+ <a href="Inflector.src/M000010.html" target="Code" class="method-signature"
481
+ onclick="popupCode('Inflector.src/M000010.html');return false;">
482
+ <span class="method-name">underscore</span><span class="method-args">(camel_cased_word)</span>
483
+ </a>
484
+ </div>
485
+
486
+ <div class="method-description">
487
+ <p>
488
+ The reverse of <tt><a href="Inflector.html#M000008">camelize</a></tt>.
489
+ Makes an underscored form from the expression in the string.
490
+ </p>
491
+ <p>
492
+ Changes &#8217;::&#8217; to &#8217;/&#8217; to convert namespaces to paths.
493
+ </p>
494
+ <p>
495
+ Examples
496
+ </p>
497
+ <pre>
498
+ &quot;ActiveRecord&quot;.underscore #=&gt; &quot;active_record&quot;
499
+ &quot;ActiveRecord::Errors&quot;.underscore #=&gt; active_record/errors
500
+ </pre>
501
+ </div>
502
+ </div>
503
+
504
+
505
+ </div>
506
+
507
+
508
+ </div>
509
+
510
+
511
+ <div id="validator-badges">
512
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
513
+ </div>
514
+
515
+ </body>
516
+ </html>
@@ -0,0 +1,22 @@
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>
7
+ <head>
8
+ <title>inflections (Inflector)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/inflector.rb, line 89</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inflections</span>
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
16
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-constant">Inflections</span>.<span class="ruby-identifier">instance</span>
17
+ <span class="ruby-keyword kw">else</span>
18
+ <span class="ruby-constant">Inflections</span>.<span class="ruby-identifier">instance</span>
19
+ <span class="ruby-keyword kw">end</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,25 @@
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>
7
+ <head>
8
+ <title>pluralize (Inflector)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/inflector.rb, line 106</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pluralize</span>(<span class="ruby-identifier">word</span>)
15
+ <span class="ruby-identifier">result</span> = <span class="ruby-identifier">word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
16
+
17
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">word</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">uncountables</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">result</span>.<span class="ruby-identifier">downcase</span>)
18
+ <span class="ruby-identifier">result</span>
19
+ <span class="ruby-keyword kw">else</span>
20
+ <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">plurals</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>)<span class="ruby-operator">|</span> <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>) }
21
+ <span class="ruby-identifier">result</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">end</span></pre>
24
+ </body>
25
+ </html>
@@ -0,0 +1,25 @@
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>
7
+ <head>
8
+ <title>singularize (Inflector)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/inflector.rb, line 126</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">singularize</span>(<span class="ruby-identifier">word</span>)
15
+ <span class="ruby-identifier">result</span> = <span class="ruby-identifier">word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
16
+
17
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">uncountables</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">result</span>.<span class="ruby-identifier">downcase</span>)
18
+ <span class="ruby-identifier">result</span>
19
+ <span class="ruby-keyword kw">else</span>
20
+ <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">singulars</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>)<span class="ruby-operator">|</span> <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>) }
21
+ <span class="ruby-identifier">result</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">end</span></pre>
24
+ </body>
25
+ </html>
@@ -0,0 +1,22 @@
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>
7
+ <head>
8
+ <title>camelize (Inflector)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/inflector.rb, line 147</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">camelize</span>(<span class="ruby-identifier">lower_case_and_underscored_word</span>, <span class="ruby-identifier">first_letter_in_uppercase</span> = <span class="ruby-keyword kw">true</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">first_letter_in_uppercase</span>
16
+ <span class="ruby-identifier">lower_case_and_underscored_word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\/(.?)/</span>) { <span class="ruby-value str">&quot;::&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">upcase</span> }.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/(^|_)(.)/</span>) { <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">upcase</span> }
17
+ <span class="ruby-keyword kw">else</span>
18
+ <span class="ruby-identifier">lower_case_and_underscored_word</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">camelize</span>(<span class="ruby-identifier">lower_case_and_underscored_word</span>)[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
19
+ <span class="ruby-keyword kw">end</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,18 @@
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>
7
+ <head>
8
+ <title>titleize (Inflector)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/inflector.rb, line 164</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">titleize</span>(<span class="ruby-identifier">word</span>)
15
+ <span class="ruby-identifier">humanize</span>(<span class="ruby-identifier">underscore</span>(<span class="ruby-identifier">word</span>)).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\b([a-z])/</span>) { <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">capitalize</span> }
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>