Socket
Book a DemoInstallSign in
Socket

termtable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

termtable

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Termtable

Installation

Add this line to your application's Gemfile:

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.

table = Termtable::Table.new [[1, 2, 3], [4, 5, 6]]

This can also be given as a hash with a rows key.

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

Termtable::Table.new ['Header A', 'Header B'], [['a1', 'a2'], ['b1', 'b2']]

Also as a headers key

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

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

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.

FAQs

Package last updated on 15 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.