Class: Vivlio::Starter::CLI::TablePrinter
- Inherits:
-
Object
- Object
- Vivlio::Starter::CLI::TablePrinter
- Defined in:
- lib/vivlio/starter/cli/metrics.rb
Overview
統計情報を表形式で出力する
Constant Summary collapse
- HEADER_FORMAT =
[ '%-40s', '%10s', '%12s', '%18s', '%12s', '%9s', '%9s', '%10s', '%11s' ].join(' ').freeze
- ROW_FORMAT =
[ '%<path>-40s', '%<lines>10d', '%<chars>12d', '%<no_crlf>18d', '%<sentences>12d', '%<avg_sentence>9.2f', '%<commas>9d', '%<clauses>10d', '%<avg_clause>11.2f' ].join(' ').freeze
- HEADER_LABELS =
{ path: 'path', lines: 'lines', chars: 'chars', no_crlf: 'chars(no CR/LF)', sentences: 'sentences', avg_sentence: 'avg sent', commas: 'commas', clauses: 'clauses', avg_clause: 'avg clause' }.freeze
Instance Method Summary collapse
-
#initialize(stats) ⇒ TablePrinter
constructor
表示対象の統計情報を保持する.
-
#print ⇒ Object
ヘッダーと各行・合計を順に出力する.
Constructor Details
#initialize(stats) ⇒ TablePrinter
表示対象の統計情報を保持する
356 357 358 359 360 |
# File 'lib/vivlio/starter/cli/metrics.rb', line 356 def initialize(stats) @stats = stats @header = build_header @divider = '-' * @header.length end |
Instance Method Details
#print ⇒ Object
ヘッダーと各行・合計を順に出力する
363 364 365 366 367 368 |
# File 'lib/vivlio/starter/cli/metrics.rb', line 363 def print puts header puts divider stats.each { |stat| puts row(stat['path'], stat) } print_totals end |