Sha256: 836bc2187119bccfe6861729513f1696b8688d21a99e493b7e7dd259dc34516c

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

module Output
  include CommandLineReporter

  def show_welcome
    show_msg(:Welcome)
  end

  def show_main_menu
    show_msg(:MainMenu)
  end

  def show_rules
    show_msg(:Rules)
  end

  def show_stats(sorted_stats = Statistic.sort_stats)
    table(border: true) do
      generate_table_titles
      generate_table_values(sorted_stats)
    end
  end

  def generate_table_titles
    row do
      column('Player name', width: 20)
      column('Difficulty', width: 10)
      column('Attempts total', width: 14)
      column('Attempts used', width: 13)
      column('Hints total', width: 11)
      column('Hints used', width: 11)
    end
  end

  def generate_table_values(sorted_stats)
    sorted_stats.each do |player|
      row do
        column(player[:name])
        column(player[:difficulty])
        column(player[:attempts_total])
        column(player[:attempts_used])
        column(player[:hints_total])
        column(player[:hints_used])
      end
    end
  end

  def show_msg(type)
    puts I18n.t(type)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
codebreaker_paratskiy-0.2.2 lib/modules/output.rb
codebreaker_paratskiy-0.2.1 lib/modules/output.rb
codebreaker_paratskiy-0.2.0 lib/modules/output.rb
codebreaker_paratskiy-0.1.9 lib/modules/output.rb
codebreaker_paratskiy-0.1.8 lib/modules/output.rb
codebreaker_paratskiy-0.1.7 lib/modules/output.rb
codebreaker_paratskiy-0.1.6 lib/modules/output.rb
codebreaker_paratskiy-0.1.5 lib/modules/output.rb
codebreaker_paratskiy-0.1.3 lib/modules/output.rb