Description
Library can be used to render your data to a console. Though it's quite simple, but has many features.
How to use
- Install the gem
bundle add tabled
orgem install tabled
- Add to the application
require 'tabled''
- Pass to the application array of rows. Each row may have any amount of columns and optional footer text.
Params for Tabled instance
Tabled accepts two params. Data which is prohibited and options.
Available options:
-
framed
- optional, default is true -
row_separator
- optional, default is-
. Can benil
if you don't need separate rows. -
titles
- optional parameter with list of columns titles
More examples in demo.rb
Simple data structure
data = [
["Helena", "20 years", "Female"],
["John", "18 years", "Male"],
["Alan", "23 years", "Male"],
]
Tabled.new(data, framed: false,
row_separator: nil).print_to_console
Result
Helena 20 years Female
John 18 years Male
Alan 23 years Male
Using footer inside a row
data = [
["Helena", "20 years", "Female"],
["John", "18 years", "Male", { footer: "Legendary assassin John Wick (Keanu Reeves)." }],
["Alan", "23 years", "Male"],
]
Tabled.new(data, row_separator: nil).print_to_console
Result
----------------------------------------------------------------
| Helena 20 years Female |
| John 18 years Male |
| Legendary assassin John Wick (Keanu Reeves). |
| Alan 23 years Male |
----------------------------------------------------------------
Contributing
- Fork it ( http://github.com/rukomoynikov/tabled/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request