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.
- data/LICENSE +16 -0
- data/README +57 -0
- data/Rakefile +79 -0
- data/doc/classes/Enumerable.html +146 -0
- data/doc/classes/Enumerable.src/M000025.html +21 -0
- data/doc/classes/Enumerable.src/M000026.html +34 -0
- data/doc/classes/FormattedString/Formats/Xml.html +144 -0
- data/doc/classes/FormattedString/Formats/Xml.src/M000004.html +49 -0
- data/doc/classes/FormattedString/Formats.html +111 -0
- data/doc/classes/FormattedString.html +111 -0
- data/doc/classes/Inflector/Inflections.html +321 -0
- data/doc/classes/Inflector/Inflections.src/M000019.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000020.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000021.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000022.html +26 -0
- data/doc/classes/Inflector/Inflections.src/M000023.html +18 -0
- data/doc/classes/Inflector/Inflections.src/M000024.html +23 -0
- data/doc/classes/Inflector.html +516 -0
- data/doc/classes/Inflector.src/M000005.html +22 -0
- data/doc/classes/Inflector.src/M000006.html +25 -0
- data/doc/classes/Inflector.src/M000007.html +25 -0
- data/doc/classes/Inflector.src/M000008.html +22 -0
- data/doc/classes/Inflector.src/M000009.html +18 -0
- data/doc/classes/Inflector.src/M000010.html +22 -0
- data/doc/classes/Inflector.src/M000011.html +18 -0
- data/doc/classes/Inflector.src/M000012.html +18 -0
- data/doc/classes/Inflector.src/M000013.html +18 -0
- data/doc/classes/Inflector.src/M000014.html +18 -0
- data/doc/classes/Inflector.src/M000015.html +19 -0
- data/doc/classes/Inflector.src/M000016.html +18 -0
- data/doc/classes/Inflector.src/M000017.html +22 -0
- data/doc/classes/Inflector.src/M000018.html +27 -0
- data/doc/classes/String.html +191 -0
- data/doc/classes/String.src/M000001.html +18 -0
- data/doc/classes/String.src/M000002.html +20 -0
- data/doc/classes/String.src/M000003.html +19 -0
- data/doc/created.rid +1 -0
- data/doc/files/LICENSE.html +129 -0
- data/doc/files/README.html +196 -0
- data/doc/files/lib/formatted_string/formats/xml_rb.html +119 -0
- data/doc/files/lib/formatted_string_rb.html +108 -0
- data/doc/files/lib/inflections_rb.html +101 -0
- data/doc/files/lib/inflector_rb.html +108 -0
- data/doc/fr_class_index.html +33 -0
- data/doc/fr_file_index.html +32 -0
- data/doc/fr_method_index.html +52 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/formatted_string/formats/xml.rb +163 -0
- data/lib/formatted_string.rb +34 -0
- data/lib/inflections.rb +53 -0
- data/lib/inflector.rb +282 -0
- 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">"@#{scope}"</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>
|
94
|
+
<a href="#M000015">classify</a>
|
95
|
+
<a href="#M000017">constantize</a>
|
96
|
+
<a href="#M000011">dasherize</a>
|
97
|
+
<a href="#M000013">demodulize</a>
|
98
|
+
<a href="#M000016">foreign_key</a>
|
99
|
+
<a href="#M000012">humanize</a>
|
100
|
+
<a href="#M000005">inflections</a>
|
101
|
+
<a href="#M000018">ordinalize</a>
|
102
|
+
<a href="#M000006">pluralize</a>
|
103
|
+
<a href="#M000007">singularize</a>
|
104
|
+
<a href="#M000014">tableize</a>
|
105
|
+
<a href="#M000009">titleize</a>
|
106
|
+
<a href="#M000010">underscore</a>
|
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 ":lower"
|
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
|
+
’/’ to ’::’ which is useful for converting paths to
|
154
|
+
namespaces
|
155
|
+
</p>
|
156
|
+
<p>
|
157
|
+
Examples
|
158
|
+
</p>
|
159
|
+
<pre>
|
160
|
+
"active_record".camelize #=> "ActiveRecord"
|
161
|
+
"active_record".camelize(:lower) #=> "activeRecord"
|
162
|
+
"active_record/errors".camelize #=> "ActiveRecord::Errors"
|
163
|
+
"active_record/errors".camelize(:lower) #=> "activeRecord::Errors"
|
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
|
+
"egg_and_hams".classify #=> "EggAndHam"
|
190
|
+
"post".classify #=> "Post"
|
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
|
+
"Module".constantize #=> Module
|
216
|
+
"Class".constantize #=> 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
|
+
"puni_puni" #=> "puni-puni"
|
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
|
+
"ActiveRecord::CoreExtensions::String::Inflections".demodulize #=> "Inflections"
|
263
|
+
"Inflections".demodulize #=> "Inflections"
|
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 ‘_’ between the name and ‘id’.
|
283
|
+
</p>
|
284
|
+
<p>
|
285
|
+
Examples
|
286
|
+
</p>
|
287
|
+
<pre>
|
288
|
+
"Message".foreign_key #=> "message_id"
|
289
|
+
"Message".foreign_key(false) #=> "messageid"
|
290
|
+
"Admin::Post".foreign_key #=> "post_id"
|
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
|
+
"employee_salary" #=> "Employee salary"
|
316
|
+
"author_id" #=> "Author"
|
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) # => "1st"
|
355
|
+
ordinalize(2) # => "2nd"
|
356
|
+
ordinalize(1002) # => "1002nd"
|
357
|
+
ordinalize(1003) # => "1003rd"
|
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
|
+
"post".pluralize #=> "posts"
|
381
|
+
"octopus".pluralize #=> "octopi"
|
382
|
+
"sheep".pluralize #=> "sheep"
|
383
|
+
"words".pluralize #=> "words"
|
384
|
+
"the blue mailman".pluralize #=> "the blue mailmen"
|
385
|
+
"CamelOctopus".pluralize #=> "CamelOctopi"
|
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
|
+
"posts".singularize #=> "post"
|
410
|
+
"octopi".singularize #=> "octopus"
|
411
|
+
"sheep".singluarize #=> "sheep"
|
412
|
+
"word".singluarize #=> "word"
|
413
|
+
"the blue mailmen".singularize #=> "the blue mailman"
|
414
|
+
"CamelOctopi".singularize #=> "CamelOctopus"
|
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
|
+
"RawScaledScorer".tableize #=> "raw_scaled_scorers"
|
440
|
+
"egg_and_ham".tableize #=> "egg_and_hams"
|
441
|
+
"fancyCategory".tableize #=> "fancy_categories"
|
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
|
+
"man from the boondocks".titleize #=> "Man From The Boondocks"
|
471
|
+
"x-men: the last stand".titleize #=> "X Men: The Last Stand"
|
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 ’::’ to ’/’ to convert namespaces to paths.
|
493
|
+
</p>
|
494
|
+
<p>
|
495
|
+
Examples
|
496
|
+
</p>
|
497
|
+
<pre>
|
498
|
+
"ActiveRecord".underscore #=> "active_record"
|
499
|
+
"ActiveRecord::Errors".underscore #=> 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">"::"</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>
|