Class: Majo::Formatter::CSV

Inherits:
Object
  • Object
show all
Defined in:
lib/majo/formatter/csv.rb

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ CSV

Returns a new instance of CSV.



6
7
8
# File 'lib/majo/formatter/csv.rb', line 6

def initialize(result)
  @result = result
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
# File 'lib/majo/formatter/csv.rb', line 10

def call
  ::CSV.generate do |csv|
    csv << ['Object class path', 'Class path', 'Method ID', 'Singleton method', 'Path', 'Line', 'Alloc generation', 'Free generation', 'Memsize', "Count"]
    groups.each do |row, count|
      csv << [row.object_class_path, row.class_path, row.method_id, row.singleton?, row.path, row.line, row.alloc_generation, row.free_generation, row.memsize, count]
    end
  end
end

#groupsObject



19
20
21
# File 'lib/majo/formatter/csv.rb', line 19

def groups
  [*@result.allocations, *@result.retained].tally
end