sexmachine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,24 @@
1
+ = Sex Machine
2
+ This gem uses the underlying data from the program "gender" by Jorg Michael (described [here](http://www.autohotkey.com/community/viewtopic.php?t=22000)). It's use is pretty straightforward:
3
+
4
+ >> require 'sexmachine'
5
+ >> d = Detector.new
6
+ >> d.get_gender("Bob")
7
+ :male
8
+ >> d.get_gender("Sally")
9
+ :female
10
+ >> d.get_gender("Pauley") # should be androgynous
11
+ :andy
12
+
13
+ I18N is fully supported:
14
+
15
+ >> d.get_gender("�lfr�n")
16
+ :female
17
+
18
+ If you have an alterative data file, you can pass that in as an optional argument to the Detector.
19
+
20
+ Try to avoid creating many Detectors, as each creation means reading in the data file.
21
+
22
+ = Licenses
23
+ The genderator code is distributed under the GPLv3. The data file nam_dict.txt is released under the GNU Free Documentation License.
24
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rake/testtask'
4
+ require 'rdoc/task'
5
+
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ desc "Create documentation"
9
+ RDoc::Task.new("doc") { |rdoc|
10
+ rdoc.title = "SexMachine - Gender from first name"
11
+ rdoc.rdoc_dir = 'docs'
12
+ rdoc.rdoc_files.include('README.rdoc')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ }
@@ -0,0 +1,123 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8
+
9
+ <title>File: README.rdoc [SexMachine - Gender from first name]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file">
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="project-metadata">
36
+
37
+
38
+ <div id="fileindex-section" class="section project-section">
39
+ <h3 class="section-header">Files</h3>
40
+ <ul>
41
+
42
+ <li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+
47
+
48
+ <div id="classindex-section" class="section project-section">
49
+ <h3 class="section-header">Class Index
50
+ <span class="search-toggle"><img src="./images/find.png"
51
+ height="16" width="16" alt="[+]"
52
+ title="show/hide quicksearch" /></span></h3>
53
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
54
+ <fieldset>
55
+ <legend>Quicksearch</legend>
56
+ <input type="text" name="quicksearch" value=""
57
+ class="quicksearch-field" />
58
+ </fieldset>
59
+ </form>
60
+
61
+ <ul class="link-list">
62
+
63
+ <li><a href="./SexMachine.html">SexMachine</a></li>
64
+
65
+ <li><a href="./SexMachine/Detector.html">SexMachine::Detector</a></li>
66
+
67
+ </ul>
68
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
69
+ </div>
70
+
71
+
72
+ </div>
73
+ </div>
74
+
75
+ <div id="documentation">
76
+ <h1>Sex Machine</h1>
77
+ <p>
78
+ This gem uses the underlying data from the program &#8220;gender&#8221; by
79
+ Jorg Michael (described [here](<a
80
+ href="http://www.autohotkey.com/community/viewtopic.php?t=22000">www.autohotkey.com/community/viewtopic.php?t=22000</a>)).
81
+ It&#8217;s use is pretty straightforward:
82
+ </p>
83
+ <pre>
84
+ &gt;&gt; require 'sexmachine'
85
+ &gt;&gt; d = Detector.new
86
+ &gt;&gt; d.get_gender(&quot;Bob&quot;)
87
+ :male
88
+ &gt;&gt; d.get_gender(&quot;Sally&quot;)
89
+ :female
90
+ &gt;&gt; d.get_gender(&quot;Pauley&quot;) # should be androgynous
91
+ :andy
92
+ </pre>
93
+ <p>
94
+ I18N is fully supported:
95
+ </p>
96
+ <pre>
97
+ &gt;&gt; d.get_gender(&quot;�lfr�n&quot;)
98
+ :female
99
+ </pre>
100
+ <p>
101
+ If you have an alterative data file, you can pass that in as an optional
102
+ argument to the Detector.
103
+ </p>
104
+ <p>
105
+ Try to avoid creating many Detectors, as each creation means reading in the
106
+ data file.
107
+ </p>
108
+ <h1>Licenses</h1>
109
+ <p>
110
+ The genderator code is distributed under the GPLv3. The data file
111
+ nam_dict.txt is released under the GNU Free Documentation License.
112
+ </p>
113
+
114
+ </div>
115
+
116
+ <div id="validator-badges">
117
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
118
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
119
+ Rdoc Generator</a> 1.1.6</small>.</p>
120
+ </div>
121
+ </body>
122
+ </html>
123
+
@@ -0,0 +1,163 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Module: SexMachine</title>
9
+
10
+ <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="./js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="./js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="./js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="module">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="./lib/sexmachine/detector_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/sexmachine/detector.rb">lib/sexmachine/detector.rb</a></li>
43
+
44
+ <li><a href="./lib/sexmachine/version_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
45
+ class="thickbox" title="lib/sexmachine/version.rb">lib/sexmachine/version.rb</a></li>
46
+
47
+ </ul>
48
+ </div>
49
+ </div>
50
+
51
+
52
+ </div>
53
+
54
+ <div id="class-metadata">
55
+
56
+ <!-- Parent Class -->
57
+
58
+
59
+ <!-- Namespace Contents -->
60
+
61
+ <div id="namespace-list-section" class="section">
62
+ <h3 class="section-header">Namespace</h3>
63
+ <ul class="link-list">
64
+
65
+ <li><span class="type">CLASS</span> <a href="SexMachine/Detector.html">SexMachine::Detector</a></li>
66
+
67
+ </ul>
68
+ </div>
69
+
70
+
71
+ <!-- Method Quickref -->
72
+
73
+
74
+ <!-- Included Modules -->
75
+
76
+ </div>
77
+
78
+ <div id="project-metadata">
79
+
80
+
81
+ <div id="fileindex-section" class="section project-section">
82
+ <h3 class="section-header">Files</h3>
83
+ <ul>
84
+
85
+ <li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
86
+
87
+ </ul>
88
+ </div>
89
+
90
+
91
+ <div id="classindex-section" class="section project-section">
92
+ <h3 class="section-header">Class Index
93
+ <span class="search-toggle"><img src="./images/find.png"
94
+ height="16" width="16" alt="[+]"
95
+ title="show/hide quicksearch" /></span></h3>
96
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
97
+ <fieldset>
98
+ <legend>Quicksearch</legend>
99
+ <input type="text" name="quicksearch" value=""
100
+ class="quicksearch-field" />
101
+ </fieldset>
102
+ </form>
103
+
104
+ <ul class="link-list">
105
+
106
+ <li><a href="./SexMachine.html">SexMachine</a></li>
107
+
108
+ <li><a href="./SexMachine/Detector.html">SexMachine::Detector</a></li>
109
+
110
+ </ul>
111
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
112
+ </div>
113
+
114
+
115
+ </div>
116
+ </div>
117
+
118
+ <div id="documentation">
119
+ <h1 class="module">SexMachine</h1>
120
+
121
+ <div id="description">
122
+
123
+ </div>
124
+
125
+ <!-- Constants -->
126
+
127
+ <div id="constants-list" class="section">
128
+ <h3 class="section-header">Constants</h3>
129
+ <dl>
130
+
131
+ <dt><a name="VERSION">VERSION</a></dt>
132
+
133
+ <dd class="description"></dd>
134
+
135
+
136
+ </dl>
137
+ </div>
138
+
139
+
140
+ <!-- Attributes -->
141
+
142
+
143
+ <!-- Methods -->
144
+
145
+
146
+ </div>
147
+
148
+
149
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
150
+
151
+ <p>Disabled; run with --debug to generate this.</p>
152
+
153
+ </div>
154
+
155
+ <div id="validator-badges">
156
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
157
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
158
+ Rdoc Generator</a> 1.1.6</small>.</p>
159
+ </div>
160
+
161
+ </body>
162
+ </html>
163
+
@@ -0,0 +1,376 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: SexMachine::Detector</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="../js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="../js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="class">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="../index.html">Home</a>
29
+ <a href="../index.html#classes">Classes</a>
30
+ <a href="../index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="../lib/sexmachine/detector_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/sexmachine/detector.rb">lib/sexmachine/detector.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+ <div id="parent-class-section" class="section">
56
+ <h3 class="section-header">Parent</h3>
57
+
58
+ <p class="link">Object</p>
59
+
60
+ </div>
61
+
62
+
63
+ <!-- Namespace Contents -->
64
+
65
+
66
+ <!-- Method Quickref -->
67
+
68
+ <div id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+ <ul class="link-list">
71
+
72
+ <li><a href="#method-c-new">::new</a></li>
73
+
74
+ <li><a href="#method-i-eatNameLine">#eatNameLine</a></li>
75
+
76
+ <li><a href="#method-i-get_gender">#get_gender</a></li>
77
+
78
+ <li><a href="#method-i-parse">#parse</a></li>
79
+
80
+ <li><a href="#method-i-set">#set</a></li>
81
+
82
+ </ul>
83
+ </div>
84
+
85
+
86
+ <!-- Included Modules -->
87
+
88
+ </div>
89
+
90
+ <div id="project-metadata">
91
+
92
+
93
+ <div id="fileindex-section" class="section project-section">
94
+ <h3 class="section-header">Files</h3>
95
+ <ul>
96
+
97
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
98
+
99
+ </ul>
100
+ </div>
101
+
102
+
103
+ <div id="classindex-section" class="section project-section">
104
+ <h3 class="section-header">Class Index
105
+ <span class="search-toggle"><img src="../images/find.png"
106
+ height="16" width="16" alt="[+]"
107
+ title="show/hide quicksearch" /></span></h3>
108
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
109
+ <fieldset>
110
+ <legend>Quicksearch</legend>
111
+ <input type="text" name="quicksearch" value=""
112
+ class="quicksearch-field" />
113
+ </fieldset>
114
+ </form>
115
+
116
+ <ul class="link-list">
117
+
118
+ <li><a href="../SexMachine.html">SexMachine</a></li>
119
+
120
+ <li><a href="../SexMachine/Detector.html">SexMachine::Detector</a></li>
121
+
122
+ </ul>
123
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
124
+ </div>
125
+
126
+
127
+ </div>
128
+ </div>
129
+
130
+ <div id="documentation">
131
+ <h1 class="class">SexMachine::Detector</h1>
132
+
133
+ <div id="description">
134
+
135
+ </div>
136
+
137
+ <!-- Constants -->
138
+
139
+
140
+ <!-- Attributes -->
141
+
142
+
143
+ <!-- Methods -->
144
+
145
+ <div id="public-class-method-details" class="method-section section">
146
+ <h3 class="section-header">Public Class Methods</h3>
147
+
148
+
149
+ <div id="new-method" class="method-detail ">
150
+ <a name="method-c-new"></a>
151
+
152
+ <div class="method-heading">
153
+
154
+ <span class="method-name">new</span><span
155
+ class="method-args">(fname=nil)</span>
156
+ <span class="method-click-advice">click to toggle source</span>
157
+
158
+ </div>
159
+
160
+ <div class="method-description">
161
+
162
+
163
+
164
+
165
+
166
+ <div class="method-source-code"
167
+ id="new-source">
168
+ <pre>
169
+ <span class="ruby-comment cmt"># File lib/sexmachine/detector.rb, line 4</span>
170
+ 4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">fname</span>=<span class="ruby-keyword kw">nil</span>)
171
+ 5: <span class="ruby-ivar">@names</span> = {}
172
+ 6: <span class="ruby-identifier">fname</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-value str">'../data/nam_dict.txt'</span>, <span class="ruby-keyword kw">__FILE__</span>)
173
+ 7: <span class="ruby-identifier">parse</span> <span class="ruby-identifier">fname</span>
174
+ 8: <span class="ruby-keyword kw">end</span></pre>
175
+ </div>
176
+
177
+ </div>
178
+
179
+
180
+
181
+
182
+ </div>
183
+
184
+
185
+ </div>
186
+
187
+ <div id="public-instance-method-details" class="method-section section">
188
+ <h3 class="section-header">Public Instance Methods</h3>
189
+
190
+
191
+ <div id="get-gender-method" class="method-detail ">
192
+ <a name="method-i-get_gender"></a>
193
+
194
+ <div class="method-heading">
195
+
196
+ <span class="method-name">get_gender</span><span
197
+ class="method-args">(name)</span>
198
+ <span class="method-click-advice">click to toggle source</span>
199
+
200
+ </div>
201
+
202
+ <div class="method-description">
203
+
204
+
205
+
206
+
207
+
208
+ <div class="method-source-code"
209
+ id="get-gender-source">
210
+ <pre>
211
+ <span class="ruby-comment cmt"># File lib/sexmachine/detector.rb, line 18</span>
212
+ 18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_gender</span>(<span class="ruby-identifier">name</span>)
213
+ 19: <span class="ruby-ivar">@names</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">name</span>, <span class="ruby-value">:andy</span>)
214
+ 20: <span class="ruby-keyword kw">end</span></pre>
215
+ </div>
216
+
217
+ </div>
218
+
219
+
220
+
221
+
222
+ </div>
223
+
224
+
225
+ <div id="parse-method" class="method-detail ">
226
+ <a name="method-i-parse"></a>
227
+
228
+ <div class="method-heading">
229
+
230
+ <span class="method-name">parse</span><span
231
+ class="method-args">(fname)</span>
232
+ <span class="method-click-advice">click to toggle source</span>
233
+
234
+ </div>
235
+
236
+ <div class="method-description">
237
+
238
+
239
+
240
+
241
+
242
+ <div class="method-source-code"
243
+ id="parse-source">
244
+ <pre>
245
+ <span class="ruby-comment cmt"># File lib/sexmachine/detector.rb, line 10</span>
246
+ 10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">fname</span>)
247
+ 11: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">fname</span>, <span class="ruby-value str">&quot;r:iso8859-1:utf-8&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
248
+ 12: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">each_line</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
249
+ 13: <span class="ruby-identifier">eatNameLine</span> <span class="ruby-identifier">line</span>
250
+ 14: }
251
+ 15: }
252
+ 16: <span class="ruby-keyword kw">end</span></pre>
253
+ </div>
254
+
255
+ </div>
256
+
257
+
258
+
259
+
260
+ </div>
261
+
262
+
263
+ </div>
264
+
265
+ <div id="private-instance-method-details" class="method-section section">
266
+ <h3 class="section-header">Private Instance Methods</h3>
267
+
268
+
269
+ <div id="eat-ame-ine-method" class="method-detail ">
270
+ <a name="method-i-eatNameLine"></a>
271
+
272
+ <div class="method-heading">
273
+
274
+ <span class="method-name">eatNameLine</span><span
275
+ class="method-args">(line)</span>
276
+ <span class="method-click-advice">click to toggle source</span>
277
+
278
+ </div>
279
+
280
+ <div class="method-description">
281
+
282
+
283
+
284
+
285
+
286
+ <div class="method-source-code"
287
+ id="eat-ame-ine-source">
288
+ <pre>
289
+ <span class="ruby-comment cmt"># File lib/sexmachine/detector.rb, line 23</span>
290
+ 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eatNameLine</span>(<span class="ruby-identifier">line</span>)
291
+ 24: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-node">&quot;#&quot;</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-value str">&quot;=&quot;</span>)
292
+ 25:
293
+ 26: <span class="ruby-identifier">parts</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot; &quot;</span>).<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;&quot;</span> }
294
+ 27:
295
+ 28: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parts</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;F&quot;</span>
296
+ 29: <span class="ruby-identifier">set</span> <span class="ruby-identifier">parts</span>[<span class="ruby-value">1</span>], <span class="ruby-value">:female</span>
297
+ 30: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">parts</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;M&quot;</span>
298
+ 31: <span class="ruby-identifier">set</span> <span class="ruby-identifier">parts</span>[<span class="ruby-value">1</span>], <span class="ruby-value">:male</span>
299
+ 32: <span class="ruby-keyword kw">else</span>
300
+ 33: <span class="ruby-identifier">set</span> <span class="ruby-identifier">parts</span>[<span class="ruby-value">1</span>], <span class="ruby-value">:andy</span>
301
+ 34: <span class="ruby-keyword kw">end</span>
302
+ 35: <span class="ruby-keyword kw">end</span></pre>
303
+ </div>
304
+
305
+ </div>
306
+
307
+
308
+
309
+
310
+ </div>
311
+
312
+
313
+ <div id="set-method" class="method-detail ">
314
+ <a name="method-i-set"></a>
315
+
316
+ <div class="method-heading">
317
+
318
+ <span class="method-name">set</span><span
319
+ class="method-args">(name, gender)</span>
320
+ <span class="method-click-advice">click to toggle source</span>
321
+
322
+ </div>
323
+
324
+ <div class="method-description">
325
+
326
+
327
+
328
+
329
+
330
+ <div class="method-source-code"
331
+ id="set-source">
332
+ <pre>
333
+ <span class="ruby-comment cmt"># File lib/sexmachine/detector.rb, line 37</span>
334
+ 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">gender</span>)
335
+ 38: <span class="ruby-comment cmt"># go w/ first option, don't reset</span>
336
+ 39: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@names</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">name</span>
337
+ 40:
338
+ 41: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;+&quot;</span>
339
+ 42: [ <span class="ruby-value str">''</span>, <span class="ruby-value str">'-'</span>, <span class="ruby-value str">' '</span> ].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">replacement</span><span class="ruby-operator">|</span>
340
+ 43: <span class="ruby-identifier">set</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot;+&quot;</span>, <span class="ruby-identifier">replacement</span>), <span class="ruby-identifier">gender</span>
341
+ 44: }
342
+ 45: <span class="ruby-keyword kw">else</span>
343
+ 46: <span class="ruby-ivar">@names</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">gender</span>
344
+ 47: <span class="ruby-keyword kw">end</span>
345
+ 48: <span class="ruby-keyword kw">end</span></pre>
346
+ </div>
347
+
348
+ </div>
349
+
350
+
351
+
352
+
353
+ </div>
354
+
355
+
356
+ </div>
357
+
358
+
359
+ </div>
360
+
361
+
362
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
363
+
364
+ <p>Disabled; run with --debug to generate this.</p>
365
+
366
+ </div>
367
+
368
+ <div id="validator-badges">
369
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
370
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
371
+ Rdoc Generator</a> 1.1.6</small>.</p>
372
+ </div>
373
+
374
+ </body>
375
+ </html>
376
+