Class: ValidData::Printer
- Inherits:
-
Object
- Object
- ValidData::Printer
- Defined in:
- lib/valid_data/printer.rb
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(padding) ⇒ Printer
constructor
TODO: Auto-scale padding as a function of the longest name being printed.
- #print(result) ⇒ Object
Constructor Details
#initialize(padding) ⇒ Printer
TODO: Auto-scale padding as a function of the longest name being printed.
4 5 6 7 |
# File 'lib/valid_data/printer.rb', line 4 def initialize(padding) @padding = padding puts header end |
Instance Method Details
#header ⇒ Object
13 14 15 16 |
# File 'lib/valid_data/printer.rb', line 13 def header "%s | %s | %s" % ["Model", "Invalid", "Total"].map{ |title| title.ljust(padding) } + "\n" + "-" * 3 * padding end |
#print(result) ⇒ Object
9 10 11 |
# File 'lib/valid_data/printer.rb', line 9 def print(result) "%s | %s | %s" % [result.name, result.invalid_count, result.total].map{ |cell| cell.to_s.ljust(padding) } end |