ruby-extensions 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ MANIFEST
2
+ README.textile
3
+ Rakefile
4
+ doc/RubyExtensions.html
5
+ doc/String.html
6
+ doc/_index.html
7
+ doc/class_list.html
8
+ doc/css/common.css
9
+ doc/css/full_list.css
10
+ doc/css/style.css
11
+ doc/file.README.html
12
+ doc/file_list.html
13
+ doc/frames.html
14
+ doc/index.html
15
+ doc/js/app.js
16
+ doc/js/full_list.js
17
+ doc/js/jquery.js
18
+ doc/method_list.html
19
+ doc/top-level-namespace.html
20
+ lib/ruby-extensions/core/string.rb
21
+ lib/ruby-extensions.rb
22
+ pkg/.gitkeep
23
+ spec/core/string.rb
24
+ spec/helper.rb
25
+ tasks/build.rake
26
+ tasks/doc.rake
@@ -0,0 +1,34 @@
1
+ h1. About
2
+
3
+ Ruby Extensions is a small collection of extensions of core classes provided by Ruby
4
+
5
+ h2. Available Extensions
6
+
7
+ * String.pluralize
8
+ * String.singularize
9
+
10
+ h2. Requirements
11
+
12
+ * Bacon
13
+
14
+ h2. License
15
+
16
+ Copyright (c) 2010, Yorick Peterse
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining a copy
19
+ of this software and associated documentation files (the "Software"), to deal
20
+ in the Software without restriction, including without limitation the rights
21
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
+ copies of the Software, and to permit persons to whom the Software is
23
+ furnished to do so, subject to the following conditions:
24
+
25
+ The above copyright notice and this permission notice shall be included in
26
+ all copies or substantial portions of the Software.
27
+
28
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34
+ THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ require 'rake'
2
+ require File.expand_path('../lib/ruby-extensions', __FILE__)
3
+
4
+ # Load all the tasks from the tasks directory
5
+ Dir.glob('./tasks/*.rake').each do |f|
6
+ import f
7
+ end
@@ -0,0 +1,151 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>Module: RubyExtensions</title>
7
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="_index.html">Index (R)</a> &raquo;
27
+
28
+
29
+ <span class="title">RubyExtensions</span>
30
+
31
+
32
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
+ </div>
34
+
35
+ <div id="search">
36
+ <a id="class_list_link" href="#">Class List</a>
37
+ <a id="method_list_link" href="#">Method List</a>
38
+ <a id ="file_list_link" href="#">File List</a>
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+ </div>
43
+
44
+ <iframe id="search_frame"></iframe>
45
+
46
+ <div id="content"><h1>Module: RubyExtensions
47
+
48
+
49
+
50
+ </h1>
51
+
52
+ <dl class="box">
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ <dt class="r1 last">Defined in:</dt>
62
+ <dd class="r1 last">/Applications/MAMP/htdocs/ruby/Ruby-Extensions/lib/ruby-extensions.rb</dd>
63
+
64
+ </dl>
65
+ <div class="clear"></div>
66
+
67
+ <h2>Overview</h2><div class="docstring">
68
+ <div class="discussion">
69
+ <p>Main namespace, not really much to it actually.</p>
70
+
71
+ </div>
72
+ </div>
73
+ <div class="tags">
74
+ <h3>Author:</h3>
75
+ <ul class="author">
76
+
77
+ <li>
78
+
79
+
80
+
81
+
82
+
83
+ <div class='inline'><p>Yorick Peterse</p></div>
84
+
85
+ </li>
86
+
87
+ </ul>
88
+ <h3>Since:</h3>
89
+ <ul class="since">
90
+
91
+ <li>
92
+
93
+
94
+
95
+
96
+
97
+ <div class='inline'><p>1.0</p></div>
98
+
99
+ </li>
100
+
101
+ </ul>
102
+
103
+ </div>
104
+ <h2>Constant Summary</h2>
105
+
106
+ <dl class="constants">
107
+
108
+ <dt id="Version-constant" class="">Version =
109
+ <div class="docstring">
110
+ <div class="discussion">
111
+ <p>Current version number of the gem.</p>
112
+
113
+ </div>
114
+ </div>
115
+ <div class="tags">
116
+ <h3>Since:</h3>
117
+ <ul class="since">
118
+
119
+ <li>
120
+
121
+
122
+
123
+
124
+
125
+ <div class='inline'><p>1.0</p></div>
126
+
127
+ </li>
128
+
129
+ </ul>
130
+
131
+ </div>
132
+ </dt>
133
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.0</span><span class='tstring_end'>'</span></span></pre></dd>
134
+
135
+ </dl>
136
+
137
+
138
+
139
+
140
+
141
+
142
+ </div>
143
+
144
+ <div id="footer">
145
+ Generated on Wed Jan 26 01:21:27 2011 by
146
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
147
+ 0.6.4 (ruby-1.9.2).
148
+ </div>
149
+
150
+ </body>
151
+ </html>
@@ -0,0 +1,720 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>Class: String</title>
7
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="_index.html">Index (S)</a> &raquo;
27
+
28
+
29
+ <span class="title">String</span>
30
+
31
+
32
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
+ </div>
34
+
35
+ <div id="search">
36
+ <a id="class_list_link" href="#">Class List</a>
37
+ <a id="method_list_link" href="#">Method List</a>
38
+ <a id ="file_list_link" href="#">File List</a>
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+ </div>
43
+
44
+ <iframe id="search_frame"></iframe>
45
+
46
+ <div id="content"><h1>Class: String
47
+
48
+
49
+
50
+ </h1>
51
+
52
+ <dl class="box">
53
+
54
+ <dt class="r1">Inherits:</dt>
55
+ <dd class="r1">
56
+ <span class="inheritName">Object</span>
57
+
58
+ <ul class="fullTree">
59
+ <li>Object</li>
60
+
61
+ <li class="next">String</li>
62
+
63
+ </ul>
64
+ <a href="#" class="inheritanceTree">show all</a>
65
+
66
+ </dd>
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+ <dt class="r2 last">Defined in:</dt>
77
+ <dd class="r2 last">/Applications/MAMP/htdocs/ruby/Ruby-Extensions/lib/ruby-extensions/core/string.rb</dd>
78
+
79
+ </dl>
80
+ <div class="clear"></div>
81
+
82
+ <h2>Overview</h2><div class="docstring">
83
+ <div class="discussion">
84
+ <p>Extension to the string class provided by Ruby that provides the following 2 methods:</p>
85
+ <ul>
86
+ <li>String.pluralize</li>
87
+ <li>String.singularize</li>
88
+ </ul>
89
+ <p>Note that these methods only work for English words, other languages such as Japanese
90
+ or French aren&#8217;t supported at this time (January, 2011). This snippet also doesn&#8217;t cover
91
+ every single english word, patches are welcome!</p>
92
+
93
+ </div>
94
+ </div>
95
+ <div class="tags">
96
+ <h3>Author:</h3>
97
+ <ul class="author">
98
+
99
+ <li>
100
+
101
+
102
+
103
+
104
+
105
+ <div class='inline'><p>Yorick Peterse, Michael Fellinger</p></div>
106
+
107
+ </li>
108
+
109
+ </ul>
110
+ <h3>Since:</h3>
111
+ <ul class="since">
112
+
113
+ <li>
114
+
115
+
116
+
117
+
118
+
119
+ <div class='inline'><p>1.0</p></div>
120
+
121
+ </li>
122
+
123
+ </ul>
124
+
125
+ </div>
126
+ <h2>Constant Summary</h2>
127
+
128
+ <dl class="constants">
129
+
130
+ <dt id="SingularToPlural-constant" class="">SingularToPlural =
131
+ <div class="docstring">
132
+ <div class="discussion">
133
+ <p>Constant containing all regular expressions for singular strings (that will be pluralized)
134
+ and their replacements.</p>
135
+
136
+ </div>
137
+ </div>
138
+ <div class="tags">
139
+ <h3>Since:</h3>
140
+ <ul class="since">
141
+
142
+ <li>
143
+
144
+
145
+
146
+
147
+
148
+ <div class='inline'><p>1.0</p></div>
149
+
150
+ </li>
151
+
152
+ </ul>
153
+
154
+ </div>
155
+ </dt>
156
+ <dd><pre class="code"><span class='lbrace'>{</span>
157
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ss$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sses</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
158
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>se$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ses</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
159
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>sh$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>shes</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
160
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ge$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ges</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
161
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ch$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ches</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
162
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ge$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ges</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
163
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>g$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>gs</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
164
+
165
+ <span class='comment'># When the singular form ends in a voiceless consonant (other than a sibilant).
166
+ </span> <span class='comment'>#
167
+ </span> <span class='comment'># lap =&gt; laps
168
+ </span> <span class='comment'># cat =&gt; cats
169
+ </span> <span class='comment'># clock =&gt; clocks
170
+ </span> <span class='comment'># cuff =&gt; cuffs
171
+ </span> <span class='comment'># death =&gt; deaths
172
+ </span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ap$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aps</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
173
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>at$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
174
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ck$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>cks</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
175
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ff$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ffs</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
176
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>th$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ths</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
177
+
178
+ <span class='comment'># Most nouns ending in o preceded by a consonant also form their plurals by adding -es
179
+ </span> <span class='comment'>#
180
+ </span> <span class='comment'># hero =&gt; heroes
181
+ </span> <span class='comment'># potato =&gt; potatoes
182
+ </span> <span class='comment'># volcano =&gt; volcanoes or volcanos
183
+ </span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>o$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>oes</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
184
+
185
+ <span class='comment'># nouns ending in a y preceded by a consonant usually drop the y and add -ies
186
+ </span> <span class='comment'>#
187
+ </span> <span class='comment'># cherry =&gt; cherries
188
+ </span> <span class='comment'># lady =&gt; ladies
189
+ </span> <span class='comment'># ywzxvtsrqpnmlkjhgfdcb
190
+ </span> <span class='comment'>#
191
+ </span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>([bcdfghjklmnpqrstvxzwy]+)y$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\1ies</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
192
+
193
+ <span class='comment'># For all other words (i.e. words ending in vowels or voiced non-sibilants).
194
+ </span> <span class='comment'>#
195
+ </span> <span class='comment'># boy =&gt; boys
196
+ </span> <span class='comment'># girl =&gt; girls
197
+ </span> <span class='comment'># chair =&gt; chairs
198
+ </span> <span class='comment'># quiz =&gt; quizes
199
+ </span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>z$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>zes</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
200
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>y$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ys</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
201
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>l$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ls</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
202
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>r$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rs</span><span class='tstring_end'>'</span></span>
203
+ <span class='rbrace'>}</span></pre></dd>
204
+
205
+ <dt id="PluralToSingular-constant" class="">PluralToSingular =
206
+ <div class="docstring">
207
+ <div class="discussion">
208
+ <p>Constant containing all regular expressions used to convert plural words to
209
+ singular words.</p>
210
+
211
+ </div>
212
+ </div>
213
+ <div class="tags">
214
+ <h3>Since:</h3>
215
+ <ul class="since">
216
+
217
+ <li>
218
+
219
+
220
+
221
+
222
+
223
+ <div class='inline'><p>1.0</p></div>
224
+
225
+ </li>
226
+
227
+ </ul>
228
+
229
+ </div>
230
+ </dt>
231
+ <dd><pre class="code"><span class='lbrace'>{</span>
232
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>sses$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ss</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
233
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ses$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>se</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
234
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>shes$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>sh</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
235
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ges$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ges</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
236
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ches$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ches</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
237
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ges$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ges</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
238
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>aps$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ap</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
239
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ats$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>at</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
240
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>cks$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ck</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
241
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ffs$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ff</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
242
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ths$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>th</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
243
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>oes$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>o</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
244
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ies$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>y</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
245
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>zes$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>z</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
246
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ys$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>y</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
247
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>l$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ls</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
248
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>r$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rs</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
249
+ <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>s$</span><span class='regexp_end'>/</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
250
+ <span class='rbrace'>}</span></pre></dd>
251
+
252
+ </dl>
253
+
254
+
255
+
256
+
257
+
258
+ <h2>
259
+ Instance Method Summary
260
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
261
+ </h2>
262
+
263
+ <ul class="summary">
264
+
265
+ <li class="public ">
266
+ <span class="summary_signature">
267
+
268
+ <a href="#pluralize-instance_method" title="#pluralize (instance method)">- (String) <strong>pluralize</strong> </a>
269
+
270
+
271
+
272
+ </span>
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+ <span class="summary_desc"><div class='inline'><p>Tries to convert a string to it&#8217;s pluralized version.</p></div></span>
282
+
283
+ </li>
284
+
285
+
286
+ <li class="public ">
287
+ <span class="summary_signature">
288
+
289
+ <a href="#pluralize%21-instance_method" title="#pluralize! (instance method)">- (Object) <strong>pluralize!</strong> </a>
290
+
291
+
292
+
293
+ </span>
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+ <span class="summary_desc"><div class='inline'><p>Converts the current string into a pluralized form and
303
+ overwrites the old value rather than returning it.</p></div></span>
304
+
305
+ </li>
306
+
307
+
308
+ <li class="public ">
309
+ <span class="summary_signature">
310
+
311
+ <a href="#singularize-instance_method" title="#singularize (instance method)">- (String) <strong>singularize</strong> </a>
312
+
313
+
314
+
315
+ </span>
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+ <span class="summary_desc"><div class='inline'><p>Tries to convert the current string into a singular version.</p></div></span>
325
+
326
+ </li>
327
+
328
+
329
+ <li class="public ">
330
+ <span class="summary_signature">
331
+
332
+ <a href="#singularize%21-instance_method" title="#singularize! (instance method)">- (Object) <strong>singularize!</strong> </a>
333
+
334
+
335
+
336
+ </span>
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+ <span class="summary_desc"><div class='inline'><p>Converts a plural string to it&#8217;s singular form and replaces
346
+ the current value of the string with this singular version.</p></div></span>
347
+
348
+ </li>
349
+
350
+
351
+ </ul>
352
+
353
+
354
+
355
+
356
+ <div id="instance_method_details" class="method_details_list">
357
+ <h2>Instance Method Details</h2>
358
+
359
+
360
+ <div class="method_details first">
361
+ <p class="signature first" id="pluralize-instance_method">
362
+
363
+ - (<tt><span class='object_link'><a href="" title="String (class)">String</a></span></tt>) <strong>pluralize</strong>
364
+
365
+
366
+
367
+ </p><div class="docstring">
368
+ <div class="discussion">
369
+ <p>Tries to convert a string to it&#8217;s pluralized version. For example, &#8220;user&#8221; would
370
+ result in &#8220;users&#8221; and &#8220;quiz&#8221; will result in &#8220;quizes&#8221;. This method will return
371
+ the pluralized string, use pluralize! to overwrite the current (singular) version
372
+ of the string with the pluralized one.</p>
373
+
374
+ </div>
375
+ </div>
376
+ <div class="tags">
377
+
378
+ <div class="examples">
379
+ <h3>Examples:</h3>
380
+
381
+ <h4><div class='inline'></div></h4>
382
+ <pre class="example code">
383
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>user</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id pluralize'>pluralize</span> <span class='comment'># =&gt; users
384
+ </span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>baby</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id pluralize'>pluralize</span> <span class='comment'># =&gt; babies</span></pre>
385
+
386
+ </div>
387
+ <h3>Returns:</h3>
388
+ <ul class="return">
389
+
390
+ <li>
391
+
392
+ <span class='type'>(<tt><span class='object_link'><a href="" title="String (class)">String</a></span></tt>)</span>
393
+
394
+
395
+
396
+
397
+ &mdash;
398
+ <div class='inline'><p>The pluralized version of the string.</p></div>
399
+
400
+ </li>
401
+
402
+ </ul>
403
+ <h3>Author:</h3>
404
+ <ul class="author">
405
+
406
+ <li>
407
+
408
+
409
+
410
+
411
+
412
+ <div class='inline'><p>Yorick Peterse, Michael Fellinger</p></div>
413
+
414
+ </li>
415
+
416
+ </ul>
417
+ <h3>Since:</h3>
418
+ <ul class="since">
419
+
420
+ <li>
421
+
422
+
423
+
424
+
425
+
426
+ <div class='inline'><p>1.0</p></div>
427
+
428
+ </li>
429
+
430
+ </ul>
431
+
432
+ </div><table class="source_code">
433
+ <tr>
434
+ <td>
435
+ <pre class="lines">
436
+
437
+
438
+ 112
439
+ 113
440
+ 114
441
+ 115
442
+ 116
443
+ 117
444
+ 118
445
+ 119
446
+ 120
447
+ 121
448
+ 122
449
+ 123
450
+ 124</pre>
451
+ </td>
452
+ <td>
453
+ <pre class="code"><span class="info file"># File '/Applications/MAMP/htdocs/ruby/Ruby-Extensions/lib/ruby-extensions/core/string.rb', line 112</span>
454
+
455
+ <span class='kw'>def</span> <span class='id pluralize'>pluralize</span>
456
+ <span class='id string'>string</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id dup'>dup</span>
457
+
458
+ <span class='const'>SingularToPlural</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id regex'>regex</span><span class='comma'>,</span> <span class='id replace'>replace</span><span class='op'>|</span>
459
+ <span class='id new_string'>new_string</span> <span class='op'>=</span> <span class='id string'>string</span><span class='period'>.</span><span class='id gsub'>gsub</span><span class='lparen'>(</span><span class='id regex'>regex</span><span class='comma'>,</span> <span class='id replace'>replace</span><span class='rparen'>)</span>
460
+
461
+ <span class='kw'>if</span> <span class='id new_string'>new_string</span> <span class='op'>!=</span> <span class='id string'>string</span>
462
+ <span class='kw'>return</span> <span class='id new_string'>new_string</span>
463
+ <span class='kw'>end</span>
464
+ <span class='kw'>end</span>
465
+
466
+ <span class='kw'>return</span> <span class='id string'>string</span>
467
+ <span class='kw'>end</span></pre>
468
+ </td>
469
+ </tr>
470
+ </table>
471
+ </div>
472
+
473
+ <div class="method_details ">
474
+ <p class="signature " id="pluralize!-instance_method">
475
+
476
+ - (<tt>Object</tt>) <strong>pluralize!</strong>
477
+
478
+
479
+
480
+ </p><div class="docstring">
481
+ <div class="discussion">
482
+ <p>Converts the current string into a pluralized form and
483
+ overwrites the old value rather than returning it.</p>
484
+
485
+ </div>
486
+ </div>
487
+ <div class="tags">
488
+
489
+ <div class="examples">
490
+ <h3>Examples:</h3>
491
+
492
+ <h4><div class='inline'></div></h4>
493
+ <pre class="example code">
494
+ <span class='id word'>word</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>user</span><span class='tstring_end'>&quot;</span></span>
495
+ <span class='id word'>word</span><span class='period'>.</span><span class='id pluralize!'>pluralize!</span> <span class='comment'># =&gt; nil
496
+ </span>
497
+ <span class='id puts'>puts</span> <span class='id word'>word</span> <span class='comment'># =&gt; users</span></pre>
498
+
499
+ </div>
500
+ <h3>Since:</h3>
501
+ <ul class="since">
502
+
503
+ <li>
504
+
505
+
506
+
507
+
508
+
509
+ <div class='inline'><p>1.0</p></div>
510
+
511
+ </li>
512
+
513
+ </ul>
514
+
515
+ </div><table class="source_code">
516
+ <tr>
517
+ <td>
518
+ <pre class="lines">
519
+
520
+
521
+ 139
522
+ 140
523
+ 141</pre>
524
+ </td>
525
+ <td>
526
+ <pre class="code"><span class="info file"># File '/Applications/MAMP/htdocs/ruby/Ruby-Extensions/lib/ruby-extensions/core/string.rb', line 139</span>
527
+
528
+ <span class='kw'>def</span> <span class='id pluralize!'>pluralize!</span>
529
+ <span class='kw'>self</span><span class='period'>.</span><span class='id replace'>replace</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id pluralize'>pluralize</span><span class='rparen'>)</span>
530
+ <span class='kw'>end</span></pre>
531
+ </td>
532
+ </tr>
533
+ </table>
534
+ </div>
535
+
536
+ <div class="method_details ">
537
+ <p class="signature " id="singularize-instance_method">
538
+
539
+ - (<tt><span class='object_link'><a href="" title="String (class)">String</a></span></tt>) <strong>singularize</strong>
540
+
541
+
542
+
543
+ </p><div class="docstring">
544
+ <div class="discussion">
545
+ <p>Tries to convert the current string into a singular version.</p>
546
+
547
+ </div>
548
+ </div>
549
+ <div class="tags">
550
+
551
+ <div class="examples">
552
+ <h3>Examples:</h3>
553
+
554
+ <h4><div class='inline'></div></h4>
555
+ <pre class="example code">
556
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>users</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id singularize'>singularize</span> <span class='comment'># =&gt; user
557
+ </span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>babies</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id singularize'>singularize</span> <span class='comment'># =&gt; baby</span></pre>
558
+
559
+ </div>
560
+ <h3>Returns:</h3>
561
+ <ul class="return">
562
+
563
+ <li>
564
+
565
+ <span class='type'>(<tt><span class='object_link'><a href="" title="String (class)">String</a></span></tt>)</span>
566
+
567
+
568
+
569
+
570
+ &mdash;
571
+ <div class='inline'><p>a singular form of the string</p></div>
572
+
573
+ </li>
574
+
575
+ </ul>
576
+ <h3>Author:</h3>
577
+ <ul class="author">
578
+
579
+ <li>
580
+
581
+
582
+
583
+
584
+
585
+ <div class='inline'><p>Yorick Peterse</p></div>
586
+
587
+ </li>
588
+
589
+ </ul>
590
+ <h3>Since:</h3>
591
+ <ul class="since">
592
+
593
+ <li>
594
+
595
+
596
+
597
+
598
+
599
+ <div class='inline'><p>1.0</p></div>
600
+
601
+ </li>
602
+
603
+ </ul>
604
+
605
+ </div><table class="source_code">
606
+ <tr>
607
+ <td>
608
+ <pre class="lines">
609
+
610
+
611
+ 155
612
+ 156
613
+ 157
614
+ 158
615
+ 159
616
+ 160
617
+ 161
618
+ 162
619
+ 163
620
+ 164
621
+ 165
622
+ 166
623
+ 167</pre>
624
+ </td>
625
+ <td>
626
+ <pre class="code"><span class="info file"># File '/Applications/MAMP/htdocs/ruby/Ruby-Extensions/lib/ruby-extensions/core/string.rb', line 155</span>
627
+
628
+ <span class='kw'>def</span> <span class='id singularize'>singularize</span>
629
+ <span class='id string'>string</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id dup'>dup</span>
630
+
631
+ <span class='const'>PluralToSingular</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id regex'>regex</span><span class='comma'>,</span> <span class='id replace'>replace</span><span class='op'>|</span>
632
+ <span class='id new_string'>new_string</span> <span class='op'>=</span> <span class='id string'>string</span><span class='period'>.</span><span class='id gsub'>gsub</span><span class='lparen'>(</span><span class='id regex'>regex</span><span class='comma'>,</span> <span class='id replace'>replace</span><span class='rparen'>)</span>
633
+
634
+ <span class='kw'>if</span> <span class='id new_string'>new_string</span> <span class='op'>!=</span> <span class='id string'>string</span>
635
+ <span class='kw'>return</span> <span class='id new_string'>new_string</span>
636
+ <span class='kw'>end</span>
637
+ <span class='kw'>end</span>
638
+
639
+ <span class='kw'>return</span> <span class='id string'>string</span>
640
+ <span class='kw'>end</span></pre>
641
+ </td>
642
+ </tr>
643
+ </table>
644
+ </div>
645
+
646
+ <div class="method_details ">
647
+ <p class="signature " id="singularize!-instance_method">
648
+
649
+ - (<tt>Object</tt>) <strong>singularize!</strong>
650
+
651
+
652
+
653
+ </p><div class="docstring">
654
+ <div class="discussion">
655
+ <p>Converts a plural string to it&#8217;s singular form and replaces
656
+ the current value of the string with this singular version.</p>
657
+
658
+ </div>
659
+ </div>
660
+ <div class="tags">
661
+
662
+ <div class="examples">
663
+ <h3>Examples:</h3>
664
+
665
+ <h4><div class='inline'></div></h4>
666
+ <pre class="example code">
667
+ <span class='id word'>word</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>users</span><span class='tstring_end'>&quot;</span></span>
668
+ <span class='id word'>word</span><span class='period'>.</span><span class='id singularize!'>singularize!</span> <span class='comment'># =&gt; nil
669
+ </span>
670
+ <span class='id puts'>puts</span> <span class='id word'>word</span> <span class='comment'># =&gt; user</span></pre>
671
+
672
+ </div>
673
+ <h3>Since:</h3>
674
+ <ul class="since">
675
+
676
+ <li>
677
+
678
+
679
+
680
+
681
+
682
+ <div class='inline'><p>1.0</p></div>
683
+
684
+ </li>
685
+
686
+ </ul>
687
+
688
+ </div><table class="source_code">
689
+ <tr>
690
+ <td>
691
+ <pre class="lines">
692
+
693
+
694
+ 182
695
+ 183
696
+ 184</pre>
697
+ </td>
698
+ <td>
699
+ <pre class="code"><span class="info file"># File '/Applications/MAMP/htdocs/ruby/Ruby-Extensions/lib/ruby-extensions/core/string.rb', line 182</span>
700
+
701
+ <span class='kw'>def</span> <span class='id singularize!'>singularize!</span>
702
+ <span class='kw'>self</span><span class='period'>.</span><span class='id replace'>replace</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id singularize'>singularize</span><span class='rparen'>)</span>
703
+ <span class='kw'>end</span></pre>
704
+ </td>
705
+ </tr>
706
+ </table>
707
+ </div>
708
+
709
+ </div>
710
+
711
+ </div>
712
+
713
+ <div id="footer">
714
+ Generated on Wed Jan 26 01:21:27 2011 by
715
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
716
+ 0.6.4 (ruby-1.9.2).
717
+ </div>
718
+
719
+ </body>
720
+ </html>