Table Generator
Plain text table generator for ruby.
Main features:
- Choose column/header alignment (left, center or right)
- CJK characters support
- Embed progress bars (example in the documentation)
- Insert text in the table
- Minimum column length
- Optional size constraint
- Per column data formatter (data is separated from the layout)
- Scale down large tables with collapsible columns
- Scale up small tables with stretchable columns
- Unlimited border length
Installation
Add this line to your application's Gemfile:
gem 'tablegen'
And then execute:
$ bundle
Or install it yourself as:
$ gem install tablegen
Documentation
The documentation is hosted at
http://rubydoc.info/gems/tablegen/TableGen.
Basic Usage
require 'tablegen'
table = TableGen.new
table.header 'Browser Name', 'Layout Engine', 'License'
table.separator
table.row 'Chromium', 'Blink', 'BSD'
table.row 'dwb', 'WebKit', 'GNU GPLv3'
table.row 'Internet Explorer', 'Trident', 'Proprietary'
table.row 'Mozilla Firefox', 'Gecko', 'MPL'
puts table
Output:
Browser Name Layout Engine License
===========================================
Chromium Blink BSD
dwb WebKit GNU GPLv3
Internet Explorer Trident Proprietary
Mozilla Firefox Gecko MPL
Set the size constraint and stretch the first column:
table.width = 50
table.column 0 do |col|
col.stretch = true
end
puts table
Output:
Browser Name Layout Engine License
==================================================
Chromium Blink BSD
dwb WebKit GNU GPLv3
Internet Explorer Trident Proprietary
Mozilla Firefox Gecko MPL
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Test your changes (
rake
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request