Skip to content

PeterFaiman/pretty_table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrettyTable

Build Status

Format arrays into ASCII tables.

Includes a command line tool pretty_table that reads text input and outputs a pretty table.

Gem Usage

require 'pretty_table'

headers = ['column 1', 'column 2']
rows = [
  [4_294_967_295, 'string'],
  [true, nil],
]

puts PrettyTable.pretty_table(headers, rows)
puts PrettyTable.pretty_table(headers, rows, justify: :left)

Output:

+------------+----------+
|   column 1 | column 2 |
+------------+----------+
| 4294967295 |   string |
|       true |          |
+------------+----------+
+------------+----------+
| column 1   | column 2 |
+------------+----------+
| 4294967295 | string   |
| true       |          |
+------------+----------+

Tool Usage

The command line tool accepts a field separator. It recognizes a single \t as tab, and a single \xHH as a hex specified character.

$ pretty_table -F ,
column 1,column 2
4_294_967_295,string
true,nil
^D
+---------------+----------+
|      column 1 | column 2 |
+---------------+----------+
| 4_294_967_295 |   string |
|          true |      nil |
+---------------+----------+

License

The gem is available as open source under the terms of the MIT License.

About

Format arrays into ASCII tables.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages