Class: McDump::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/mc_dump/report.rb

Instance Method Summary collapse

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