Sha256: 2390be032f87a2a3a175f2a8e5d7926851fd3cfd262b94fa42a3306ddb6e6729

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'terminal-table'

module Kernel
  
  ##
  # Generates a Terminal::Table object.
  #
  # === Examples:
  #    
  #    puts table(['a', 'b'], [[1, 2], [3, 4]])
  #    
  #    # OR
  #
  #    t = table ['a', 'b']
  #    t << [1, 2]
  #    t << [3, 4]
  #    puts t
  #    
  #    # OR
  #
  #    user_table = table do |t|
  #      t.headings = 'First Name', 'Last Name', 'Email'
  #      t << ['TJ',  'Holowaychuk', 'tj@vision-media.ca']
  #      t << ['Bob', 'Someone',     'bob@vision-media.ca']
  #      t << ['Joe', 'Whatever',    'joe@vision-media.ca']
  #    end
  #    puts user_table
  #    
  #    # OR
  #
  #    user_table = table do
  #      self.headings = 'First Name', 'Last Name', 'Email'
  #      add_row ['TJ',  'Holowaychuk', 'tj@vision-media.ca']
  #      add_row ['Bob', 'Someone',     'bob@vision-media.ca']
  #      add_row ['Joe', 'Whatever',    'joe@vision-media.ca']
  #    end
  #    puts user_table
  #
  #   # OR
  #
  #   rows = []
  #   rows << ['Lines',      100]
  #   rows << ['Comments',   20]
  #   rows << ['Ruby',       70]
  #   rows << ['JavaScript', 30]
  #   puts table(nil, rows)
  #
  
  def table headings = [], rows = [], &block
    table = Terminal::Table.new :headings => headings, :rows => rows, &block
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
visionmedia-terminal-table-1.0.4 lib/terminal-table/import.rb