Tblr
Table is a really little gem that gives you a table data type
Installation
Add this line to your application's Gemfile:
gem 'tblr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install tblr
Usage
create a table
headers = ['firstName', 'last_name']
rows = [
%w(Barny Rubble),
%w(Fred Flinstone),
%w(Wilma Flinstone),
]
@table = Table.new(headers, rows)
Do things with your table
@table.collect(&:firstName) #=> ['Rubble', 'Fred', 'Wilma']
@table.size #=> 3
@table[0] #=> #<Tblr::Row: @headers=["firstName", "last_name"], @row=["First", "Last"]>
@table.group_by(&:last_name) #=>
# {
# "Rubble" => #<Tblr::Table: @headers=["firstName", "last_name"],
# @rows=[["Barny", "Rubble"]]>,
# "Flinstone" => #<Tblr::Table: @headers=["firstName", "last_name"],
# @rows=[["Fred", "Flinstone"], ["Wilma", "Flinstone"]]>
# }
Note: Table includes Enumerable, so you can do all those things too.
Contributing
- Fork it ( https://github.com/[my-github-username]/tblr/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Writes Specs, pull requrests will not be accepted without tests.
- Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request