Tablizer
DESCRIPTION
Tablizer is a gem that provides you a tool for quickly rendering tables, and has ANSI support for printing color strings into your console.
This should do the trick:
table = [
['animal', 'familia', 'cantidad de patas', 'pelaje' ],
['ornitorrinco', 'mamiferos', '4', 'mediano y marron' , "caca"],
['pato', 'aves', '2', 'plumas blancas' ],
['gato', 'mamiferos', '4', 'gris y corto' ],
['marmota', 'mamiferos', '4', 'color natural y corto' ]
]
mytable = Table.new(table, header: true, align: 'right')
puts mytable
=> +------------+---------+-----------------+---------------------+----+
| Animal | Familia |Cantidad de patas| Pelaje | |
+------------+---------+-----------------+---------------------+----+
|ornitorrinco|mamiferos| 4| mediano y marron|caca|
| pato| aves| 2| plumas blancas| |
| gato|mamiferos| 4| gris y corto| |
| marmota|mamiferos| 4|color natural y corto| |
+------------+---------+-----------------+---------------------+----+
The table object has the [] and []= methods, that lets you access it's data and manipulate it.
mytable[0,3] # => 'gato'
mytable[0,6] # => nil
mytable[3,2] = 'trololo'
=> +------------+---------+-----------------+---------------------+----+
| Animal | Familia |Cantidad de patas| Pelaje | |
+------------+---------+-----------------+---------------------+----+
|ornitorrinco|mamiferos| 4| mediano y marron|caca|
| pato| aves| 2| trololo| |
| gato|mamiferos| 4| gris y corto| |
| marmota|mamiferos| 4|color natural y corto| |
+------------+---------+-----------------+---------------------+----+