fat_table 0.2.3 → 0.2.4

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: 979f798ea068a4c78cefc05ad23e9bac937e1931
4
- data.tar.gz: 0b9a6103449a3adc03e997702b2b7ba7eeb293f9
3
+ metadata.gz: 772c4f7d95d5af94968f650b4bc98ebad4756626
4
+ data.tar.gz: c15462e9a444de246690482da1a8acd3a46e0c60
5
5
  SHA512:
6
- metadata.gz: 5bcc0327bf6438751e893c4ee8d3d286d13842fc92a72970c886f0857a215973bfec8baac98700f8f09f6da31fb4e0997916da8800e48411658055c94c43d8cb
7
- data.tar.gz: fd50900aca39b031a7974069baf8abbbdf0a0a76853faa0c95033ae8fa3157b288e2fdc5d6dfe1b47241a18d84204878e0b19669d2f6be62fb153927c0846ad9
6
+ metadata.gz: 4f1177b1568ece2027849b102f2e7db84db99846e7291882f943fba5fd400b75032847df303c528fada0683afb2fb5b0bc97a2a91f2e52ed74cbd6960da07ac2
7
+ data.tar.gz: 813ddb4b57d893ce9bfb0ca17bb6d03d8807fa361b166396d0635fc5d23e70f4c1641fb69b0f3973678faa2e1bb87667de6bca4b8ff3c0033ceba38db0168658
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --no-private lib/**/*.rb --markup=markdown --main=README.rdoc - README.rdoc
data/README.org CHANGED
@@ -148,8 +148,9 @@ the main features of ~FatTable~. See the detailed explanations further on down.
148
148
 
149
149
  When you install the fat_table gem, you have access to a program ~ft_console~
150
150
  which opens a ~pry~ session with ~fat_table~ loaded and the tables used in the
151
- examples in this README defined as local variables so you can experiment with
152
- them.
151
+ examples in this README defined as instance variables so you can experiment with
152
+ them. Because they are defined as instance variables, you have to write ~tab1~
153
+ as ~@tab1~ in ~ft_console~, but otherwise the examples should work.
153
154
 
154
155
  The examples in this ~README~ file are executed as code blocks within the
155
156
  ~README.org~ file, so they typically end with a call to ~.to_aoa~. That causes
@@ -162,21 +163,14 @@ To read in the table used in the Quick Start section above, you might do the
162
163
  following:
163
164
 
164
165
  #+BEGIN_EXAMPLE
165
- $ ft_console
166
- From: /home/ded/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/fat_table-0.2.1/bin/ft_console @ line 115 :
167
-
168
- 110: [15, '2013-05-29', 'S', 15_900.00, 6685.95, 24.5802, 'YLEAC', 'T'],
169
- 111: [16, '2013-05-30', 'S', 6_679.00, 2808.52, 25.0471, 'YLEAC', 'T']]
170
- 112: tt = FatTable.from_aoa(AOA)
171
- 113:
172
- 114: binding.pry
173
- => 115: instr <<-EOS
174
- 116: FatTable console sets up some sample tables you can play with (see ls)
175
- 117:
176
- 118: For example, try 'puts tab1.to_term'
177
- 119: EOS
178
-
179
- [1] pry(main)> table = FatTable.from_aoa(data)
166
+ $ ft_console[1] pry(main)> ls
167
+ ActiveSupport::ToJsonWithActiveSupportEncoder#methods: to_json
168
+ self.methods: inspect to_s
169
+ instance variables:
170
+ @aoa @tab1 @tab2 @tab_a @tab_b @tt
171
+ @data @tab1_str @tab2_str @tab_a_str @tab_b_str
172
+ locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_ lib str version
173
+ [2] pry(main)> table = FatTable.from_aoa(@data)
180
174
  => #<FatTable::Table:0x0055b40e6cd870
181
175
  @boundaries=[],
182
176
  @columns=
@@ -197,7 +191,7 @@ From: /home/ded/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/fat_table-0.2.1/b
197
191
  @raw_header=:info,
198
192
  @type="String">,
199
193
  #<FatTable::Column:0x0055b40e6d2668 @header=:ok, @items=[false, true, false, true, true, true, true, true, true, true, true, false], @raw_header=:ok, @type="Boolean">]>
200
- [2] pry(main)> puts table.to_text
194
+ [3] pry(main)> puts table.to_text
201
195
  +============+======+==========+==========+=========+=========+====+
202
196
  | Date | Code | Raw | Shares | Price | Info | Ok |
203
197
  +------------+------+----------+----------+---------+---------+----+
@@ -215,7 +209,7 @@ From: /home/ded/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/fat_table-0.2.1/b
215
209
  | 2013-05-23 | S | 23054.0 | 9694.21 | 26.8015 | ENTITY3 | F |
216
210
  +============+======+==========+==========+=========+=========+====+
217
211
  => nil
218
- [3] pry(main)>
212
+ [4] pry(main)>
219
213
  #+END_EXAMPLE
220
214
 
221
215
  And if you use ~.to_term~, you can see the effect of the color formatting
@@ -971,6 +965,8 @@ will raise an exception.
971
965
  - ~pdev~ :: for Numeric and DateTime columns, compute the population standard
972
966
  deviation of the non-nil values in the column, dates are converted to
973
967
  numbers as for the :avg aggregate,
968
+ - ~all?~ :: for Boolean columns only, return true if all of the non-nil values
969
+ in the column are true,
974
970
  - ~any?~ :: for Boolean columns only, return true if any non-nil value in the
975
971
  column is true,
976
972
  - ~none?~ :: for Boolean columns only, return true if no non-nil value in the
data/README.rdoc CHANGED
@@ -135,8 +135,11 @@ the main features of +FatTable+. See the detailed explanations further on down.
135
135
 
136
136
  When you install the fat_table gem, you have access to a program +ft_console+
137
137
  which opens a +pry+ session with +fat_table+ loaded and the tables used in the
138
- examples in this README defined as local variables so you can experiment with
139
- them.
138
+ examples in this README defined as instance variables so you can experiment with
139
+ them. Because they are defined as instance variables, you have to write ~tab1~
140
+ as ~@tab1~ in ~ft_console~, but otherwise the examples should work.
141
+
142
+
140
143
 
141
144
  The examples in this +README+ file are executed as code blocks within the
142
145
  +README.org+ file, so they typically end with a call to +.to_aoa+. That causes
@@ -148,21 +151,14 @@ the table to be inserted into the file and formatted as a table. With
148
151
  To read in the table used in the Quick Start section above, you might do the
149
152
  following:
150
153
 
151
- $ ft_console
152
- From: /home/ded/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/fat_table-0.2.1/bin/ft_console @ line 115 :
153
-
154
- 110: [15, '2013-05-29', 'S', 15_900.00, 6685.95, 24.5802, 'YLEAC', 'T'],
155
- 111: [16, '2013-05-30', 'S', 6_679.00, 2808.52, 25.0471, 'YLEAC', 'T']]
156
- 112: tt = FatTable.from_aoa(AOA)
157
- 113:
158
- 114: binding.pry
159
- => 115: instr <<-EOS
160
- 116: FatTable console sets up some sample tables you can play with (see ls)
161
- 117:
162
- 118: For example, try 'puts tab1.to_term'
163
- 119: EOS
164
-
165
- [1] pry(main)> table = FatTable.from_aoa(data)
154
+ $ ft_console[1] pry(main)> ls
155
+ ActiveSupport::ToJsonWithActiveSupportEncoder#methods: to_json
156
+ self.methods: inspect to_s
157
+ instance variables:
158
+ @aoa @tab1 @tab2 @tab_a @tab_b @tt
159
+ @data @tab1_str @tab2_str @tab_a_str @tab_b_str
160
+ locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_ lib str version
161
+ [2] pry(main)> table = FatTable.from_aoa(@data)
166
162
  => #<FatTable::Table:0x0055b40e6cd870
167
163
  @boundaries=[],
168
164
  @columns=
@@ -183,7 +179,7 @@ following:
183
179
  @raw_header=:info,
184
180
  @type="String">,
185
181
  #<FatTable::Column:0x0055b40e6d2668 @header=:ok, @items=[false, true, false, true, true, true, true, true, true, true, true, false], @raw_header=:ok, @type="Boolean">]>
186
- [2] pry(main)> puts table.to_text
182
+ [3] pry(main)> puts table.to_text
187
183
  +============+======+==========+==========+=========+=========+====+
188
184
  | Date | Code | Raw | Shares | Price | Info | Ok |
189
185
  +------------+------+----------+----------+---------+---------+----+
@@ -201,7 +197,7 @@ following:
201
197
  | 2013-05-23 | S | 23054.0 | 9694.21 | 26.8015 | ENTITY3 | F |
202
198
  +============+======+==========+==========+=========+=========+====+
203
199
  => nil
204
- [3] pry(main)>
200
+ [4] pry(main)>
205
201
 
206
202
  And if you use +.to_term+, you can see the effect of the color formatting
207
203
  directives.
data/bin/ft_console CHANGED
@@ -4,7 +4,7 @@ require 'bundler/setup'
4
4
  require 'fat_table'
5
5
  require 'pry'
6
6
 
7
- data =
7
+ @data =
8
8
  [['Date', 'Code', 'Raw', 'Shares', 'Price', 'Info', 'Ok'],
9
9
  ['2013-05-29', 'S', 15_700.00, 6601.85, 24.7790, 'ENTITY3', 'F'],
10
10
  ['2013-05-02', 'P', 118_186.40, 118_186.4, 11.8500, 'ENTITY1', 'T'],
@@ -19,7 +19,7 @@ data =
19
19
  ['2013-05-30', 'S', 6_679.00, 2808.52, 25.0471, 'ENTITY3', 'T'],
20
20
  ['2013-05-23', 'S', 23_054.00, 9694.21, 26.8015, 'ENTITY3', 'F']]
21
21
 
22
- tab_a_str = <<-EOS
22
+ @tab_a_str = <<-EOS
23
23
  | Id | Name | Age | Address | Salary | Join Date |
24
24
  |----+-------+-----+------------+--------+------------|
25
25
  | 1 | Paul | 32 | California | 20000 | 2001-07-13 |
@@ -32,7 +32,7 @@ tab_a_str = <<-EOS
32
32
  | 10 | James | 45 | Texas | 5000 | |
33
33
  EOS
34
34
 
35
- tab_b_str = <<-EOS
35
+ @tab_b_str = <<-EOS
36
36
  | Id | Dept | Emp Id |
37
37
  |----+-------------+--------|
38
38
  | 1 | IT Billing | 1 |
@@ -40,10 +40,10 @@ tab_b_str = <<-EOS
40
40
  | 3 | Finance | 7 |
41
41
  EOS
42
42
 
43
- tab_a = FatTable.from_org_string(tab_a_str)
44
- tab_b = FatTable.from_org_string(tab_b_str)
43
+ @tab_a = FatTable.from_org_string(@tab_a_str)
44
+ @tab_b = FatTable.from_org_string(@tab_b_str)
45
45
 
46
- tab1_str = <<-EOS
46
+ @tab1_str = <<-EOS
47
47
  | Ref | Date | Code | Price | G10 | QP10 | Shares | LP | QP | IPLP | IPQP |
48
48
  |------+------------------+------+--------+-----+------+--------+------+-------+--------+--------|
49
49
  | T001 | [2016-11-01 Tue] | P | 7.7000 | T | F | 100 | 14 | 86 | 0.2453 | 0.1924 |
@@ -70,7 +70,7 @@ tab1_str = <<-EOS
70
70
  | T016 | [2016-11-02 Wed] | P | 8.2500 | T | T | 100 | 14 | 86 | 0.2453 | 0.1924 |
71
71
  EOS
72
72
 
73
- tab2_str = <<-EOS
73
+ @tab2_str = <<-EOS
74
74
  | Ref | Date | Code | Price | G10 | QP10 | Shares | LP | QP | IPLP | IPQP |
75
75
  |------+------------------+------+--------+-----+------+--------+-------+------+--------+--------|
76
76
  | T003 | [2016-11-01 Tue] | P | 7.5000 | F | T | 800 | 112 | 688 | 0.2453 | 0.1924 |
@@ -93,10 +93,10 @@ tab2_str = <<-EOS
93
93
  | T021 | [2017-01-23 Mon] | P | 7.16 | T | T | 12100 | 11050 | 1050 | 0.2453 | 0.1924 |
94
94
  EOS
95
95
 
96
- tab1 = FatTable.from_org_string(tab1_str)
97
- tab2 = FatTable.from_org_string(tab2_str)
96
+ @tab1 = FatTable.from_org_string(@tab1_str)
97
+ @tab2 = FatTable.from_org_string(@tab2_str)
98
98
 
99
- AOA = [['Ref', 'Date', 'Code', 'Raw', 'Shares', 'Price', 'Info', 'Bool'],
99
+ @aoa = [['Ref', 'Date', 'Code', 'Raw', 'Shares', 'Price', 'Info', 'Bool'],
100
100
  [1, '2013-05-02', 'P', 795_546.20, 795_546.2, 1.1850, 'YLPEF1', 'T'],
101
101
  [2, '2013-05-02', 'P', 118_186.40, 118_186.4, 11.8500, 'YLPEF1', 'T'],
102
102
  [7, '2013-05-20', 'S', 12_000.00, 5046.00, 28.2804, 'YLEAC', 'F'],
@@ -109,11 +109,6 @@ AOA = [['Ref', 'Date', 'Code', 'Raw', 'Shares', 'Price', 'Info', 'Bool'],
109
109
  [14, '2013-05-29', 'S', 15_700.00, 6601.85, 24.7790, 'YLEAC', 'F'],
110
110
  [15, '2013-05-29', 'S', 15_900.00, 6685.95, 24.5802, 'YLEAC', 'T'],
111
111
  [16, '2013-05-30', 'S', 6_679.00, 2808.52, 25.0471, 'YLEAC', 'T']]
112
- tt = FatTable.from_aoa(AOA)
112
+ @tt = FatTable.from_aoa(@aoa)
113
113
 
114
- binding.pry
115
- instr <<-EOS
116
- FatTable console sets up some sample tables you can play with (see ls)
117
-
118
- For example, try 'puts tab1.to_term'
119
- EOS
114
+ Pry.start
data/fat_table.gemspec CHANGED
@@ -59,6 +59,7 @@ org-mode buffer as an org-table, ready for processing by other code blocks.
59
59
  spec.bindir = 'bin'
60
60
  spec.executables = ['ft_console']
61
61
  spec.require_paths = ['lib']
62
+ spec.metadata['yard.run'] = 'yri' # use "yard" to build full HTML docs.
62
63
 
63
64
  spec.add_development_dependency 'simplecov'
64
65
  spec.add_development_dependency 'bundler', '~> 1.14'
@@ -68,9 +69,9 @@ org-mode buffer as an org-table, ready for processing by other code blocks.
68
69
  spec.add_development_dependency 'pry'
69
70
  spec.add_development_dependency 'pry-doc'
70
71
  spec.add_development_dependency 'pry-byebug'
71
- spec.add_development_dependency 'rcodetools'
72
+ spec.add_development_dependency 'redcarpet'
72
73
 
73
- spec.add_runtime_dependency 'fat_core', '~> 2.0', '>= 2.0.1'
74
+ spec.add_runtime_dependency 'fat_core', '~> 4.0', '>= 4.1'
74
75
  spec.add_runtime_dependency 'activesupport'
75
76
  spec.add_runtime_dependency 'rainbow'
76
77
  spec.add_runtime_dependency 'dbi'
data/lib/fat_table.rb CHANGED
@@ -1,5 +1,3 @@
1
- require "fat_table/version"
2
-
3
1
  # This module provides objects for treating tables as a data type on which you
4
2
  # can (1) perform operations, such as select, where, join, and others and (2)
5
3
  # output the tables in several formats, including text, ANSI terminal, LaTeX,
@@ -7,12 +5,17 @@ require "fat_table/version"
7
5
  # variety of input sources. See, e.g., .from_csv_file,
8
6
  # FatTable.from_org_file, and FatTable.from_sql, for more details.
9
7
  module FatTable
10
- require 'fat_core'
8
+ require 'fat_core/symbol'
9
+ require 'fat_core/array'
10
+ require 'fat_core/hash'
11
+ require 'fat_core/numeric'
12
+ require 'csv'
11
13
  require 'dbi'
12
14
  require 'active_support'
13
15
  require 'active_support/core_ext'
14
16
  require 'active_support/number_helper'
15
17
 
18
+ require 'fat_table/version'
16
19
  require 'fat_table/evaluator'
17
20
  require 'fat_table/column'
18
21
  require 'fat_table/table'
@@ -1,8 +1,8 @@
1
1
  module FatTable
2
2
  # A subclass of Formatter for rendering the table as a Ruby Array of Arrays.
3
- # Each cell is an element of the inner Array is formatted as a string in
4
- # accordance with the formatting directives. All footers are included as extra
5
- # Arrays of the output. AoaFormatter supports no +options+
3
+ # Each cell is formatted as a string in accordance with the formatting
4
+ # directives. All footers are included as extra Arrays of the output.
5
+ # AoaFormatter supports no +options+
6
6
  class AoaFormatter < Formatter
7
7
 
8
8
  private
@@ -2,14 +2,14 @@ module FatTable
2
2
  # A Formatter is for use in Table output routines, and provides methods for
3
3
  # adding group and table footers to the output and instructions for how the
4
4
  # table's cells ought to be formatted. The goal is to make subclasses of this
5
- # class handle different output targets, such as aoa for org tables, ANSI
6
- # terminals, LaTeX, plain text, org mode table text, and so forth. Many of
7
- # the formatting options, such as color, will be no-ops for some output
8
- # targets, such as text, but will be valid nonetheless. Thus, the Formatter
9
- # subclass should provide the best implementation for each formatting request
10
- # available for the target. This base class will consist largely of methods
11
- # that format output as pipe-separated values, but implementations provided
12
- # by subclasses will override these for different output targets.
5
+ # class handle different output targets, such as aoa for an Array of Arrays
6
+ # (useful in Emacs org-mode code blocks), ANSI terminals, LaTeX, plain text,
7
+ # org mode table text, and so forth. Many of the formatting options, such as
8
+ # color, will be no-ops for some output targets, such as text, but will be
9
+ # valid nonetheless. Thus, a Formatter subclass should provide the best
10
+ # implementation for each formatting request available for the target. This
11
+ # base class will format output as pipe-separated values, but implementations
12
+ # provided by subclasses will override these for different output targets.
13
13
  class Formatter
14
14
  # Valid locations in a Table as an array of symbols.
15
15
  LOCATIONS = [:header, :body, :bfirst, :gfirst, :gfooter, :footer].freeze
@@ -156,12 +156,12 @@ module FatTable
156
156
  # tab.footer('Grand Total', :shares, :price)
157
157
  #
158
158
  # Average then show standard deviation of several columns
159
- # tab.footer.('Average', date: avg, shares: :avg, price: avg)
160
- # tab.footer.('Sigma', date: dev, shares: :dev, price: :dev)
159
+ # tab.footer.('Average', date: :avg, shares: :avg, price: :avg)
160
+ # tab.footer.('Sigma', date: :dev, shares: :dev, price: :dev)
161
161
  #
162
162
  # Do some sums and some other aggregates: sum shares, average date and
163
163
  # price.
164
- # tab.footer.('Summary', :shares, date: avg, price: avg)
164
+ # tab.footer.('Summary', :shares, date: :avg, price: :avg)
165
165
  def footer(label, *sum_cols, **agg_cols)
166
166
  label = label.to_s
167
167
  foot = {}
@@ -195,11 +195,11 @@ module FatTable
195
195
  # :shares, :price)
196
196
  #
197
197
  # Average then show standard deviation of several columns
198
- # tab.gfooter.('Average', date: avg, shares: :avg, price: avg)
198
+ # tab.gfooter.('Average', date: :avg, shares: :avg, price: :avg)
199
199
  # tab.gfooter.('Sigma', date: dev, shares: :dev, price: :dev)
200
200
  #
201
201
  # Do some sums and some other aggregates: sum shares, average date and
202
- # price. tab.gfooter.('Summary', :shares, date: avg, price: avg)
202
+ # price. tab.gfooter.('Summary', :shares, date: :avg, price: :avg)
203
203
  def gfooter(label, *sum_cols, **agg_cols)
204
204
  label = label.to_s
205
205
  foot = {}
@@ -303,12 +303,11 @@ module FatTable
303
303
  gfooter('Group Maximum', hsh)
304
304
  end
305
305
 
306
+ # :category: Formatting
307
+
306
308
  ############################################################################
307
309
  # Formatting methods
308
310
  #
309
- #
310
- # :category: Formatting
311
- #
312
311
  # A Formatter can specify a hash to hold the formatting instructions for
313
312
  # columns by using the column head as a key and the value as the format
314
313
  # instructions. In addition, the keys, :numeric, :string, :datetime,
@@ -419,7 +418,7 @@ module FatTable
419
418
  end
420
419
 
421
420
  # :category: Formatting
422
- #
421
+
423
422
  # Define a formatting directives for the given location. The following are
424
423
  # the valid +location+ symbols.
425
424
  #
@@ -865,7 +864,7 @@ module FatTable
865
864
  end
866
865
  if istruct.commas
867
866
  # Commify the whole number part if not done already.
868
- result = result.commify
867
+ result = result.commas
869
868
  end
870
869
  result
871
870
  end
@@ -880,7 +879,8 @@ module FatTable
880
879
  when :upper
881
880
  val.upcase
882
881
  when :title
883
- val.entitle
882
+ # Note: fat_core entitle keeps all uppercase words as upper case,
883
+ val.downcase.entitle
884
884
  when :none
885
885
  val
886
886
  end
@@ -58,6 +58,7 @@ module FatTable
58
58
  ###########################################################################
59
59
 
60
60
  # :category: Constructors
61
+
61
62
  # Return an empty FatTable::Table object.
62
63
  def initialize
63
64
  @columns = []
@@ -65,8 +66,9 @@ module FatTable
65
66
  end
66
67
 
67
68
  # :category: Constructors
68
- # Construct a Table from the contents of a CSV file. Headers will be taken
69
- # from the first row and converted to symbols.
69
+
70
+ # Construct a Table from the contents of a CSV file named +fname+. Headers
71
+ # will be taken from the first CSV row and converted to symbols.
70
72
  def self.from_csv_file(fname)
71
73
  File.open(fname, 'r') do |io|
72
74
  from_csv_io(io)
@@ -74,7 +76,9 @@ module FatTable
74
76
  end
75
77
 
76
78
  # :category: Constructors
77
- # Construct a Table from a string, treated as the input from a CSV file.
79
+
80
+ # Construct a Table from a CSV string +str+, treated in the same manner as
81
+ # the input from a CSV file in ::from_org_file.
78
82
  def self.from_csv_string(str)
79
83
  from_csv_io(StringIO.new(str))
80
84
  end
@@ -82,9 +86,9 @@ module FatTable
82
86
  # :category: Constructors
83
87
 
84
88
  # Construct a Table from the first table found in the given Emacs org-mode
85
- # file. Headers are taken from the first row if the second row is an hrule.
86
- # Otherwise, synthetic headers of the form +:col_1+, +:col_2+, etc. are
87
- # created.
89
+ # file named +fname+. Headers are taken from the first row if the second row
90
+ # is an hrule. Otherwise, synthetic headers of the form +:col_1+, +:col_2+,
91
+ # etc. are created.
88
92
  def self.from_org_file(fname)
89
93
  File.open(fname, 'r') do |io|
90
94
  from_org_io(io)
@@ -92,36 +96,39 @@ module FatTable
92
96
  end
93
97
 
94
98
  # :category: Constructors
95
- # Construct a Table from a string, treated as the contents of an org-mode
96
- # file.
99
+
100
+ # Construct a Table from a string +str+, treated in the same manner as the
101
+ # contents of an org-mode file in ::from_org_file.
97
102
  def self.from_org_string(str)
98
103
  from_org_io(StringIO.new(str))
99
104
  end
100
105
 
101
106
  # :category: Constructors
102
107
 
103
- # Construct a new table from an array of arrays. By default, with +hlines+
104
- # false, do not look for separators, i.e. nil or a string of dashes, just
105
- # treat the first row as headers. With +hlines+ true, expect separators to
106
- # mark the header row and any boundaries. If the second element of the array
107
- # is a +nil+, interpret the first element of the array as a row of headers.
108
- # Otherwise, synthesize headers of the form +:col_1+, +:col_2+, ... and so
109
- # forth. The remaining elements are taken as the body of the table, except
110
- # that if an element of the outer array is a +nil+, mark the preceding row
111
- # as a boundary. Note: In org mode code blocks, by default (+:hlines no+)
112
- # all hlines are stripped from the table, otherwise (+:hlines yes+) they are
113
- # indicated with nil elements in the outer array.
108
+ # Construct a new table from an Array of Arrays +aoa+. By default, with
109
+ # +hlines+ set to false, do not look for separators, i.e. +nils+, just treat
110
+ # the first row as headers. With +hlines+ set true, expect +nil+ separators
111
+ # to mark the header row and any boundaries. If the second element of the
112
+ # array is a +nil+, interpret the first element of the array as a row of
113
+ # headers. Otherwise, synthesize headers of the form +:col_1+, +:col_2+, ...
114
+ # and so forth. The remaining elements are taken as the body of the table,
115
+ # except that if an element of the outer array is a +nil+, mark the
116
+ # preceding row as a group boundary. Note for Emacs users: In org mode code
117
+ # blocks when an org-mode table is passed in as a variable it is passed in
118
+ # as an Array of Arrays. By default (+ HEADER: :hlines no +) org-mode strips
119
+ # all from the table; otherwise (+ HEADER: :hlines yes +) they are indicated
120
+ # with nil elements in the outer array.
114
121
  def self.from_aoa(aoa, hlines: false)
115
122
  from_array_of_arrays(aoa, hlines: hlines)
116
123
  end
117
124
 
118
125
  # :category: Constructors
119
126
 
120
- # Construct a Table from an array of hashes, or any objects that respond to
121
- # the #to_h method. All hashes must have the same keys, which, when
122
- # converted to symbols will become the headers for the Table. If hlines is
123
- # set true, mark a group boundary whenever a nil, rather than a hash
124
- # appears in the outer array.
127
+ # Construct a Table from +aoh+, an Array of Hashes or an Array of any
128
+ # objects that respond to the #to_h method. All hashes must have the same
129
+ # keys, which, when converted to symbols will become the headers for the
130
+ # Table. If hlines is set true, mark a group boundary whenever a nil, rather
131
+ # than a hash appears in the outer array.
125
132
  def self.from_aoh(aoh, hlines: false)
126
133
  if aoh.first.respond_to?(:to_h)
127
134
  from_array_of_hashes(aoh, hlines: hlines)
@@ -133,16 +140,16 @@ module FatTable
133
140
 
134
141
  # :category: Constructors
135
142
 
136
- # Construct a Table from another Table. Inherit any group boundaries from
137
- # the input table.
143
+ # Construct a new table from another FatTable::Table object +table+. Inherit any
144
+ # group boundaries from the input table.
138
145
  def self.from_table(table)
139
146
  table.deep_dup
140
147
  end
141
148
 
142
149
  # :category: Constructors
143
150
 
144
- # Construct a Table by running a SQL query against the database set up with
145
- # FatTable.set_db. Return the Table with the query results as rows.
151
+ # Construct a Table by running a SQL +query+ against the database set up
152
+ # with FatTable.set_db, with the rows of the query result as rows.
146
153
  def self.from_sql(query)
147
154
  raise UserError, 'FatTable.db must be set with FatTable.set_db' if FatTable.db.nil?
148
155
  result = Table.new
@@ -281,13 +288,16 @@ module FatTable
281
288
  ###########################################################################
282
289
 
283
290
  # :category: Attributes
284
- # Return the Column with the given header.
291
+
292
+ # Return the table's Column with the given +key+ as its header.
285
293
  def column(key)
286
294
  columns.detect { |c| c.header == key.as_sym }
287
295
  end
288
296
 
289
297
  # :category: Attributes
290
- # Return the type of the Column with the given header
298
+
299
+ # Return the type of the Column with the given +key+ as its
300
+ # header as a String.
291
301
  def type(key)
292
302
  column(key).type
293
303
  end
@@ -295,11 +305,11 @@ module FatTable
295
305
  # :category: Attributes
296
306
 
297
307
  # Return the array of items of the column with the given header symbol
298
- # +key+, or if +key+ is an Integer, return that row number. So a table's
299
- # rows can be accessed by number, and its columns can be accessed by column
300
- # header. Also, double indexing works in either row-major or column-major
301
- # order: \tab\[:id\]\[8\] returns the 9th item in the column headed :id and
302
- # so does \tab\[8\]\[:id\].
308
+ # +key+, or if +key+ is an Integer, return that row at that index. So a
309
+ # table's rows can be accessed by number, and its columns can be accessed by
310
+ # column header. Also, double indexing works in either row-major or
311
+ # column-major order: \tab\[:id\]\[8\] returns the 9th item in the column
312
+ # headed :id and so does \tab\[8\]\[:id\].
303
313
  def [](key)
304
314
  case key
305
315
  when Integer
@@ -325,7 +335,7 @@ module FatTable
325
335
 
326
336
  # :category: Attributes
327
337
 
328
- # Return a Hash of the Table's Column header symbols to types.
338
+ # Return a Hash of the Table's Column header symbols to type strings.
329
339
  def types
330
340
  result = {}
331
341
  columns.each do |c|
@@ -336,7 +346,7 @@ module FatTable
336
346
 
337
347
  # :category: Attributes
338
348
 
339
- # Return the headers for the Table as an array of symbols.
349
+ # Return the headers for the Table as an Array of Symbols.
340
350
  def headers
341
351
  columns.map(&:header)
342
352
  end
@@ -461,7 +471,7 @@ module FatTable
461
471
  # boundaries would make no sense anyway. Likewise, #union, #intersection,
462
472
  # #except, and #join reset the boundaries to their default.
463
473
  #
464
- # Return an array of an array of row hashes for the groups in this Table.
474
+ # Return an array of an Array of row Hashes for the groups in this Table.
465
475
  def groups
466
476
  normalize_boundaries
467
477
  groups = []
@@ -482,8 +492,9 @@ module FatTable
482
492
  self
483
493
  end
484
494
 
485
- # Mark a boundary at k, and if k is nil, mark the last row in the table as a
486
- # group boundary. This is used for internal purposes.
495
+ # Mark a group boundary at row +k+, and if +k+ is +nil+, mark the last row
496
+ # in the table as a group boundary. This is mainly used for internal
497
+ # purposes.
487
498
  def mark_boundary(k = nil) # :nodoc:
488
499
  if k
489
500
  boundaries.push(k)
@@ -551,11 +562,11 @@ module FatTable
551
562
  # :category: Operators
552
563
 
553
564
  # Return a new Table sorting the rows of this Table on the possibly multiple
554
- # keys given in the array of syms in headers. Append a ! to the symbol name
555
- # to indicate reverse sorting on that column.
565
+ # keys given in +sort_heads+ as an Array of Symbols. Append a ! to the
566
+ # symbol name to indicate reverse sorting on that column.
556
567
  #
557
568
  # tab.order_by(:ref, :date) => sorted table
558
- # tab.order_by(:date!) => reverse sort on :date
569
+ # tab.order_by(:date!) => reverse sort on :date
559
570
  #
560
571
  # After sorting, the output Table will have group boundaries added after
561
572
  # each row where the sort key changes.
@@ -588,23 +599,25 @@ module FatTable
588
599
  # Return a Table having the selected column expressions. Each expression can
589
600
  # be either a
590
601
  #
591
- # 1. a symbol, +:old_col+, representing a column in the current table,
602
+ # 1. in +cols+, a symbol, +:old_col+, representing a column in the current
603
+ # table,
592
604
  #
593
- # 2. a hash of +new_col: :old_col+ to rename an existing +:old_col+ column as
594
- # +:new_col+, or
605
+ # 2. a hash in +new_cols+ of the form +new_col: :old_col+ to rename an
606
+ # existing +:old_col+ column as +:new_col+, or
595
607
  #
596
- # 3. a hash of +new_col: 'expression'+, to add a new column that is computed
597
- # as an arbitrary ruby expression of the existing columns (whether
598
- # selected for the output table or not) or any new_col defined earlier in
599
- # the argument list defined as local variables in the expression. The
600
- # expression string can also access the instance variable @row, as the row
601
- # number of the row being evaluated, and @group, as the group number of
602
- # the row being evaluated.
608
+ # 3. a hash in +new_cols+ of the form +new_col: 'expression'+, to add a new
609
+ # column +new_col+ that is computed as an arbitrary ruby expression in
610
+ # which there are local variables bound to the names of existing columns
611
+ # (whether selected for the output table or not) as well as any +new_col+
612
+ # defined earlier in the argument list. The expression string can also
613
+ # access the instance variable @row, as the row number of the row being
614
+ # evaluated, and @group, as the group number of the row being evaluated.
603
615
  #
604
- # The bare symbol arguments (1) must precede any hash arguments (2) or (3).
605
- # Each expression results in a column in the resulting Table in the order
606
- # given. The expressions are evaluated in left-to-right order as well. The
607
- # output table preserves any groups present in the input table.
616
+ # The bare symbol arguments +cols+ (1) must precede any hash arguments
617
+ # +new_cols+ (2 or 3). Each expression results in a column in the resulting
618
+ # Table in the order given in the argument list. The expressions are
619
+ # evaluated in left-to-right order as well. The output table preserves any
620
+ # groups present in the input table.
608
621
  #
609
622
  # tab.select(:ref, :date, :shares) => table with only 3 columns selected
610
623
  # tab.select(:ref, :date, shares: :quantity) => rename :shares->:quantity
@@ -676,7 +689,7 @@ module FatTable
676
689
 
677
690
  # :category: Operators
678
691
 
679
- # Return this table with all duplicate rows eliminated. Resets groups. Same
692
+ # Return a new table with all duplicate rows eliminated. Resets groups. Same
680
693
  # as #uniq.
681
694
  def distinct
682
695
  result = Table.new
@@ -697,12 +710,12 @@ module FatTable
697
710
 
698
711
  # :category: Operators
699
712
 
700
- # Return a Table that combines this table with +other+ table. In other
701
- # words, return the union of this table with the other. The headers of this
702
- # table are used in the result. There must be the same number of columns of
703
- # the same type in the two tables, or an exception will be thrown.
704
- # Duplicates are eliminated from the result. Any groups present in either
705
- # Table are eliminated in the output Table.
713
+ # Return a Table that combines this table with +other+ table, i.e., return
714
+ # the union of this table with the other. The headers of this table are used
715
+ # in the result. There must be the same number of columns of the same type
716
+ # in the two tables, otherwise an exception will be raised. Duplicates are
717
+ # eliminated from the result. Any groups present in either Table are
718
+ # eliminated in the output Table.
706
719
  def union(other)
707
720
  set_operation(other, :+,
708
721
  distinct: true,
@@ -753,10 +766,10 @@ module FatTable
753
766
  # :category: Operators
754
767
 
755
768
  # Return a Table that includes the rows of this table except for any rows
756
- # that are the same as those in another table. In other words, return the
757
- # set difference between this table an the other. The headers of this table
769
+ # that are the same as those in Table +other+. In other words, return the
770
+ # set difference between this table and +other+. The headers of this table
758
771
  # are used in the result. There must be the same number of columns of the
759
- # same type in the two tables, or an exception will be thrown. Duplicates
772
+ # same type in the two tables, or an exception will be raised. Duplicates
760
773
  # are eliminated from the result. Any groups present in either Table are
761
774
  # eliminated in the output Table.
762
775
  def except(other)
@@ -766,12 +779,12 @@ module FatTable
766
779
  # :category: Operators
767
780
 
768
781
  # Return a Table that includes the rows of this table except for any rows
769
- # that are the same as those in +other+ Table. In other words, return the
782
+ # that are the same as those in Table +other+. In other words, return the
770
783
  # set difference between this table an the other. The headers of this table
771
784
  # are used in the result. There must be the same number of columns of the
772
785
  # same type in the two tables, or an exception will be thrown. Duplicates
773
- # are not eliminated from the result. Any groups present in either Table are
774
- # eliminated in the output Table.
786
+ # are /not/ eliminated from the result. Any groups present in either Table
787
+ # are eliminated in the output Table.
775
788
  def except_all(other)
776
789
  set_operation(other, :difference, distinct: false)
777
790
  end
@@ -814,8 +827,10 @@ module FatTable
814
827
 
815
828
  # :category: Operators
816
829
  #
817
- # Return a table that joins this table to another based on one or more join
818
- # expressions. There are several possibilities for the join expressions:
830
+ # Return a table that joins this Table to +other+ based on one or more join
831
+ # expressions +exps+ using the +join_type+ in determining the rows of the
832
+ # result table. There are several possible forms for the join expressions
833
+ # +exps+:
819
834
  #
820
835
  # 1. If no join expressions are given, the tables will be joined when all
821
836
  # values with the same name in both tables have the same value, a
@@ -876,8 +891,8 @@ module FatTable
876
891
  # the tables have N and M rows respectively, the joined table will
877
892
  # have N * M rows.
878
893
  #
879
- # Any groups present in either Table are eliminated in the output Table.
880
- # See the README for examples.
894
+ # Any groups present in either Table are eliminated in the output Table. See
895
+ # the README for examples.
881
896
  def join(other, *exps, join_type: :inner)
882
897
  unless other.is_a?(Table)
883
898
  raise UserError, 'need other table as first argument to join'
@@ -927,31 +942,36 @@ module FatTable
927
942
  end
928
943
 
929
944
  # :category: Operators
930
- # Perform an inner join as described in FatTable::Table.join.
945
+
946
+ # Perform an inner join as described in FatTable::Table#join.
931
947
  def inner_join(other, *exps)
932
948
  join(other, *exps)
933
949
  end
934
950
 
935
951
  # :category: Operators
936
- # Perform a left join as described in FatTable::Table.join.
952
+
953
+ # Perform a left join as described in FatTable::Table#join.
937
954
  def left_join(other, *exps)
938
955
  join(other, *exps, join_type: :left)
939
956
  end
940
957
 
941
958
  # :category: Operators
942
- # Perform a right join as described in FatTable::Table.join.
959
+
960
+ # Perform a right join as described in FatTable::Table#join.
943
961
  def right_join(other, *exps)
944
962
  join(other, *exps, join_type: :right)
945
963
  end
946
964
 
947
965
  # :category: Operators
948
- # Perform a full join as described in FatTable::Table.join.
966
+
967
+ # Perform a full join as described in FatTable::Table#join.
949
968
  def full_join(other, *exps)
950
969
  join(other, *exps, join_type: :full)
951
970
  end
952
971
 
953
972
  # :category: Operators
954
- # Perform a cross join as described in FatTable::Table.join.
973
+
974
+ # Perform a cross join as described in FatTable::Table#join.
955
975
  def cross_join(other)
956
976
  join(other, join_type: :cross)
957
977
  end
@@ -1099,23 +1119,24 @@ module FatTable
1099
1119
  public
1100
1120
 
1101
1121
  # :category: Operators
1122
+
1102
1123
  # Return a Table with a single row for each group of rows in the input table
1103
- # where the value of all columns named as simple symbols are equal. All
1104
- # other columns are set to the result of aggregating the values of that
1105
- # column within the group according to a aggregate function (:count, :sum,
1106
- # :min, :max, etc.) that you can specify by adding a hash parameter with the
1107
- # column as the key and a symbol for the aggregate function as the value.
1108
- # For example, consider the following call:
1124
+ # where the value of all columns +group_cols+ named as simple symbols are
1125
+ # equal. All other columns, +agg_cols+, are set to the result of aggregating
1126
+ # the values of that column within the group according to a aggregate
1127
+ # function (:count, :sum, :min, :max, etc.) that you can specify by adding a
1128
+ # hash parameter with the column as the key and a symbol for the aggregate
1129
+ # function as the value. For example, consider the following call:
1109
1130
  #
1110
1131
  # tab.group_by(:date, :code, :price, shares: :sum).
1111
1132
  #
1112
- # The first three parameters are simple symbols, so the table is divided
1113
- # into groups of rows in which the value of :date, :code, and :price are
1114
- # equal. The shares: hash parameter is set to the aggregate function :sum,
1115
- # so it will appear in the result as the sum of all the :shares values in
1116
- # each group. Because of the way Ruby parses parameters to a method call,
1117
- # all the grouping symbols must appear first in the parameter list before
1118
- # any hash parameters.
1133
+ # The first three parameters are simple symbols and count as +group_cols+,
1134
+ # so the table is divided into groups of rows in which the value of :date,
1135
+ # :code, and :price are equal. The shares: hash parameter is an +agg_col+
1136
+ # parameter set to the aggregate function :sum, so it will appear in the
1137
+ # result as the sum of all the :shares values in each group. Because of the
1138
+ # way Ruby parses parameters to a method call, all the grouping symbols must
1139
+ # appear first in the parameter list before any hash parameters.
1119
1140
  def group_by(*group_cols, **agg_cols)
1120
1141
  sorted_tab = order_by(group_cols)
1121
1142
  groups = sorted_tab.rows.group_by do |r|
@@ -1152,9 +1173,10 @@ module FatTable
1152
1173
  public
1153
1174
 
1154
1175
  # :category: Constructors
1155
- # Add a row represented by a Hash having the headers as keys. If mark is
1156
- # true, mark this row as a boundary. All tables should be built ultimately
1157
- # using this method as a primitive.
1176
+
1177
+ # Add a +row+ represented by a Hash having the headers as keys. If +mark:+
1178
+ # is set true, mark this row as a boundary. All tables should be built
1179
+ # ultimately using this method as a primitive.
1158
1180
  def add_row(row, mark: false)
1159
1181
  row.each_pair do |k, v|
1160
1182
  key = k.as_sym
@@ -1166,12 +1188,14 @@ module FatTable
1166
1188
  end
1167
1189
 
1168
1190
  # :category: Constructors
1169
- # Add a row without marking.
1191
+
1192
+ # Add a +row+ without marking it as a group boundary.
1170
1193
  def <<(row)
1171
1194
  add_row(row)
1172
1195
  end
1173
1196
 
1174
1197
  # :category: Constructors
1198
+
1175
1199
  # Add a FatTable::Column object +col+ to the table.
1176
1200
  def add_column(col)
1177
1201
  raise "Table already has a column with header '#{col.header}'" if column?(col.header)
@@ -1193,12 +1217,12 @@ module FatTable
1193
1217
  # :category: Output
1194
1218
 
1195
1219
  # Return a string or ruby object according to the format specified in
1196
- # FatTable.format. If a block is given, it will yield a Formatter of the
1197
- # appropriate type to which format and footers can be applied. Otherwise, the
1198
- # default format for the type will be used.
1220
+ # FatTable.format, passing the +options+ on to the Formatter. If a block is
1221
+ # given, it will yield a Formatter of the appropriate type to which format
1222
+ # and footers can be applied. Otherwise, the default format for the type
1223
+ # will be used.
1199
1224
  #
1200
- # :call-seq:
1201
- # to_format(options = {}) { |fmt| ... }
1225
+ # :call-seq: to_format(options = {}) { |fmt| ... }
1202
1226
  #
1203
1227
  def to_format(options = {})
1204
1228
  if block_given?
@@ -1211,11 +1235,11 @@ module FatTable
1211
1235
  # :category: Output
1212
1236
 
1213
1237
  # Return a string or ruby object according to the format type +fmt_type+
1214
- # given in the first argument. Valid format types are :psv, :aoa, :aoh,
1215
- # :latex, :org, :term, :text, or their string equivalents. If a block is
1216
- # given, it will yield a Formatter of the appropriate type to which format
1217
- # and footers can be applied. Otherwise, the default format for the type
1218
- # will be used.
1238
+ # given in the first argument, passing the +options+ on to the Formatter.
1239
+ # Valid format types are :psv, :aoa, :aoh, :latex, :org, :term, :text, or
1240
+ # their string equivalents. If a block is given, it will yield a Formatter
1241
+ # of the appropriate type to which format and footers can be applied.
1242
+ # Otherwise, the default format for the type will be used.
1219
1243
  #
1220
1244
  # :call-seq: to_any(fmt_type, options = {}) { |fmt| ... }
1221
1245
  #
@@ -1232,12 +1256,13 @@ module FatTable
1232
1256
 
1233
1257
  # :category: Output
1234
1258
 
1235
- # Return the table as a string formatted as a pipe-separated values. If no
1236
- # block is given, default formatting is applies to the table's cells. If a
1237
- # block is given, it yields a Formatter to the block to which formatting
1238
- # instructions and footers can be added by calling methods on it. Since the
1239
- # pipe-separated format is the default format for Formatter, there is no
1240
- # class PsvFormatter as you might expect.
1259
+ # Return the table as a string formatted as a pipe-separated values, passing
1260
+ # the +options+ on to the Formatter. If no block is given, default
1261
+ # formatting is applies to the table's cells. If a block is given, it yields
1262
+ # a Formatter to the block to which formatting instructions and footers can
1263
+ # be added by calling methods on it. Since the pipe-separated format is the
1264
+ # default format for Formatter, there is no class PsvFormatter as you might
1265
+ # expect.
1241
1266
  def to_psv(options = {})
1242
1267
  fmt = Formatter.new(self, options)
1243
1268
  yield fmt if block_given?
@@ -1246,10 +1271,11 @@ module FatTable
1246
1271
 
1247
1272
  # :category: Output
1248
1273
 
1249
- # Return the table as an Array of Array of Strings. If no block is given,
1250
- # default formatting is applies to the table's cells. If a block is given,
1251
- # it yields an AoaFormatter to the block to which formatting instructions
1252
- # and footers can be added by calling methods on it.
1274
+ # Return the table as an Array of Array of Strings, passing the +options+ on
1275
+ # to the AoaFormatter. If no block is given, default formatting is applies
1276
+ # to the table's cells. If a block is given, it yields an AoaFormatter to
1277
+ # the block to which formatting instructions and footers can be added by
1278
+ # calling methods on it.
1253
1279
  def to_aoa(options = {})
1254
1280
  fmt = FatTable::AoaFormatter.new(self, options)
1255
1281
  yield fmt if block_given?
@@ -1258,12 +1284,12 @@ module FatTable
1258
1284
 
1259
1285
  # :category: Output
1260
1286
 
1261
- # Return the table as an Array of Hashes. Each inner hash uses the Table's
1262
- # columns as keys and it values are strings representing the cells of the
1263
- # table. If no block is given, default formatting is applies to the table's
1264
- # cells. If a block is given, it yields an AohFormatter to the block to
1265
- # which formatting instructions and footers can be added by calling methods
1266
- # on it.
1287
+ # Return the table as an Array of Hashes, passing the +options+ on to the
1288
+ # AohFormatter. Each inner hash uses the Table's columns as keys and it
1289
+ # values are strings representing the cells of the table. If no block is
1290
+ # given, default formatting is applies to the table's cells. If a block is
1291
+ # given, it yields an AohFormatter to the block to which formatting
1292
+ # instructions and footers can be added by calling methods on it.
1267
1293
  def to_aoh(options = {})
1268
1294
  fmt = AohFormatter.new(self, options)
1269
1295
  yield fmt if block_given?
@@ -1272,10 +1298,11 @@ module FatTable
1272
1298
 
1273
1299
  # :category: Output
1274
1300
 
1275
- # Return the table as a string containing a LaTeX table. If no block is
1276
- # given, default formatting applies to the table's cells. If a block is
1277
- # given, it yields a LaTeXFormatter to the block to which formatting
1278
- # instructions and footers can be added by calling methods on it.
1301
+ # Return the table as a string containing a LaTeX table, passing the
1302
+ # +options+ on to the LaTeXFormatter. If no block is given, default
1303
+ # formatting applies to the table's cells. If a block is given, it yields a
1304
+ # LaTeXFormatter to the block to which formatting instructions and footers
1305
+ # can be added by calling methods on it.
1279
1306
  def to_latex(options = {})
1280
1307
  fmt = LaTeXFormatter.new(self, options)
1281
1308
  yield fmt if block_given?
@@ -1284,10 +1311,11 @@ module FatTable
1284
1311
 
1285
1312
  # :category: Output
1286
1313
 
1287
- # Return the table as a string containing an Emacs org-mode table. If no
1288
- # block is given, default formatting applies to the table's cells. If a
1289
- # block is given, it yields a OrgFormatter to the block to which formatting
1290
- # instructions and footers can be added by calling methods on it.
1314
+ # Return the table as a string containing an Emacs org-mode table, passing
1315
+ # the +options+ on to the OrgFormatter. If no block is given, default
1316
+ # formatting applies to the table's cells. If a block is given, it yields a
1317
+ # OrgFormatter to the block to which formatting instructions and footers can
1318
+ # be added by calling methods on it.
1291
1319
  def to_org(options = {})
1292
1320
  fmt = OrgFormatter.new(self, options)
1293
1321
  yield fmt if block_given?
@@ -1297,10 +1325,10 @@ module FatTable
1297
1325
  # :category: Output
1298
1326
 
1299
1327
  # Return the table as a string containing ANSI terminal text representing
1300
- # table. If no block is given, default formatting applies to the table's
1301
- # cells. If a block is given, it yields a TermFormatter to the block to
1302
- # which formatting instructions and footers can be added by calling methods
1303
- # on it.
1328
+ # table, passing the +options+ on to the TermFormatter. If no block is
1329
+ # given, default formatting applies to the table's cells. If a block is
1330
+ # given, it yields a TermFormatter to the block to which formatting
1331
+ # instructions and footers can be added by calling methods on it.
1304
1332
  def to_term(options = {})
1305
1333
  fmt = TermFormatter.new(self, options)
1306
1334
  yield fmt if block_given?
@@ -1309,10 +1337,12 @@ module FatTable
1309
1337
 
1310
1338
  # :category: Output
1311
1339
 
1312
- # Return the table as a string containing ordinary text representing table.
1313
- # If no block is given, default formatting applies to the table's cells. If
1314
- # a block is given, it yields a TextFormatter to the block to which
1315
- # formatting instructions and footers can be added by calling methods on it.
1340
+ # Return the table as a string containing ordinary text representing table,
1341
+ # passing the +options+ on to the TextFormatter. If no block is given,
1342
+ # default formatting applies to the table's cells. If a block is given, it
1343
+ # yields a TextFormatter to the block to which formatting instructions and
1344
+ # footers can be added by calling methods on it.
1345
+ # @return [String]
1316
1346
  def to_text(options = {})
1317
1347
  fmt = TextFormatter.new(self, options)
1318
1348
  yield fmt if block_given?
@@ -1,4 +1,4 @@
1
1
  module FatTable
2
2
  # The current version of FatTable
3
- VERSION = '0.2.3'.freeze
3
+ VERSION = '0.2.4'.freeze
4
4
  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.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-08 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rcodetools
126
+ name: redcarpet
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -142,20 +142,20 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '2.0'
145
+ version: '4.0'
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
- version: 2.0.1
148
+ version: '4.1'
149
149
  type: :runtime
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - "~>"
154
154
  - !ruby/object:Gem::Version
155
- version: '2.0'
155
+ version: '4.0'
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
- version: 2.0.1
158
+ version: '4.1'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: activesupport
161
161
  requirement: !ruby/object:Gem::Requirement
@@ -280,6 +280,7 @@ files:
280
280
  - ".gitignore"
281
281
  - ".rspec"
282
282
  - ".travis.yml"
283
+ - ".yardopts"
283
284
  - Gemfile
284
285
  - LICENSE.txt
285
286
  - README.org
@@ -308,6 +309,7 @@ homepage: https://github.com/ddoherty03/fat_table
308
309
  licenses: []
309
310
  metadata:
310
311
  allowed_push_host: https://rubygems.org
312
+ yard.run: yri
311
313
  post_install_message:
312
314
  rdoc_options: []
313
315
  require_paths:
@@ -324,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
326
  version: '0'
325
327
  requirements: []
326
328
  rubyforge_project:
327
- rubygems_version: 2.5.1
329
+ rubygems_version: 2.5.2
328
330
  signing_key:
329
331
  specification_version: 4
330
332
  summary: Provides tools for working with tables as a data type.