sycsvpro 0.1.2 → 0.1.3
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/Gemfile.lock +3 -1
- data/README.md +21 -8
- data/README.rdoc +3 -2
- data/bin/sycsvpro +17 -6
- data/lib/sycsvpro/aggregator.rb +16 -5
- data/lib/sycsvpro/calculator.rb +19 -5
- data/lib/sycsvpro/counter.rb +17 -7
- data/lib/sycsvpro/dsl.rb +43 -0
- data/lib/sycsvpro/filter.rb +0 -7
- data/lib/sycsvpro/sorter.rb +28 -8
- data/lib/sycsvpro/version.rb +1 -1
- data/spec/sycsvpro/sorter_spec.rb +50 -0
- data/sycsvpro.gemspec +1 -0
- metadata +18 -66
- data/html/Dsl.html +0 -277
- data/html/Object.html +0 -187
- data/html/README_rdoc.html +0 -187
- data/html/Sycsvpro/Aggregator.html +0 -482
- data/html/Sycsvpro/Allocator.html +0 -293
- data/html/Sycsvpro/Analyzer.html +0 -239
- data/html/Sycsvpro/Calculator.html +0 -407
- data/html/Sycsvpro/Collector.html +0 -281
- data/html/Sycsvpro/ColumnFilter.html +0 -170
- data/html/Sycsvpro/ColumnTypeFilter.html +0 -191
- data/html/Sycsvpro/Counter.html +0 -492
- data/html/Sycsvpro/Extractor.html +0 -269
- data/html/Sycsvpro/Filter.html +0 -411
- data/html/Sycsvpro/Header.html +0 -239
- data/html/Sycsvpro/Inserter.html +0 -275
- data/html/Sycsvpro/Mapper.html +0 -288
- data/html/Sycsvpro/Profiler.html +0 -234
- data/html/Sycsvpro/RowFilter.html +0 -175
- data/html/Sycsvpro/ScriptCreator.html +0 -235
- data/html/Sycsvpro/ScriptList.html +0 -281
- data/html/Sycsvpro/Sorter.html +0 -346
- data/html/Sycsvpro.html +0 -155
- data/html/created.rid +0 -24
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/fonts.css +0 -167
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +0 -225
- data/html/js/darkfish.js +0 -140
- data/html/js/jquery.js +0 -18
- data/html/js/navigation.js +0 -142
- data/html/js/search.js +0 -109
- data/html/js/search_index.js +0 -1
- data/html/js/searcher.js +0 -228
- data/html/rdoc.css +0 -580
- data/html/table_of_contents.html +0 -347
data/html/Sycsvpro/Counter.html
DELETED
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
|
|
7
|
-
<title>class Sycsvpro::Counter - Your application title</title>
|
|
8
|
-
|
|
9
|
-
<link href="../fonts.css" rel="stylesheet">
|
|
10
|
-
<link href="../rdoc.css" rel="stylesheet">
|
|
11
|
-
|
|
12
|
-
<script type="text/javascript">
|
|
13
|
-
var rdoc_rel_prefix = "../";
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<script src="../js/jquery.js"></script>
|
|
17
|
-
<script src="../js/navigation.js"></script>
|
|
18
|
-
<script src="../js/search_index.js"></script>
|
|
19
|
-
<script src="../js/search.js"></script>
|
|
20
|
-
<script src="../js/searcher.js"></script>
|
|
21
|
-
<script src="../js/darkfish.js"></script>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<body id="top" role="document" class="class">
|
|
25
|
-
<nav role="navigation">
|
|
26
|
-
<div id="project-navigation">
|
|
27
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
28
|
-
<h2>
|
|
29
|
-
<a href="../index.html" rel="home">Home</a>
|
|
30
|
-
</h2>
|
|
31
|
-
|
|
32
|
-
<div id="table-of-contents-navigation">
|
|
33
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
|
34
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
|
35
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
40
|
-
<form action="#" method="get" accept-charset="utf-8">
|
|
41
|
-
<div id="search-field-wrapper">
|
|
42
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
|
43
|
-
aria-autocomplete="list" aria-controls="search-results"
|
|
44
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
45
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<ul id="search-results" aria-label="Search Results"
|
|
49
|
-
aria-busy="false" aria-expanded="false"
|
|
50
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
|
51
|
-
</form>
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<div id="class-metadata">
|
|
59
|
-
|
|
60
|
-
<div id="parent-class-section" class="nav-section">
|
|
61
|
-
<h3>Parent</h3>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<p class="link"><a href="../Object.html">Object</a>
|
|
65
|
-
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<div id="includes-section" class="nav-section">
|
|
69
|
-
<h3>Included Modules</h3>
|
|
70
|
-
|
|
71
|
-
<ul class="link-list">
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<li><a class="include" href="../Dsl.html">Dsl</a>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</ul>
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<!-- Method Quickref -->
|
|
82
|
-
<div id="method-list-section" class="nav-section">
|
|
83
|
-
<h3>Methods</h3>
|
|
84
|
-
|
|
85
|
-
<ul class="link-list" role="directory">
|
|
86
|
-
|
|
87
|
-
<li ><a href="#method-c-new">::new</a>
|
|
88
|
-
|
|
89
|
-
<li ><a href="#method-i-execute">#execute</a>
|
|
90
|
-
|
|
91
|
-
<li ><a href="#method-i-process_count">#process_count</a>
|
|
92
|
-
|
|
93
|
-
<li ><a href="#method-i-write_result">#write_result</a>
|
|
94
|
-
|
|
95
|
-
</ul>
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
</div>
|
|
99
|
-
</nav>
|
|
100
|
-
|
|
101
|
-
<main role="main" aria-labelledby="class-Sycsvpro::Counter">
|
|
102
|
-
<h1 id="class-Sycsvpro::Counter" class="class">
|
|
103
|
-
class Sycsvpro::Counter
|
|
104
|
-
</h1>
|
|
105
|
-
|
|
106
|
-
<section class="description">
|
|
107
|
-
|
|
108
|
-
<p><a href="Counter.html">Counter</a> counts values and uses the values as
|
|
109
|
-
column names and uses the count as the column value</p>
|
|
110
|
-
|
|
111
|
-
</section>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
<section class="attribute-method-details" class="method-section">
|
|
125
|
-
<header>
|
|
126
|
-
<h3>Attributes</h3>
|
|
127
|
-
</header>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<div id="attribute-i-col_filter" class="method-detail">
|
|
131
|
-
<div class="method-heading attribute-method-heading">
|
|
132
|
-
<span class="method-name">col_filter</span><span
|
|
133
|
-
class="attribute-access-type">[R]</span>
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
|
-
<div class="method-description">
|
|
137
|
-
|
|
138
|
-
<p>filter that is used for columns</p>
|
|
139
|
-
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
|
|
143
|
-
<div id="attribute-i-heading" class="method-detail">
|
|
144
|
-
<div class="method-heading attribute-method-heading">
|
|
145
|
-
<span class="method-name">heading</span><span
|
|
146
|
-
class="attribute-access-type">[R]</span>
|
|
147
|
-
</div>
|
|
148
|
-
|
|
149
|
-
<div class="method-description">
|
|
150
|
-
|
|
151
|
-
<p>header of the out file</p>
|
|
152
|
-
|
|
153
|
-
</div>
|
|
154
|
-
</div>
|
|
155
|
-
|
|
156
|
-
<div id="attribute-i-infile" class="method-detail">
|
|
157
|
-
<div class="method-heading attribute-method-heading">
|
|
158
|
-
<span class="method-name">infile</span><span
|
|
159
|
-
class="attribute-access-type">[R]</span>
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
|
-
<div class="method-description">
|
|
163
|
-
|
|
164
|
-
<p>infile contains the data that is operated on</p>
|
|
165
|
-
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
|
|
169
|
-
<div id="attribute-i-key_columns" class="method-detail">
|
|
170
|
-
<div class="method-heading attribute-method-heading">
|
|
171
|
-
<span class="method-name">key_columns</span><span
|
|
172
|
-
class="attribute-access-type">[R]</span>
|
|
173
|
-
</div>
|
|
174
|
-
|
|
175
|
-
<div class="method-description">
|
|
176
|
-
|
|
177
|
-
<p>values are assigned to the key columns</p>
|
|
178
|
-
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
|
|
182
|
-
<div id="attribute-i-key_titles" class="method-detail">
|
|
183
|
-
<div class="method-heading attribute-method-heading">
|
|
184
|
-
<span class="method-name">key_titles</span><span
|
|
185
|
-
class="attribute-access-type">[R]</span>
|
|
186
|
-
</div>
|
|
187
|
-
|
|
188
|
-
<div class="method-description">
|
|
189
|
-
|
|
190
|
-
<p>key columns headers</p>
|
|
191
|
-
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
|
|
195
|
-
<div id="attribute-i-key_values" class="method-detail">
|
|
196
|
-
<div class="method-heading attribute-method-heading">
|
|
197
|
-
<span class="method-name">key_values</span><span
|
|
198
|
-
class="attribute-access-type">[R]</span>
|
|
199
|
-
</div>
|
|
200
|
-
|
|
201
|
-
<div class="method-description">
|
|
202
|
-
|
|
203
|
-
<p>values that are assigned to the key column</p>
|
|
204
|
-
|
|
205
|
-
</div>
|
|
206
|
-
</div>
|
|
207
|
-
|
|
208
|
-
<div id="attribute-i-outfile" class="method-detail">
|
|
209
|
-
<div class="method-heading attribute-method-heading">
|
|
210
|
-
<span class="method-name">outfile</span><span
|
|
211
|
-
class="attribute-access-type">[R]</span>
|
|
212
|
-
</div>
|
|
213
|
-
|
|
214
|
-
<div class="method-description">
|
|
215
|
-
|
|
216
|
-
<p>outfile is the file where the result is written to</p>
|
|
217
|
-
|
|
218
|
-
</div>
|
|
219
|
-
</div>
|
|
220
|
-
|
|
221
|
-
<div id="attribute-i-row_filter" class="method-detail">
|
|
222
|
-
<div class="method-heading attribute-method-heading">
|
|
223
|
-
<span class="method-name">row_filter</span><span
|
|
224
|
-
class="attribute-access-type">[R]</span>
|
|
225
|
-
</div>
|
|
226
|
-
|
|
227
|
-
<div class="method-description">
|
|
228
|
-
|
|
229
|
-
<p>filter that is used for rows</p>
|
|
230
|
-
|
|
231
|
-
</div>
|
|
232
|
-
</div>
|
|
233
|
-
|
|
234
|
-
<div id="attribute-i-sum_col_title" class="method-detail">
|
|
235
|
-
<div class="method-heading attribute-method-heading">
|
|
236
|
-
<span class="method-name">sum_col_title</span><span
|
|
237
|
-
class="attribute-access-type">[R]</span>
|
|
238
|
-
</div>
|
|
239
|
-
|
|
240
|
-
<div class="method-description">
|
|
241
|
-
|
|
242
|
-
<p>Title of the sum column</p>
|
|
243
|
-
|
|
244
|
-
</div>
|
|
245
|
-
</div>
|
|
246
|
-
|
|
247
|
-
<div id="attribute-i-sum_row" class="method-detail">
|
|
248
|
-
<div class="method-heading attribute-method-heading">
|
|
249
|
-
<span class="method-name">sum_row</span><span
|
|
250
|
-
class="attribute-access-type">[R]</span>
|
|
251
|
-
</div>
|
|
252
|
-
|
|
253
|
-
<div class="method-description">
|
|
254
|
-
|
|
255
|
-
<p>row where to add the sums of the columns</p>
|
|
256
|
-
|
|
257
|
-
</div>
|
|
258
|
-
</div>
|
|
259
|
-
|
|
260
|
-
<div id="attribute-i-sum_row_title" class="method-detail">
|
|
261
|
-
<div class="method-heading attribute-method-heading">
|
|
262
|
-
<span class="method-name">sum_row_title</span><span
|
|
263
|
-
class="attribute-access-type">[R]</span>
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
<div class="method-description">
|
|
267
|
-
|
|
268
|
-
<p>Title of the sum row</p>
|
|
269
|
-
|
|
270
|
-
</div>
|
|
271
|
-
</div>
|
|
272
|
-
|
|
273
|
-
<div id="attribute-i-sums" class="method-detail">
|
|
274
|
-
<div class="method-heading attribute-method-heading">
|
|
275
|
-
<span class="method-name">sums</span><span
|
|
276
|
-
class="attribute-access-type">[R]</span>
|
|
277
|
-
</div>
|
|
278
|
-
|
|
279
|
-
<div class="method-description">
|
|
280
|
-
|
|
281
|
-
<p>sums of the column values</p>
|
|
282
|
-
|
|
283
|
-
</div>
|
|
284
|
-
</div>
|
|
285
|
-
|
|
286
|
-
</section>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
|
291
|
-
<header>
|
|
292
|
-
<h3>Public Class Methods</h3>
|
|
293
|
-
</header>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
<div id="method-c-new" class="method-detail ">
|
|
297
|
-
|
|
298
|
-
<div class="method-heading">
|
|
299
|
-
<span class="method-name">new</span><span
|
|
300
|
-
class="method-args">(options={})</span>
|
|
301
|
-
|
|
302
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
303
|
-
|
|
304
|
-
</div>
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
<div class="method-description">
|
|
308
|
-
|
|
309
|
-
<p>Creates a new counter. Takes as attributes infile, outfile, key, rows,
|
|
310
|
-
cols, date-format and indicator whether to add a sum row</p>
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
<div class="method-source-code" id="new-source">
|
|
316
|
-
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 41</span>
|
|
317
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
|
|
318
|
-
<span class="ruby-ivar">@infile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:infile</span>]
|
|
319
|
-
<span class="ruby-ivar">@outfile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:outfile</span>]
|
|
320
|
-
<span class="ruby-identifier">init_key_columns</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:key</span>])
|
|
321
|
-
<span class="ruby-ivar">@row_filter</span> = <span class="ruby-constant">RowFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:rows</span>])
|
|
322
|
-
<span class="ruby-ivar">@col_filter</span> = <span class="ruby-constant">ColumnFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:cols</span>], <span class="ruby-identifier">df</span><span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:df</span>])
|
|
323
|
-
<span class="ruby-ivar">@key_values</span> = {}
|
|
324
|
-
<span class="ruby-ivar">@heading</span> = []
|
|
325
|
-
<span class="ruby-identifier">init_sum_scheme</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:sum</span>])
|
|
326
|
-
<span class="ruby-ivar">@sums</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>)
|
|
327
|
-
<span class="ruby-keyword">end</span></pre>
|
|
328
|
-
</div>
|
|
329
|
-
|
|
330
|
-
</div>
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
</div>
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
</section>
|
|
339
|
-
|
|
340
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
|
341
|
-
<header>
|
|
342
|
-
<h3>Public Instance Methods</h3>
|
|
343
|
-
</header>
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
<div id="method-i-execute" class="method-detail ">
|
|
347
|
-
|
|
348
|
-
<div class="method-heading">
|
|
349
|
-
<span class="method-name">execute</span><span
|
|
350
|
-
class="method-args">()</span>
|
|
351
|
-
|
|
352
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
353
|
-
|
|
354
|
-
</div>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
<div class="method-description">
|
|
358
|
-
|
|
359
|
-
<p>Executes the counter</p>
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
<div class="method-source-code" id="execute-source">
|
|
365
|
-
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 54</span>
|
|
366
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
|
|
367
|
-
<span class="ruby-identifier">process_count</span>
|
|
368
|
-
<span class="ruby-identifier">write_result</span>
|
|
369
|
-
<span class="ruby-keyword">end</span></pre>
|
|
370
|
-
</div>
|
|
371
|
-
|
|
372
|
-
</div>
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
</div>
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
<div id="method-i-process_count" class="method-detail ">
|
|
381
|
-
|
|
382
|
-
<div class="method-heading">
|
|
383
|
-
<span class="method-name">process_count</span><span
|
|
384
|
-
class="method-args">()</span>
|
|
385
|
-
|
|
386
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
387
|
-
|
|
388
|
-
</div>
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
<div class="method-description">
|
|
392
|
-
|
|
393
|
-
<p>Processes the counting on the in file</p>
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
<div class="method-source-code" id="process_count-source">
|
|
399
|
-
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 60</span>
|
|
400
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">process_count</span>
|
|
401
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">infile</span>).<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
|
|
402
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">col_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">row_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>, <span class="ruby-identifier">row</span><span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>))
|
|
403
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">empty?</span>
|
|
404
|
-
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">unstring</span>(<span class="ruby-identifier">line</span>).<span class="ruby-identifier">split</span>(<span class="ruby-string">';'</span>).<span class="ruby-identifier">values_at</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">key_columns</span>)
|
|
405
|
-
<span class="ruby-identifier">key_value</span> = <span class="ruby-identifier">key_values</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">key_values</span>[<span class="ruby-identifier">key</span>] = { <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-identifier">key</span>,
|
|
406
|
-
<span class="ruby-identifier">elements</span><span class="ruby-operator">:</span> <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>),
|
|
407
|
-
<span class="ruby-identifier">sum</span><span class="ruby-operator">:</span> <span class="ruby-value">0</span> }
|
|
408
|
-
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">';'</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">column</span><span class="ruby-operator">|</span>
|
|
409
|
-
<span class="ruby-identifier">heading</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">column</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">heading</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">column</span>).<span class="ruby-identifier">nil?</span>
|
|
410
|
-
<span class="ruby-identifier">key_value</span>[<span class="ruby-value">:elements</span>][<span class="ruby-identifier">column</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
|
411
|
-
<span class="ruby-identifier">key_value</span>[<span class="ruby-value">:sum</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
|
412
|
-
<span class="ruby-identifier">sums</span>[<span class="ruby-identifier">column</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
|
413
|
-
<span class="ruby-keyword">end</span>
|
|
414
|
-
<span class="ruby-keyword">end</span>
|
|
415
|
-
<span class="ruby-keyword">end</span>
|
|
416
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">sum_col_title</span>.<span class="ruby-identifier">nil?</span>
|
|
417
|
-
<span class="ruby-identifier">heading</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">sum_col_title</span>
|
|
418
|
-
<span class="ruby-identifier">sums</span>[<span class="ruby-identifier">sum_col_title</span>] = <span class="ruby-identifier">sums</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">:+</span>)
|
|
419
|
-
<span class="ruby-keyword">end</span>
|
|
420
|
-
<span class="ruby-keyword">end</span></pre>
|
|
421
|
-
</div>
|
|
422
|
-
|
|
423
|
-
</div>
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
</div>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
<div id="method-i-write_result" class="method-detail ">
|
|
432
|
-
|
|
433
|
-
<div class="method-heading">
|
|
434
|
-
<span class="method-name">write_result</span><span
|
|
435
|
-
class="method-args">()</span>
|
|
436
|
-
|
|
437
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
438
|
-
|
|
439
|
-
</div>
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
<div class="method-description">
|
|
443
|
-
|
|
444
|
-
<p>Writes the count results</p>
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
<div class="method-source-code" id="write_result-source">
|
|
450
|
-
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 83</span>
|
|
451
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write_result</span>
|
|
452
|
-
<span class="ruby-identifier">sum_line</span> = [<span class="ruby-identifier">sum_row_title</span>] <span class="ruby-operator">+</span> [<span class="ruby-string">''</span>] <span class="ruby-operator">*</span> (<span class="ruby-identifier">key_titles</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
|
|
453
|
-
<span class="ruby-identifier">heading</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
|
|
454
|
-
<span class="ruby-identifier">sum_line</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">sums</span>[<span class="ruby-identifier">h</span>]
|
|
455
|
-
<span class="ruby-keyword">end</span>
|
|
456
|
-
<span class="ruby-identifier">row</span> = <span class="ruby-value">0</span>;
|
|
457
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">outfile</span>, <span class="ruby-string">'w'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
|
|
458
|
-
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">sum_line</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">row</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sum_row</span> ; <span class="ruby-identifier">row</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
|
459
|
-
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> (<span class="ruby-identifier">key_titles</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">heading</span>.<span class="ruby-identifier">sort</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>)
|
|
460
|
-
<span class="ruby-identifier">key_values</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
|
461
|
-
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">sum_line</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">row</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sum_row</span> ; <span class="ruby-identifier">row</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
|
462
|
-
<span class="ruby-identifier">line</span> = [<span class="ruby-identifier">k</span>]
|
|
463
|
-
<span class="ruby-identifier">heading</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
|
|
464
|
-
<span class="ruby-identifier">line</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:elements</span>][<span class="ruby-identifier">h</span>] <span class="ruby-keyword">unless</span> <span class="ruby-identifier">h</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sum_col_title</span>
|
|
465
|
-
<span class="ruby-keyword">end</span>
|
|
466
|
-
<span class="ruby-identifier">line</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:sum</span>] <span class="ruby-keyword">unless</span> <span class="ruby-identifier">sum_col_title</span>.<span class="ruby-identifier">nil?</span>
|
|
467
|
-
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>)
|
|
468
|
-
<span class="ruby-keyword">end</span>
|
|
469
|
-
<span class="ruby-keyword">end</span>
|
|
470
|
-
<span class="ruby-keyword">end</span></pre>
|
|
471
|
-
</div>
|
|
472
|
-
|
|
473
|
-
</div>
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
</div>
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
</section>
|
|
482
|
-
|
|
483
|
-
</section>
|
|
484
|
-
</main>
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
<footer id="validator-badges" role="contentinfo">
|
|
488
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
489
|
-
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
|
490
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
491
|
-
</footer>
|
|
492
|
-
|