Method: NuclearPowerReactors#list_all_countries

Defined in:
lib/nuclear_power_reactors.rb

#list_all_countriesObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/nuclear_power_reactors.rb', line 26

def list_all_countries
  column_width = @country_hash.values.max_by {|name| name.length}.length + 4
  columns = 3
  organizer = 1
  @country_hash.each do |key, value|
      name = "(#{key}) #{format_name(value)}"
    if organizer % columns == 0
      puts "#{name}".colorize(:blue)
    else
      (column_width - name.length).times do
        name << " "
      end
      print "#{name}".colorize(:blue)
    end
    organizer += 1
  end
  puts
end