Class: McDump::Report
- Inherits:
-
Object
- Object
- McDump::Report
- Defined in:
- lib/mc_dump/report.rb
Instance Method Summary collapse
- #dump(io = $stdout) ⇒ Object
-
#initialize(items) ⇒ Report
constructor
A new instance of Report.
Constructor Details
#initialize(items) ⇒ Report
Returns a new instance of Report.
5 6 7 |
# File 'lib/mc_dump/report.rb', line 5 def initialize(items) @items = items end |
Instance Method Details
#dump(io = $stdout) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/mc_dump/report.rb', line 9 def dump(io=$stdout) = column_names = .keys line_format = "|#{column_names.map { |name| " %#{[name]}s " }.join("|")}|" io.puts line_format % column_names @items.each { |item| io.puts line_format % item.to_h.values_at(*column_names) } end |