Class: RubyPgExtras::IndexInfoPrint

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_pg_extras/index_info_print.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(data) ⇒ Object



7
8
9
# File 'lib/ruby_pg_extras/index_info_print.rb', line 7

def self.call(data)
  new.call(data)
end

Instance Method Details

#call(data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ruby_pg_extras/index_info_print.rb', line 11

def call(data)
  rows = data.map do |el|
    [
      el.fetch(:index_name),
      el.fetch(:table_name),
      el.fetch(:columns).join(', '),
      el.fetch(:index_size),
      el.fetch(:index_scans),
      el.fetch(:null_frac)
    ]
  end

  puts Terminal::Table.new(
    headings: [
      "Index name",
      "Table name",
      "Columns",
      "Index size",
      "Index scans",
      "Null frac"
    ],
    title: title,
    rows: rows
  )
end