Skip to content

Instantly share code, notes, and snippets.

@thejefflarson
Created August 9, 2010 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejefflarson/516193 to your computer and use it in GitHub Desktop.
Save thejefflarson/516193 to your computer and use it in GitHub Desktop.
class TableFu
def group_by(column)
rows = [["column", "value"]]
faceted_by(column).each {|table| rows << [table.faceted_on, table.rows.length] }
TableFu.new rows
end
end
table = TableFu.new data
table.group_by column
>> #<TableFu:0x1032fd2b8 @column_headers=["column", "value"], @col_opts={}, @table=[[-1, -3], [0, 0], [1, 26], [2, 26], [3, 27], [4, 52]], @totals={}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment