Created
September 6, 2009 18:10
-
-
Save baldwindavid/181906 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'hirb' | |
module Hirb | |
module Console | |
# Simple shortcut to grab a few columns in irb | |
# Note that you can only use column names | |
# Usage: | |
# tab Article.all, :id, :title, :published_at | |
def tab(output, *fields) | |
max_width = case fields.size | |
when 1 then 120 | |
when 2 then 110 | |
else 90 | |
end | |
options = { | |
:fields => fields, | |
:max_width => max_width | |
} | |
Console.render_output(output, options.merge(:class=>"Hirb::Helpers::AutoTable")) | |
end | |
end | |
end | |
extend Hirb::Console |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment