Module: PrintUtils

Included in:
NbaRoster, NbaSchedule, NbaTeamList
Defined in:
lib/hoopscrape/PrintUtils.rb

Overview

Print Utilities

Instance Method Summary collapse

Instance Method Details

#asTable(args, col_width = 15, title = '', show_idx = true) ⇒ String

Printable tabular String representation of args data

Parameters:

  • args ([[object]])

    Table Data

  • col_width (Integer) (defaults to: 15)

    Column Width

  • title (String) (defaults to: '')

    Table Title

  • show_idx (Bool) (defaults to: true)

    Show Index?

Returns:



9
10
11
12
13
14
15
16
17
18
# File 'lib/hoopscrape/PrintUtils.rb', line 9

def asTable(args, col_width = 15, title = '', show_idx = true)
  result = "\n#{title}"
  idx_width = args.size.to_s.length
  args.each_with_index do |row, idx|
    result << "\n#{idx + 1}." + ' ' * pad(idx_width, idx) + '  ' if show_idx
    result << "\n" unless show_idx
    formatRow(row, col_width, result)
  end
  result << "\n"
end