terminal_table
terminal_table
A library that helps you create and print tables on your terminal!
Installation
-
Add the dependency to your
shard.yml
:dependencies: terminal_table: github: kouroshalinaghi/terminal_table
-
Run
shards install
Usage
- You need an Array of Array of Int32 Or String (
Array(Array(Int32 | String))
) as rows. - Create an instance of
TerminalTable::Table
with callingTerminalTable::Table.new()
. Here are the supported arguments:
Key | Type | Default Value | Required? |
---|---|---|---|
rows |
Array(Array(Int32 | String)) |
_ | Yes |
enable_separator |
Bool |
true |
No |
header |
Array(String) |
[] of String |
No |
corner_char |
String |
"+" |
No |
row_char |
String |
"-" |
No |
col_char |
String |
"|" |
No |
Example:
h = ["Name", "Age"]
r = [
["Kourosh", 17],
["Dan", 32]
]
table = TerminalTable::Table.new(rows: r, header: h)
- Print the table with the
TerminalTable::Table#to_s
method! (returns aString
)
puts table.to_s
Example:
+---------+-----+
| Name | Age |
+---------+-----+
| Kourosh | 17 |
+---------+-----+
| Dan | 32 |
+---------+-----+
Important: Do not use p()
method instead of puts()
! it will consider "\n"
as a normal string.
Contributing
- Fork it (https://github.com/kouroshalinaghi/terminal_table/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 a new Pull Request
Contributors
- KouroshAlinaghi - creator and maintainer
terminal_table
Repository
terminal_table
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- about 4 years ago
- August 31, 2020
License
MIT License
Links
Synced at
Thu, 21 Nov 2024 10:53:06 GMT
Languages