Skip to content

Instantly share code, notes, and snippets.

@baldwindavid
Created September 6, 2009 18:10
Show Gist options
  • Save baldwindavid/181906 to your computer and use it in GitHub Desktop.
Save baldwindavid/181906 to your computer and use it in GitHub Desktop.
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