Working with Ruby
Hi, I am Jan. This is my old Ruby blog. I still post about Ruby, but I now do it on You should also install Irbtools to improve your IRB.

Small Ruby CLI Improvements (Part 3): Hirb vs. Unicode

Hirb: “A mini view framework for console/irb that’s easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu.” now supports unicode in two ways:

┌───────────────────────────────────────────┬───────────────────────────────────────────────┐ │ Support for unicode full-width characters │ Unicode table characters instead of +/- chars │ └───────────────────────────────────────────┴───────────────────────────────────────────────┘

Nice unicode-drawn tables

You need to upgrade to hirb 0.4.0 to use this new feature: You can pass an :unicode => true option to your tables to get them unicodized. To automatically use it for all your tables, you can put the following statement in your ~/.irbrc:

Hirb::View.formatter.add_view 'Object', :ancestor => true, :options => { :unicode => true }

Irbtools users just need to upgrade to 0.8.6.

Btw, if you don’t like the ╎ gaps, you can customize the used characters with:

Hirb::Helpers::UnicodeTable::CHARS[:bottom][:vertical][:inside] = '│'

Full-width characters

If you were experiencing wrong table sizes, you can now use hirb-unicode (thanks to miaout17). It patches the original hirb gem with the right unicode-display_width. Unfortunately, it can be slow under some circumstances, but this may be improved with future versions of unicode-display_width.

Creative Commons License