Sha256: 4caafde9f390c6dcb4d229d216fcae617c8b461c7bbb3653fb80a348d110968d
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# Termtable ## Installation Add this line to your application's Gemfile: ```ruby gem 'termtable' ``` And then execute: $ bundle Or install it yourself as: $ gem install termtable ## Usage A table instance can take a 2 dimensional array for the rows. ```ruby table = Termtable::Table.new [[1, 2, 3], [4, 5, 6]] ``` This can also be given as a hash with a rows key. ```ruby table = Termtable::Table.new rows: [[1, 2, 3], [4, 5, 6]] puts table.render +--+--+--+ |1 |2 |3 | |4 |5 |6 | +--+--+--+ ``` ### Headers Headers can be given as the first array ```ruby Termtable::Table.new ['Header A', 'Header B'], [['a1', 'a2'], ['b1', 'b2']] ``` Also as a headers key ```ruby Termtable::Table.new headers: ['Header A', 'Header B'], rows: [['a1', 'a2'], ['b1', 'b2']] +---------+---------+ |Header A |Header B | +---------+---------+ |a1 |a2 | |b1 |b2 | +---------+---------+ ``` ### Padding It is possible to pass a padding argument to the render method ```ruby table = Termtable::Table.new rows: [['a1', 'a2'], ['b1', 12345]] puts table.render(padding: 3) +-----+--------+ |a1 |a2 | |b1 |12345 | +-----+--------+ ``` ### Alignment It is possible to pass an alignment argument to render ```ruby table = Termtable::Table.new rows: [['a1', 'a2'], ['b1', 123456]] puts table.render(alignment: 'center') +----+--------+ | a1 | a2 | | b1 | 123456 | +----+--------+ ``` ## Development To run the tests $ rake ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/nikkypx/termtable.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
termtable-0.1.0 | README.md |