print_primes_table 0.0.2
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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +3 -0
- data/.yardoc/checksums +10 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +78 -0
- data/Rakefile +2 -0
- data/bin/print_primes_table +10 -0
- data/doc/PrintPrimesTable.html +146 -0
- data/doc/PrintPrimesTable/Client.html +368 -0
- data/doc/PrintPrimesTable/Options.html +142 -0
- data/doc/PrintPrimesTable/Options/DefaultOption.html +247 -0
- data/doc/PrintPrimesTable/Options/HelpOption.html +311 -0
- data/doc/PrintPrimesTable/Options/OnlyPrimesOption.html +289 -0
- data/doc/PrintPrimesTable/Primes.html +496 -0
- data/doc/PrintPrimesTable/Validators.html +142 -0
- data/doc/PrintPrimesTable/Validators/DefaultValidator.html +284 -0
- data/doc/PrintPrimesTable/Validators/ErrorMessage.html +405 -0
- data/doc/PrintPrimesTable/Validators/HelpValidator.html +285 -0
- data/doc/_index.html +228 -0
- data/doc/class_list.html +58 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +122 -0
- data/doc/file_list.html +60 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +122 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +181 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +135 -0
- data/doc/top-level-namespace.html +131 -0
- data/features/command_print_primes_table.feature +57 -0
- data/features/help_option.feature +24 -0
- data/features/support/env.rb +2 -0
- data/features/validate_arguments.feature +14 -0
- data/lib/print_primes_table.rb +4 -0
- data/lib/print_primes_table/client.rb +40 -0
- data/lib/print_primes_table/options/default_option.rb +28 -0
- data/lib/print_primes_table/options/help_option.rb +47 -0
- data/lib/print_primes_table/options/only_primes_option.rb +29 -0
- data/lib/print_primes_table/primes.rb +52 -0
- data/lib/print_primes_table/validators/default_validator.rb +39 -0
- data/lib/print_primes_table/validators/error_message.rb +31 -0
- data/lib/print_primes_table/validators/help_validator.rb +28 -0
- data/lib/print_primes_table/version.rb +10 -0
- data/print_primes_table.gemspec +29 -0
- metadata +132 -0
@@ -0,0 +1,289 @@
|
|
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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: PrintPrimesTable::Options::OnlyPrimesOption
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../../';
|
20
|
+
framesUrl = "../../frames.html#!PrintPrimesTable/Options/OnlyPrimesOption.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (O)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../PrintPrimesTable.html" title="PrintPrimesTable (module)">PrintPrimesTable</a></span></span> » <span class='title'><span class='object_link'><a href="../Options.html" title="PrintPrimesTable::Options (module)">Options</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">OnlyPrimesOption</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: PrintPrimesTable::Options::OnlyPrimesOption
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">PrintPrimesTable::Options::OnlyPrimesOption</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/print_primes_table/options/only_primes_option.rb</dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>to print only a list of primes collection</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
<p class="tag_title">Author:</p>
|
113
|
+
<ul class="author">
|
114
|
+
|
115
|
+
<li>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<div class='inline'>
|
122
|
+
<p>Diego Hernán Piccinini Lagos</p>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
</li>
|
126
|
+
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<h2>
|
138
|
+
Class Method Summary
|
139
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
140
|
+
</h2>
|
141
|
+
|
142
|
+
<ul class="summary">
|
143
|
+
|
144
|
+
<li class="public ">
|
145
|
+
<span class="summary_signature">
|
146
|
+
|
147
|
+
<a href="#process-class_method" title="process (class method)">+ (Object) <strong>process</strong>(args, options) </a>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
</span>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<span class="summary_desc"><div class='inline'>
|
162
|
+
<p>process the input to print the list if it pass the
|
163
|
+
DefaultValidator.validate.</p>
|
164
|
+
</div></span>
|
165
|
+
|
166
|
+
</li>
|
167
|
+
|
168
|
+
|
169
|
+
</ul>
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
<div id="class_method_details" class="method_details_list">
|
175
|
+
<h2>Class Method Details</h2>
|
176
|
+
|
177
|
+
|
178
|
+
<div class="method_details first">
|
179
|
+
<h3 class="signature first" id="process-class_method">
|
180
|
+
|
181
|
+
+ (<tt>Object</tt>) <strong>process</strong>(args, options)
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
</h3><div class="docstring">
|
188
|
+
<div class="discussion">
|
189
|
+
|
190
|
+
<p>process the input to print the list if it pass the
|
191
|
+
DefaultValidator.validate</p>
|
192
|
+
|
193
|
+
|
194
|
+
</div>
|
195
|
+
</div>
|
196
|
+
<div class="tags">
|
197
|
+
<p class="tag_title">Parameters:</p>
|
198
|
+
<ul class="param">
|
199
|
+
|
200
|
+
<li>
|
201
|
+
|
202
|
+
<span class='name'>args</span>
|
203
|
+
|
204
|
+
|
205
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
—
|
210
|
+
<div class='inline'>
|
211
|
+
<p>the first argument is the quantity of primes collection</p>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
</li>
|
215
|
+
|
216
|
+
<li>
|
217
|
+
|
218
|
+
<span class='name'>options</span>
|
219
|
+
|
220
|
+
|
221
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
—
|
226
|
+
<div class='inline'>
|
227
|
+
<p>if in future we will want to add options</p>
|
228
|
+
</div>
|
229
|
+
|
230
|
+
</li>
|
231
|
+
|
232
|
+
</ul>
|
233
|
+
|
234
|
+
|
235
|
+
</div><table class="source_code">
|
236
|
+
<tr>
|
237
|
+
<td>
|
238
|
+
<pre class="lines">
|
239
|
+
|
240
|
+
|
241
|
+
12
|
242
|
+
13
|
243
|
+
14
|
244
|
+
15
|
245
|
+
16
|
246
|
+
17
|
247
|
+
18
|
248
|
+
19
|
249
|
+
20
|
250
|
+
21
|
251
|
+
22
|
252
|
+
23
|
253
|
+
24
|
254
|
+
25</pre>
|
255
|
+
</td>
|
256
|
+
<td>
|
257
|
+
<pre class="code"><span class="info file"># File 'lib/print_primes_table/options/only_primes_option.rb', line 12</span>
|
258
|
+
|
259
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_process'>process</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
260
|
+
<span class='id identifier rubyid_validator'>validator</span> <span class='op'>=</span> <span class='const'>Validators</span><span class='op'>::</span><span class='const'>DefaultValidator</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
261
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_validator'>validator</span> <span class='op'>==</span> <span class='symbol'>:valid</span>
|
262
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='op'>></span><span class='int'>0</span>
|
263
|
+
<span class='id identifier rubyid_total'>total</span> <span class='op'>=</span> <span class='const'>Integer</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
264
|
+
<span class='id identifier rubyid_primes'>primes</span> <span class='op'>=</span> <span class='const'>Primes</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='id identifier rubyid_total'>total</span>
|
265
|
+
<span class='kw'>else</span>
|
266
|
+
<span class='id identifier rubyid_primes'>primes</span><span class='op'>=</span> <span class='const'>Primes</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
267
|
+
<span class='kw'>end</span>
|
268
|
+
<span class='id identifier rubyid_primes'>primes</span><span class='period'>.</span><span class='id identifier rubyid_list_numbers'>list_numbers</span>
|
269
|
+
<span class='kw'>else</span>
|
270
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_validator'>validator</span>
|
271
|
+
<span class='kw'>end</span>
|
272
|
+
<span class='kw'>end</span></pre>
|
273
|
+
</td>
|
274
|
+
</tr>
|
275
|
+
</table>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
</div>
|
279
|
+
|
280
|
+
</div>
|
281
|
+
|
282
|
+
<div id="footer">
|
283
|
+
Generated on Thu Apr 9 11:19:35 2015 by
|
284
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
285
|
+
0.8.7.6 (ruby-2.0.0).
|
286
|
+
</div>
|
287
|
+
|
288
|
+
</body>
|
289
|
+
</html>
|
@@ -0,0 +1,496 @@
|
|
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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: PrintPrimesTable::Primes
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!PrintPrimesTable/Primes.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (P)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../PrintPrimesTable.html" title="PrintPrimesTable (module)">PrintPrimesTable</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Primes</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: PrintPrimesTable::Primes
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">PrintPrimesTable::Primes</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/print_primes_table/primes.rb</dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>To handle the primes numbers</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
<p class="tag_title">Author:</p>
|
113
|
+
<ul class="author">
|
114
|
+
|
115
|
+
<li>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<div class='inline'>
|
122
|
+
<p>Diego Hernán Piccinini Lagos</p>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
</li>
|
126
|
+
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<h2>
|
138
|
+
Instance Method Summary
|
139
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
140
|
+
</h2>
|
141
|
+
|
142
|
+
<ul class="summary">
|
143
|
+
|
144
|
+
<li class="public ">
|
145
|
+
<span class="summary_signature">
|
146
|
+
|
147
|
+
<a href="#fill_collection-instance_method" title="#fill_collection (instance method)">- (Object) <strong>fill_collection</strong> </a>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
</span>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<span class="summary_desc"><div class='inline'>
|
162
|
+
<p>fill the collection with primes number end when the collection.count is
|
163
|
+
equal total.</p>
|
164
|
+
</div></span>
|
165
|
+
|
166
|
+
</li>
|
167
|
+
|
168
|
+
|
169
|
+
<li class="public ">
|
170
|
+
<span class="summary_signature">
|
171
|
+
|
172
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Primes) <strong>initialize</strong>(total = DEFAULT_TOTAL) </a>
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
</span>
|
177
|
+
|
178
|
+
|
179
|
+
<span class="note title constructor">constructor</span>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
<span class="summary_desc"><div class='inline'>
|
189
|
+
<p>A new instance of Primes.</p>
|
190
|
+
</div></span>
|
191
|
+
|
192
|
+
</li>
|
193
|
+
|
194
|
+
|
195
|
+
<li class="public ">
|
196
|
+
<span class="summary_signature">
|
197
|
+
|
198
|
+
<a href="#list_numbers-instance_method" title="#list_numbers (instance method)">- (Object) <strong>list_numbers</strong> </a>
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
</span>
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
<span class="summary_desc"><div class='inline'>
|
213
|
+
<p>print the list of primes collection separed by tab.</p>
|
214
|
+
</div></span>
|
215
|
+
|
216
|
+
</li>
|
217
|
+
|
218
|
+
|
219
|
+
<li class="public ">
|
220
|
+
<span class="summary_signature">
|
221
|
+
|
222
|
+
<a href="#print_table-instance_method" title="#print_table (instance method)">- (Object) <strong>print_table</strong> </a>
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
</span>
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
<span class="summary_desc"><div class='inline'>
|
237
|
+
<p>print the table of TOTAL x TOTAL collection each coordinate contain the
|
238
|
+
product.</p>
|
239
|
+
</div></span>
|
240
|
+
|
241
|
+
</li>
|
242
|
+
|
243
|
+
|
244
|
+
</ul>
|
245
|
+
|
246
|
+
|
247
|
+
<div id="constructor_details" class="method_details_list">
|
248
|
+
<h2>Constructor Details</h2>
|
249
|
+
|
250
|
+
<div class="method_details first">
|
251
|
+
<h3 class="signature first" id="initialize-instance_method">
|
252
|
+
|
253
|
+
- (<tt><span class='object_link'><a href="" title="PrintPrimesTable::Primes (class)">Primes</a></span></tt>) <strong>initialize</strong>(total = DEFAULT_TOTAL)
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
</h3><div class="docstring">
|
260
|
+
<div class="discussion">
|
261
|
+
|
262
|
+
<p>Returns a new instance of Primes</p>
|
263
|
+
|
264
|
+
|
265
|
+
</div>
|
266
|
+
</div>
|
267
|
+
<div class="tags">
|
268
|
+
<p class="tag_title">Parameters:</p>
|
269
|
+
<ul class="param">
|
270
|
+
|
271
|
+
<li>
|
272
|
+
|
273
|
+
<span class='name'>total</span>
|
274
|
+
|
275
|
+
|
276
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
277
|
+
|
278
|
+
|
279
|
+
<em class="default">(defaults to: <tt>DEFAULT_TOTAL</tt>)</em>
|
280
|
+
|
281
|
+
|
282
|
+
—
|
283
|
+
<div class='inline'>
|
284
|
+
<p>the quantity of the primes collection</p>
|
285
|
+
</div>
|
286
|
+
|
287
|
+
</li>
|
288
|
+
|
289
|
+
</ul>
|
290
|
+
|
291
|
+
|
292
|
+
</div><table class="source_code">
|
293
|
+
<tr>
|
294
|
+
<td>
|
295
|
+
<pre class="lines">
|
296
|
+
|
297
|
+
|
298
|
+
11
|
299
|
+
12
|
300
|
+
13
|
301
|
+
14
|
302
|
+
15</pre>
|
303
|
+
</td>
|
304
|
+
<td>
|
305
|
+
<pre class="code"><span class="info file"># File 'lib/print_primes_table/primes.rb', line 11</span>
|
306
|
+
|
307
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_total'>total</span> <span class='op'>=</span> <span class='const'>DEFAULT_TOTAL</span><span class='rparen'>)</span>
|
308
|
+
<span class='ivar'>@total</span><span class='op'>=</span><span class='id identifier rubyid_total'>total</span>
|
309
|
+
<span class='ivar'>@collection</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
310
|
+
<span class='id identifier rubyid_fill_collection'>fill_collection</span>
|
311
|
+
<span class='kw'>end</span></pre>
|
312
|
+
</td>
|
313
|
+
</tr>
|
314
|
+
</table>
|
315
|
+
</div>
|
316
|
+
|
317
|
+
</div>
|
318
|
+
|
319
|
+
|
320
|
+
<div id="instance_method_details" class="method_details_list">
|
321
|
+
<h2>Instance Method Details</h2>
|
322
|
+
|
323
|
+
|
324
|
+
<div class="method_details first">
|
325
|
+
<h3 class="signature first" id="fill_collection-instance_method">
|
326
|
+
|
327
|
+
- (<tt>Object</tt>) <strong>fill_collection</strong>
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
</h3><div class="docstring">
|
334
|
+
<div class="discussion">
|
335
|
+
|
336
|
+
<p>fill the collection with primes number end when the collection.count is
|
337
|
+
equal total</p>
|
338
|
+
|
339
|
+
|
340
|
+
</div>
|
341
|
+
</div>
|
342
|
+
<div class="tags">
|
343
|
+
|
344
|
+
|
345
|
+
</div><table class="source_code">
|
346
|
+
<tr>
|
347
|
+
<td>
|
348
|
+
<pre class="lines">
|
349
|
+
|
350
|
+
|
351
|
+
18
|
352
|
+
19
|
353
|
+
20
|
354
|
+
21
|
355
|
+
22
|
356
|
+
23
|
357
|
+
24
|
358
|
+
25
|
359
|
+
26
|
360
|
+
27
|
361
|
+
28
|
362
|
+
29
|
363
|
+
30
|
364
|
+
31
|
365
|
+
32</pre>
|
366
|
+
</td>
|
367
|
+
<td>
|
368
|
+
<pre class="code"><span class="info file"># File 'lib/print_primes_table/primes.rb', line 18</span>
|
369
|
+
|
370
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_fill_collection'>fill_collection</span>
|
371
|
+
<span class='id identifier rubyid_eval_number'>eval_number</span> <span class='op'>=</span> <span class='int'>2</span>
|
372
|
+
<span class='kw'>begin</span>
|
373
|
+
<span class='id identifier rubyid_has_divisors'>has_divisors</span> <span class='op'>=</span> <span class='kw'>false</span>
|
374
|
+
<span class='ivar'>@collection</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_prime'>prime</span><span class='op'>|</span>
|
375
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_eval_number'>eval_number</span> <span class='op'>%</span> <span class='id identifier rubyid_prime'>prime</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>0</span>
|
376
|
+
<span class='id identifier rubyid_has_divisors'>has_divisors</span> <span class='op'>=</span> <span class='kw'>true</span>
|
377
|
+
<span class='kw'>break</span>
|
378
|
+
<span class='kw'>end</span>
|
379
|
+
<span class='kw'>end</span>
|
380
|
+
<span class='comment'># only the numbers has not divisors are primes
|
381
|
+
</span> <span class='ivar'>@collection</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_eval_number'>eval_number</span> <span class='kw'>unless</span> <span class='id identifier rubyid_has_divisors'>has_divisors</span>
|
382
|
+
<span class='id identifier rubyid_eval_number'>eval_number</span> <span class='op'>+=</span> <span class='int'>1</span>
|
383
|
+
<span class='kw'>end</span> <span class='kw'>until</span> <span class='ivar'>@collection</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>==</span> <span class='ivar'>@total</span>
|
384
|
+
<span class='kw'>end</span></pre>
|
385
|
+
</td>
|
386
|
+
</tr>
|
387
|
+
</table>
|
388
|
+
</div>
|
389
|
+
|
390
|
+
<div class="method_details ">
|
391
|
+
<h3 class="signature " id="list_numbers-instance_method">
|
392
|
+
|
393
|
+
- (<tt>Object</tt>) <strong>list_numbers</strong>
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
</h3><div class="docstring">
|
400
|
+
<div class="discussion">
|
401
|
+
|
402
|
+
<p>print the list of primes collection separed by tab</p>
|
403
|
+
|
404
|
+
|
405
|
+
</div>
|
406
|
+
</div>
|
407
|
+
<div class="tags">
|
408
|
+
|
409
|
+
|
410
|
+
</div><table class="source_code">
|
411
|
+
<tr>
|
412
|
+
<td>
|
413
|
+
<pre class="lines">
|
414
|
+
|
415
|
+
|
416
|
+
34
|
417
|
+
35
|
418
|
+
36</pre>
|
419
|
+
</td>
|
420
|
+
<td>
|
421
|
+
<pre class="code"><span class="info file"># File 'lib/print_primes_table/primes.rb', line 34</span>
|
422
|
+
|
423
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_list_numbers'>list_numbers</span>
|
424
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='ivar'>@collection</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\t</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
425
|
+
<span class='kw'>end</span></pre>
|
426
|
+
</td>
|
427
|
+
</tr>
|
428
|
+
</table>
|
429
|
+
</div>
|
430
|
+
|
431
|
+
<div class="method_details ">
|
432
|
+
<h3 class="signature " id="print_table-instance_method">
|
433
|
+
|
434
|
+
- (<tt>Object</tt>) <strong>print_table</strong>
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
</h3><div class="docstring">
|
441
|
+
<div class="discussion">
|
442
|
+
|
443
|
+
<p>print the table of TOTAL x TOTAL collection each coordinate contain the
|
444
|
+
product</p>
|
445
|
+
|
446
|
+
|
447
|
+
</div>
|
448
|
+
</div>
|
449
|
+
<div class="tags">
|
450
|
+
|
451
|
+
|
452
|
+
</div><table class="source_code">
|
453
|
+
<tr>
|
454
|
+
<td>
|
455
|
+
<pre class="lines">
|
456
|
+
|
457
|
+
|
458
|
+
40
|
459
|
+
41
|
460
|
+
42
|
461
|
+
43
|
462
|
+
44
|
463
|
+
45
|
464
|
+
46
|
465
|
+
47
|
466
|
+
48</pre>
|
467
|
+
</td>
|
468
|
+
<td>
|
469
|
+
<pre class="code"><span class="info file"># File 'lib/print_primes_table/primes.rb', line 40</span>
|
470
|
+
|
471
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_print_table'>print_table</span>
|
472
|
+
<span class='id identifier rubyid_headings'>headings</span> <span class='op'>=</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> </span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='ivar'>@collection</span>
|
473
|
+
<span class='id identifier rubyid_rows'>rows</span><span class='op'>=</span><span class='lbracket'>[</span><span class='rbracket'>]</span>
|
474
|
+
<span class='ivar'>@collection</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_prime'>prime</span><span class='op'>|</span>
|
475
|
+
<span class='id identifier rubyid_rows'>rows</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='lbracket'>[</span><span class='id identifier rubyid_prime'>prime</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='ivar'>@collection</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='op'>|</span> <span class='id identifier rubyid_prime'>prime</span> <span class='op'>*</span> <span class='id identifier rubyid_a'>a</span><span class='rbrace'>}</span>
|
476
|
+
<span class='kw'>end</span>
|
477
|
+
<span class='id identifier rubyid_table'>table</span> <span class='op'>=</span> <span class='const'>Terminal</span><span class='op'>::</span><span class='const'>Table</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='symbol'>:headings</span> <span class='op'>=></span> <span class='id identifier rubyid_headings'>headings</span><span class='comma'>,</span> <span class='symbol'>:rows</span> <span class='op'>=></span> <span class='id identifier rubyid_rows'>rows</span>
|
478
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_table'>table</span>
|
479
|
+
<span class='kw'>end</span></pre>
|
480
|
+
</td>
|
481
|
+
</tr>
|
482
|
+
</table>
|
483
|
+
</div>
|
484
|
+
|
485
|
+
</div>
|
486
|
+
|
487
|
+
</div>
|
488
|
+
|
489
|
+
<div id="footer">
|
490
|
+
Generated on Thu Apr 9 11:19:34 2015 by
|
491
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
492
|
+
0.8.7.6 (ruby-2.0.0).
|
493
|
+
</div>
|
494
|
+
|
495
|
+
</body>
|
496
|
+
</html>
|