Fork me on GitHub

Project Notes

#143 Tables

Generating data tables in the console from Array, Hash, or ActiveRecord objects with the tablesmith gem.

Notes

I learned of the tablesmith gem in rubyweekly #492.

It’s a pretty neat little utility for generating console tables.

Taking it for a quick test drive…

Running the Example

The Gemfile specifies the gem requirements. bundle install as usual.

$ gem install bundler && bundle install
$ ./example.rb
Books Published/Year. Source: https://en.wikipedia.org/wiki/Books_published_per_country_per_year
+----------------+--------+
|    Country     | Books  |
+----------------+--------+
| Australia      | 28234  |
| Brazil         | 57473  |
| China          | 440000 |
| France         | 77986  |
| Germany        | 93600  |
| India          | 90000  |
| Indonesia      | 89000  |
| Italy          | 61966  |
| Iran           | 72871  |
| Japan          | 139078 |
| Russia         | 101981 |
| South Korea    | 63476  |
| Spain          | 44000  |
| Taiwan         | 28084  |
| Turkey         | 66890  |
| United Kingdom | 184000 |
| United States  | 304912 |
+----------------+--------+
Sorted:
+----------------+--------+
|    Country     | Books  |
+----------------+--------+
| China          | 440000 |
| United States  | 304912 |
| United Kingdom | 184000 |
| Japan          | 139078 |
| Russia         | 101981 |
| Germany        | 93600  |
| India          | 90000  |
| Indonesia      | 89000  |
| France         | 77986  |
| Iran           | 72871  |
| Turkey         | 66890  |
| South Korea    | 63476  |
| Italy          | 61966  |
| Brazil         | 57473  |
| Spain          | 44000  |
| Australia      | 28234  |
| Taiwan         | 28084  |
+----------------+--------+

Credits and References

About LCK#143 ruby
Project Source on GitHub Return to the Project Catalog

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.

LittleArduinoProjects LittleModelArt More on my blog