Top Level Namespace

Defined Under Namespace

Modules: Apalo Classes: String

Instance Method Summary collapse

Instance Method Details

#find_top10(hash) ⇒ Object



1
2
3
4
5
6
7
8
9
# File 'lib/apalo/cli/commands/basic.rb', line 1

def find_top10(hash)
  if hash.values.size > 10
    top10 = hash.values.sort[-10..-1]
  else
    top10 = hash.values.sort
  end
  return \
    hash.find_all { |key,val| top10.include?(val) }.sort{ |a,b| a[1] <=> b[1] }
end

#render_top10(hash, title) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/apalo/cli/commands/vhosts_overview.rb', line 1

def render_top10(hash, title)
  puts title
  puts 
  if hash.values.size > 10
    top10 = hash.values.sort[-10..-1]
  else
    top10 = hash.values.sort
  end
  hash.find_all { |key,val| top10.include?(val) }.sort{ |a,b| a[1] <=> b[1] }.each do |key,val|
    puts "#{val}: ".ljust(10, " ") + "#{key}" if val != 0
  end
  puts
end