fat_table 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f348d317c061becae08890ff02cc9c08789787d966f9ed88f3a4ef22b6eddb44
4
- data.tar.gz: bf672b4f4f4ab07df465d06904ccebb9b48507177dc88a343eb09bfb0e98bc02
3
+ metadata.gz: f045f2196dd5d6ad7584b877d847945f99cc8079b86b8a810af8528d2c18074c
4
+ data.tar.gz: cb8f031c4f48d472af658f111221524882f5d2bb6574858b1e988e2384d7ba56
5
5
  SHA512:
6
- metadata.gz: c721233a04cc1664e8d8acea3cf677190aa47da30b3db7e1b9f6c13ddd56028a8ecd8b0c71915d0a1703f46fc9a22a1c3a8a3f13d6c80fb07964a22fd864ab7e
7
- data.tar.gz: 7877d4529d8a6f2a13ee0a1518730791b4e5ed7dbadd2030367593c95ccdbd5159e711f7ffe69b9b2fa9b4812a6f49d3d1a9fce46642e4454f54ff40d769a4cb
6
+ metadata.gz: f906e8841e268263635dc4231573b07cb48cd48b1f33fd2a0d7812e65f1e9720ac8f8556129601b702a828c5c6a7a7a04c00344016c2ebe0004a892d1f524ab9
7
+ data.tar.gz: 694f65455ed63c1304f0bc626192c2770968278ec0599c0e9c5f57c5fcb091a351ed4e09d28fe6cbda12278f1f9ed669e128339e6e99b4fc2a1a21467d182892
data/README.org CHANGED
@@ -31,7 +31,6 @@ The following is for org.
31
31
  "Current version is: #{FatTable::VERSION}"
32
32
  #+end_src
33
33
 
34
- #+RESULTS:
35
34
  #+begin_EXAMPLE
36
35
  Current version is: 0.6.0
37
36
  #+end_EXAMPLE
@@ -173,7 +173,12 @@ module FatTable
173
173
  # Column. This makes Columns Enumerable, so all the Enumerable methods are
174
174
  # available on a Column.
175
175
  def each
176
- items.each { |itm| yield itm }
176
+ if block_given?
177
+ items.each { |itm| yield itm }
178
+ self
179
+ else
180
+ to_enum(:each)
181
+ end
177
182
  end
178
183
 
179
184
  ##########################################################################
@@ -67,7 +67,7 @@ module FatTable
67
67
 
68
68
  # Return the value of the label, for the kth group if grouped.
69
69
  def label(k = 0)
70
- calc_label(k)
70
+ @values[@label_col][k]
71
71
  end
72
72
 
73
73
  # :category: Accessors
@@ -221,24 +221,32 @@ module FatTable
221
221
  @values[@label_col] << calc_label(k)
222
222
  end
223
223
  else
224
- @values[@label_col] = [calc_label(0)]
224
+ @values[@label_col] = [calc_label]
225
225
  end
226
226
  end
227
227
 
228
- # Calculate the label for the kth group, using k = 0 for non-group
228
+ # Calculate the label for the kth group, using k = nil for non-group
229
229
  # footers. If the label is a proc, call it with the group number.
230
- def calc_label(k)
230
+ def calc_label(k = nil)
231
231
  case @label
232
232
  when Proc
233
233
  case @label.arity
234
234
  when 0
235
235
  @label.call
236
236
  when 1
237
- @label.call(k)
237
+ k ? @label.call(k) : @label.call(self)
238
238
  when 2
239
- @label.call(k, self)
239
+ if k
240
+ @label.call(k, self)
241
+ else
242
+ raise ArgumentError, "a non-group footer label proc may only have 1 argument for the containing footer f"
243
+ end
240
244
  else
241
- raise ArgumentError, "footer label proc may only have 1 argument for group number k"
245
+ if k
246
+ raise ArgumentError, "group footer label proc may only have 0, 1, or 2 arguments for group number k and containing footer f"
247
+ else
248
+ raise ArgumentError, "a non-group footer label proc may only have 0 or 1 arguments for the containing footer f"
249
+ end
242
250
  end
243
251
  else
244
252
  @label.to_s
@@ -530,8 +530,13 @@ module FatTable
530
530
 
531
531
  # Yield each row of the table as a Hash with the column symbols as keys.
532
532
  def each
533
- rows.each do |row|
534
- yield row
533
+ if block_given?
534
+ rows.each do |row|
535
+ yield row
536
+ end
537
+ self
538
+ else
539
+ to_enum(:each)
535
540
  end
536
541
  end
537
542
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module FatTable
4
4
  # The current version of FatTable
5
- VERSION = '0.6.0'
5
+ VERSION = '0.6.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-26 00:00:00.000000000 Z
11
+ date: 2022-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -332,7 +332,7 @@ licenses: []
332
332
  metadata:
333
333
  allowed_push_host: https://rubygems.org
334
334
  yard.run: yri
335
- post_install_message:
335
+ post_install_message:
336
336
  rdoc_options: []
337
337
  require_paths:
338
338
  - lib
@@ -348,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
348
  version: '0'
349
349
  requirements: []
350
350
  rubygems_version: 3.3.3
351
- signing_key:
351
+ signing_key:
352
352
  specification_version: 4
353
353
  summary: Provides tools for working with tables as a data type.
354
354
  test_files: []