Project

tabled

0.0
The project is in a healthy, maintained state
Library can be used to render your data to a console. Though it's quite simple, but has many features.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

 Project Readme

Gem Version CI is pasing for ruby 2.6 - 3.0 Downloads

Description

Library can be used to render your data to a console. Though it's quite simple, but has many features.

How to use

  1. Install the gem bundle add tabled or gem install tabled
  2. Add to the application require 'tabled''
  3. 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:

  1. framed - optional, default is true
  2. row_separator - optional, default is -. Can be nil if you don't need separate rows.
  3. 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

  1. Fork it ( http://github.com/rukomoynikov/tabled/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request