module Pry::Helpers

Public Class Methods

tablify(things, line_length) click to toggle source
# File lib/pry/helpers/table.rb, line 23
def self.tablify(things, line_length)
  table = Table.new(things, :column_count => things.size)
  table.column_count -= 1 until 1 == table.column_count or
    table.fits_on_line?(line_length)
  table
end
tablify_or_one_line(heading, things) click to toggle source
# File lib/pry/helpers/table.rb, line 3
def self.tablify_or_one_line(heading, things)
  plain_heading = Pry::Helpers::Text.strip_color(heading)
  attempt = Table.new(things, :column_count => things.size)
  if attempt.fits_on_line?(Terminal.width! - plain_heading.size - 2)
    "#{heading}: #{attempt}\n"
  else
    "#{heading}: \n#{tablify_to_screen_width(things, :indent => '  ')}\n"
  end
end
tablify_to_screen_width(things, options = {}) click to toggle source
# File lib/pry/helpers/table.rb, line 13
def self.tablify_to_screen_width(things, options = {})
  things = things.compact
  if indent = options[:indent]
    usable_width = Terminal.width! - indent.size
    tablify(things, usable_width).to_s.gsub(/^/, indent)
  else
    tablify(things, Terminal.width!).to_s
  end
end