sycsvpro 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 200bdc00de01fd102bec6290071adb632baec288
4
- data.tar.gz: a26adffa7877ac00cf6cf2bcb5902f3842db5992
3
+ metadata.gz: 39f66722b9a55455e899ca7a011b6d562f77854a
4
+ data.tar.gz: 49ad0894d735625b689e904bedc50d551271ad7c
5
5
  SHA512:
6
- metadata.gz: fda3aaaefbdd73d869c5c4ff879f60902ea15158671076775a49183bc44db19e883f600ab00f10b7a9c533eaf15977a41c0c7611332b48e19a82ec6ad8b04630
7
- data.tar.gz: 5035fca1649a5c2457c50a2eacca90396bda949509b70072e7ac460f31daf6e79d8f82dee2648c64767fc386d59c438dda6ba3db553a322bdcd622dcc23f3b3a
6
+ metadata.gz: b9761749882a98ab040eaba00e2e80c856341ead1b19cf2b897eb4a5a851af90740cd79bd2804f0c461ed87526a313a555b3877f11cf1a2902f1b1fcd1f8aaee
7
+ data.tar.gz: 61654ae343a83fdfb87f531aa0c62c36eec85fd9aa0257863d99bfdbfeaff311e645d808782d48779c61b26a5acf015692aa71d2cf1c32b745b4065925c5962a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sycsvpro (0.0.6)
4
+ sycsvpro (0.0.7)
5
5
  gli (= 2.9.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -3,15 +3,17 @@ syc-svpro
3
3
 
4
4
  Processing of csv files. *sycsvpro* offers following functions
5
5
 
6
- * analyze csv file
6
+ * analyze a csv file
7
7
  * extract rows and columns from a file
8
8
  * collect values of rows and assign them to categories
9
9
  * map column values to new values
10
10
  * allocate column values to a key column (since version 0.0.4)
11
11
  * count values in columns and use the value as column name
12
12
  * arithmetic operations on values of columns
13
+ * sort rows base on columns
14
+ * insert rows to a csv-file (since version 0.0.8)
13
15
  * create or edit a Ruby script
14
- * list scripts available optionally with methods
16
+ * list scripts available optionally with methods (since version 0.0.7)
15
17
  * execute a Ruby script file that operates a csv file
16
18
 
17
19
  To get help type
@@ -22,16 +24,15 @@ In the following examples we assume the following file
22
24
 
23
25
  ```
24
26
  customer;machine;control;drive;motor;date;contract
25
- hello;h1;con123;dri120;mot100;1.12.3013;1
26
- hello;h2;con123;dri130;mot110;1.12.3013;1
27
- indix;i1;con456;dri130;mot090;1.12.3013;1
28
- chiro;c1;con333;dri110;mot100;1.12.3013;1
29
- chiro;c2;con331;dri100;mot130;1.12.3013;1
27
+ hello;h1;con123;dri120;mot100;1.01.3013;1
28
+ hello;h2;con123;dri130;mot110;1.02.3012;1
29
+ indix;i1;con456;dri130;mot090;5.11.3013;1
30
+ chiro;c1;con333;dri110;mot100;1.10.3011;1
31
+ chiro;c2;con331;dri100;mot130;3.05.3010;1
30
32
  ```
31
33
 
32
34
  Analyze
33
35
  -------
34
-
35
36
  Analyze the content of the provided file *in.csv*
36
37
 
37
38
  $ sycsvpro -f in.csv analyze
@@ -50,14 +51,12 @@ Analyze the content of the provided file *in.csv*
50
51
 
51
52
  Extract
52
53
  -------
53
-
54
54
  Extract row 1,2 and 10-20 as well as columns 4 and 6-7
55
55
 
56
56
  $ sycsvpro -f in.csv -o out.csv extract -r 1,2,10-20 -c 4,6-7
57
57
 
58
58
  Collect
59
59
  -------
60
-
61
60
  Collect all product rows (2, 3 and 4) to the category product
62
61
 
63
62
  $ sycsvpro -f in.csv -o out.csv collect -r 2-20 -c products:2-4
@@ -78,7 +77,6 @@ Collect all product rows (2, 3 and 4) to the category product
78
77
 
79
78
  Map
80
79
  ---
81
-
82
80
  Map the product names to new names
83
81
 
84
82
  The mapping file (mapping) uses the result from the collect command above
@@ -110,7 +108,6 @@ Allocate all the machine types to the customer
110
108
 
111
109
  Count
112
110
  -----
113
-
114
111
  Count all customers (key column) in rows 2 to 20 that have machines that start with *h* and have a contract valid beginning after 1.1.2000. Add a sum row with title Total at column 1
115
112
 
116
113
  $ sycsvpro -f in.csv -o out.csv count -r 2-20 -k 0 -c 1:/^h/,5:">1.1.2000" --df "%d.%m.%Y" -s "Total:1"
@@ -126,18 +123,35 @@ The result in file out.csv is
126
123
 
127
124
  Calc
128
125
  ----
129
-
130
126
  Process arithmetic operations on the contract count and create a target column
131
127
 
132
128
  $ sycsvpro -f in.csv -o out.csv calc -r 2-20 -h *,target -c 6:*2,7:target=c6*10
133
129
 
134
130
  $ cat out.csv
135
131
  customer;machine;control;drive;motor;date;contract;target
136
- hello;h1;con123;dri120;mot100;1.12.3013;2;20
137
- hello;h2;con123;dri130;mot110;1.12.3013;2;20
138
- indix;i1;con456;dri130;mot090;1.12.3013;2;20
139
- chiro;c1;con333;dri110;mot100;1.12.3013;2;20
140
- chiro;c2;con331;dri100;mot130;1.12.3013;2;20
132
+ hello;h1;con123;dri120;mot100;1.01.3013;1
133
+ hello;h2;con123;dri130;mot110;1.02.3012;1
134
+ indix;i1;con456;dri130;mot090;5.11.3013;1
135
+ chiro;c1;con333;dri110;mot100;1.10.3011;1
136
+ chiro;c2;con331;dri100;mot130;3.05.3010;1
137
+
138
+ Sort
139
+ ----
140
+ Sort rows on specified columns as an example sort rows based on customer (string s) and contract date (date d)
141
+
142
+ $ sycsvpro -f in.csv -o out.csv sort -r 2-20 -c s:0,d:5
143
+
144
+ hello;h2;con123;dri130;mot110;1.02.3012;1
145
+ hello;h1;con123;dri120;mot100;1.01.3013;1
146
+ indix;i1;con456;dri130;mot090;5.11.3013;1
147
+ chiro;c2;con331;dri100;mot130;3.05.3010;1
148
+ chiro;c1;con333;dri110;mot100;1.10.3011;1
149
+
150
+ Insert
151
+ ------
152
+ Add rows at the bottom or on top of a file. The command below adds the content of the file file-with-rows-to-insert.text on top of the file in.csv and saves it to out.csv
153
+
154
+ $ sycsvpro -f in.csv -o out.csv insert file-with-rows-to-insert.txt -p top
141
155
 
142
156
  Edit
143
157
  ----
@@ -147,7 +161,7 @@ Creates or if it exists opens a file for editing. The file is created in the dir
147
161
 
148
162
  List
149
163
  ----
150
- List the scripts available in the scripts directory
164
+ List the scripts or insert-file available in the scripts directory
151
165
 
152
166
  $ sycsvpro list -m
153
167
  script.rb
@@ -155,7 +169,6 @@ List the scripts available in the scripts directory
155
169
 
156
170
  Execute
157
171
  -------
158
-
159
172
  Execute takes a Ruby script file as an argument and processes the script. The following command executes the script *script.rb* and invokes the method *calc*
160
173
 
161
174
  $ sycsvpro execute ./script.rb calc
@@ -212,5 +225,10 @@ A work flow could be as follows
212
225
  * Extract rows and columns of interest `extract`
213
226
  * Count values `count`
214
227
  * Do arithmetic operations on the values `calc`
228
+ * Sort the rows based on column values
215
229
 
216
230
  When I have analyzed the data I use _Microsoft Excel_ or _LibreOffice Calc_ to create nice graphs. To create more sophisiticated analysis *R* is the right tool to use.
231
+
232
+ Installation
233
+ ============
234
+ [![Gem Version](https://badge.fury.io/rb/sycsvpro.png)](http://badge.fury.io/rb/sycsvpro)
data/README.rdoc CHANGED
@@ -6,6 +6,7 @@ License:: Distributed uder the MIT license, see LICENSE in the source distro
6
6
 
7
7
  The application provides an interface for analyzing, cleaning and operating on csv files
8
8
 
9
+ {<img src="https://badge.fury.io/rb/sycsvpro.png" alt="Gem Version" />}[http://badge.fury.io/rb/sycsvpro]
9
10
 
10
11
  == Install
11
12
 
data/bin/sycsvpro CHANGED
@@ -114,14 +114,13 @@ command :allocate do |c|
114
114
  end
115
115
  end
116
116
 
117
- desc 'Creates a script file or opens a script file for editing if it exists'
117
+ desc 'Creates a script/insert file or opens a script/insert file for editing if it exists'
118
118
  command :edit do |c|
119
- c.desc 'Name of the script file'
120
- c.default_value 'script.rb'
121
- c.arg_name 'SCRIPT_NAME.rb'
122
- c.flag [:s, :script], :must_match => /^\w+\.rb/
119
+ c.desc 'Name of the script/insert file'
120
+ c.arg_name 'SCRIPT_NAME.rb|INSERT_NAME.ins'
121
+ c.flag [:s, :script], :must_match => /^\w+\.rb|^\w+\.ins/
123
122
 
124
- c.desc 'Method to create'
123
+ c.desc 'Method to create in combination with a script file'
125
124
  c.arg_name 'METHOD_NAME'
126
125
  c.flag [:m, :method], :must_match => /^\w+/
127
126
 
@@ -132,17 +131,22 @@ command :edit do |c|
132
131
  end
133
132
  end
134
133
 
135
- desc 'Lists scripts in the scripts directory with optionally listing methods'
134
+ desc 'Lists script or insert files in the scripts directory with optionally listing methods of script files'
136
135
  command :list do |c|
136
+ c.desc 'Type of script (Ruby or insert file)'
137
+ c.default_value 'script'
138
+ c.arg_name 'SCRIPT|INSERT'
139
+ c.flag [:t, :type], :must_match => /script|insert/i
140
+
137
141
  c.desc 'Name of the script file'
138
- c.arg_name 'SCRIPT_NAME.rb'
139
- c.flag [:s, :script], :must_match => /^\w+\.rb/
142
+ c.arg_name 'SCRIPT_NAME.rb|INSERT_NAME.ins'
143
+ c.flag [:s, :script], :must_match => /^\w+\.rb|^\w+\.ins/
140
144
 
141
145
  c.desc 'Show methods'
142
146
  c.switch [:m, :method]
143
147
 
144
148
  c.action do |global_options,options,args|
145
- script_list = Sycsvpro::ScriptList.new(dir: script_directory,
149
+ script_list = Sycsvpro::ScriptList.new(dir: script_directory, type: options[:t],
146
150
  script: options[:s], show_methods: options[:m])
147
151
 
148
152
  scripts = script_list.execute
@@ -213,6 +217,59 @@ command :count do |c|
213
217
  counter.execute
214
218
  puts "done"
215
219
  end
220
+
221
+ end
222
+
223
+ desc 'Sort rows based on column values'
224
+ command :sort do |c|
225
+ c.desc 'Rows to consider'
226
+ c.arg_name '1,2,10-30|REGEXP'
227
+ c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/
228
+
229
+ c.desc 'Columns to sort based on a type (n = number, s = string, d = date) and its value'
230
+ c.arg_name 'n:1,s:2-5,d:7'
231
+ c.flag [:c, :col], :must_match => /[d|n|s]:\d+(?:-\d+|,[d|n|s]:\d+)*/
232
+
233
+ c.desc 'Format of date values'
234
+ c.arg_name '%d.%m.%Y|%m/%d/%Y|...'
235
+ c.default_value '%Y-%m-%d'
236
+ c.flag [:df]
237
+
238
+ c.desc 'Sort order descending - default ascending'
239
+ c.switch [:d, :desc]
240
+
241
+ c.action do |global_options,options,args|
242
+ sorter = Sycsvpro::Sorter.new(infile: global_options[:f], outfile: global_options[:o],
243
+ rows: options[:r], cols: options[:c], df: options[:df],
244
+ desc: options[:d])
245
+ print 'Sorting...'
246
+ sorter.execute
247
+ print 'done'
248
+ end
249
+ end
250
+
251
+ desc 'Inserts rows from a file to a csv-file'
252
+ arg_name 'INSERT_FILE'
253
+ command :insert do |c|
254
+
255
+ c.desc 'Position TOP or BOTTOM where to insert the rows'
256
+ c.default_value 'top'
257
+ c.arg_name 'top|bottom'
258
+ c.flag [:p, :position], :must_match => /^top|^bottom/i
259
+
260
+ c.action do |global_options,options,args|
261
+ help_now! "You need to provide an insert file" if args.size == 0
262
+
263
+ insert_file = File.expand_path(args[0])
264
+ insert_file = File.join(script_directory, args[0]) unless File.exists? insert_file
265
+ help_now! "Insert file #{insert_file} doesn't exist!" unless File.exists? insert_file
266
+
267
+ print "Inserting..."
268
+ inserter = Sycsvpro::Inserter.new(infile: global_options[:f], outfile: global_options[:o],
269
+ insert: insert_file, position: options[:p])
270
+ inserter.execute
271
+ puts "done"
272
+ end
216
273
  end
217
274
 
218
275
  desc 'Map values in columns to new values'
@@ -275,7 +332,7 @@ pre do |global,command,options,args|
275
332
  case command.name
276
333
  when :analyze
277
334
  help_now! "You need to provide an input file '-f FILE'" if global[:f].nil?
278
- when :allocate, :calc, :collect, :count, :extract, :map
335
+ when :allocate, :calc, :collect, :count, :extract, :map, :sort
279
336
  help_now! "You need to provide an input file '-f FILE'" if global[:f].nil?
280
337
  help_now! "You need to provide a result file '-o OUT_FILE'" if global[:o].nil?
281
338
  end
@@ -290,10 +347,12 @@ pre do |global,command,options,args|
290
347
 
291
348
  # Creates statistics on the command operation
292
349
  Stats = Struct.new(:command, :start, :end, :count) do
350
+ # Calcualates the total duration
293
351
  def duration
294
352
  self.end - self.start
295
353
  end
296
354
 
355
+ # Calculates the average time per row processing
297
356
  def average
298
357
  if count > 0
299
358
  (self.end - self.start) * 1000 / self.count
@@ -302,6 +361,7 @@ pre do |global,command,options,args|
302
361
  end
303
362
  end
304
363
 
364
+ # Prints the statistics
305
365
  def to_s
306
366
  if count > 0
307
367
  sprintf("%s %.5f %s %d %s %.5f %s", "'#{self.command}' has run",
@@ -99,6 +99,9 @@ href="mailto:pierre@sugaryourcoffee.de">pierre@sugaryourcoffee.de</a>)</p>
99
99
  <p>The application provides an interface for analyzing, cleaning and operating
100
100
  on csv files</p>
101
101
 
102
+ <p><a href="http://badge.fury.io/rb/sycsvpro"><img
103
+ src="https://badge.fury.io/rb/sycsvpro.png" alt="Gem Version" /></a></p>
104
+
102
105
  <h2 id="label-Install">Install<span><a href="#label-Install">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
103
106
 
104
107
  <p>Install:</p>
@@ -144,7 +147,7 @@ bin</pre>
144
147
 
145
148
  <p>VERSION</p>
146
149
 
147
- <pre>0.0.5</pre>
150
+ <pre>0.0.8</pre>
148
151
 
149
152
  <p>GLOBAL OPTIONS</p>
150
153
 
@@ -166,7 +169,10 @@ count - Counts the occurences of column values. Uses column values as heading
166
169
  execute - Executes the code provided in a file
167
170
  extract - Extract specified rows and columns from the file
168
171
  help - Shows a list of commands or help for one command
169
- map - Map values in columns to new values</pre>
172
+ insert - Inserts rows from a file to a csv-file
173
+ list - List scripts in the scripts directory with optionally listing methods
174
+ map - Map values in columns to new values
175
+ sort - Sort columns based on column values</pre>
170
176
  </main>
171
177
 
172
178
 
@@ -0,0 +1,187 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Sycsvpro::ColumnTypeFilter - 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="ColumnFilter.html">Sycsvpro::ColumnFilter</a>
65
+
66
+ </div>
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+
76
+ <li class="calls-super" ><a href="#method-i-process">#process</a>
77
+
78
+ </ul>
79
+ </div>
80
+
81
+ </div>
82
+ </nav>
83
+
84
+ <main role="main" aria-labelledby="class-Sycsvpro::ColumnTypeFilter">
85
+ <h1 id="class-Sycsvpro::ColumnTypeFilter" class="class">
86
+ class Sycsvpro::ColumnTypeFilter
87
+ </h1>
88
+
89
+ <section class="description">
90
+
91
+ <p>Create a filter based on a colum and its type</p>
92
+
93
+ </section>
94
+
95
+
96
+
97
+
98
+ <section id="5Buntitled-5D" class="documentation-section">
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
109
+ <header>
110
+ <h3>Public Instance Methods</h3>
111
+ </header>
112
+
113
+
114
+ <div id="method-i-process" class="method-detail ">
115
+
116
+ <div class="method-heading">
117
+ <span class="method-name">process</span><span
118
+ class="method-args">(object, options={})</span>
119
+
120
+ <span class="method-click-advice">click to toggle source</span>
121
+
122
+ </div>
123
+
124
+
125
+ <div class="method-description">
126
+
127
+ <p>Processes the filter and returns the filtered columns</p>
128
+
129
+
130
+ <div class="method-calls-super">
131
+ Calls superclass method
132
+ <a href="ColumnFilter.html#method-i-process">Sycsvpro::ColumnFilter#process</a>
133
+ </div>
134
+
135
+
136
+
137
+ <div class="method-source-code" id="process-source">
138
+ <pre><span class="ruby-comment"># File lib/sycsvpro/column_type_filter.rb, line 8</span>
139
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">options</span>={})
140
+ <span class="ruby-identifier">filtered</span> = <span class="ruby-keyword">super</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">options</span>)
141
+
142
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">nil?</span>
143
+
144
+ <span class="ruby-identifier">values</span> = <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;;&#39;</span>)
145
+
146
+ <span class="ruby-identifier">values</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
147
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">types</span>[<span class="ruby-identifier">index</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;n&#39;</span>
148
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\./</span>
149
+ <span class="ruby-identifier">number_value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_f</span>
150
+ <span class="ruby-keyword">else</span>
151
+ <span class="ruby-identifier">number_value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_i</span>
152
+ <span class="ruby-keyword">end</span>
153
+ <span class="ruby-identifier">values</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">number_value</span>
154
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">types</span>[<span class="ruby-identifier">index</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;d&#39;</span>
155
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">empty?</span>
156
+ <span class="ruby-identifier">date</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-string">&#39;9999-9-9&#39;</span>, <span class="ruby-string">&#39;%Y-%m-%d&#39;</span>)
157
+ <span class="ruby-keyword">else</span>
158
+ <span class="ruby-identifier">date</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">strptime</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">date_format</span>)
159
+ <span class="ruby-keyword">end</span>
160
+ <span class="ruby-identifier">values</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">date</span>
161
+ <span class="ruby-keyword">end</span>
162
+ <span class="ruby-keyword">end</span>
163
+
164
+ <span class="ruby-identifier">values</span>
165
+ <span class="ruby-keyword">end</span></pre>
166
+ </div>
167
+
168
+ </div>
169
+
170
+
171
+
172
+
173
+ </div>
174
+
175
+
176
+ </section>
177
+
178
+ </section>
179
+ </main>
180
+
181
+
182
+ <footer id="validator-badges" role="contentinfo">
183
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
184
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
185
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
186
+ </footer>
187
+
@@ -170,6 +170,19 @@ to override the process method</p>
170
170
  </div>
171
171
  </div>
172
172
 
173
+ <div id="attribute-i-types" class="method-detail">
174
+ <div class="method-heading attribute-method-heading">
175
+ <span class="method-name">types</span><span
176
+ class="attribute-access-type">[R]</span>
177
+ </div>
178
+
179
+ <div class="method-description">
180
+
181
+ <p>Type of column (n = number, s = string)</p>
182
+
183
+ </div>
184
+ </div>
185
+
173
186
  </section>
174
187
 
175
188
 
@@ -199,10 +212,11 @@ to override the process method</p>
199
212
 
200
213
 
201
214
  <div class="method-source-code" id="new-source">
202
- <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 20</span>
215
+ <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 22</span>
203
216
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">values</span>, <span class="ruby-identifier">options</span>={})
204
217
  <span class="ruby-ivar">@date_format</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:df</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&quot;%Y-%m-%d&quot;</span>
205
218
  <span class="ruby-ivar">@filter</span> = []
219
+ <span class="ruby-ivar">@types</span> = []
206
220
  <span class="ruby-ivar">@pattern</span> = []
207
221
  <span class="ruby-ivar">@pivot</span> = {}
208
222
  <span class="ruby-identifier">create_filter</span>(<span class="ruby-identifier">values</span>)
@@ -245,7 +259,7 @@ otherwise false</p>
245
259
 
246
260
 
247
261
  <div class="method-source-code" id="has_filter-3F-source">
248
- <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 59</span>
262
+ <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 64</span>
249
263
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">has_filter?</span>
250
264
  <span class="ruby-keyword">return</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">filter</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">empty?</span>)
251
265
  <span class="ruby-keyword">end</span></pre>
@@ -283,10 +297,12 @@ otherwise false</p>
283
297
 
284
298
 
285
299
  <div class="method-source-code" id="method_missing-source">
286
- <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 29</span>
300
+ <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 32</span>
287
301
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">id</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
288
302
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">equal</span>(<span class="ruby-node">$1</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(\d+)$/</span>
303
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">equal_type</span>(<span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(s|n|d):(\d+)$/</span>
289
304
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">range</span>(<span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(\d+)-(\d+)$/</span>
305
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">range_type</span>(<span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>, <span class="ruby-node">$3</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(s|n|d):(\d+)-(\d+)$/</span>
290
306
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">regex</span>(<span class="ruby-node">$1</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^\/(.*)\/$/</span>
291
307
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">col_regex</span>(<span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(\d+):\/(.*)\/$/</span>
292
308
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">date</span>(<span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>, <span class="ruby-node">$3</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^(\d+):(&lt;|=|&gt;)(\d+.\d+.\d+)/</span>
@@ -322,7 +338,7 @@ otherwise false</p>
322
338
 
323
339
 
324
340
  <div class="method-source-code" id="pivot_each_column-source">
325
- <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 45</span>
341
+ <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 50</span>
326
342
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">pivot_each_column</span>(<span class="ruby-identifier">values</span>=[])
327
343
  <span class="ruby-identifier">pivot</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-identifier">parameters</span><span class="ruby-operator">|</span>
328
344
  <span class="ruby-identifier">value</span> = <span class="ruby-identifier">values</span>[<span class="ruby-identifier">parameters</span>[<span class="ruby-value">:col</span>].<span class="ruby-identifier">to_i</span>]
@@ -364,7 +380,7 @@ otherwise false</p>
364
380
 
365
381
 
366
382
  <div class="method-source-code" id="process-source">
367
- <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 40</span>
383
+ <pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 45</span>
368
384
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">options</span>={})
369
385
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&#39;Needs to be overridden by sub class&#39;</span>
370
386
  <span class="ruby-keyword">end</span></pre>