Sha256: 98e700840c8ec7069ee4432fa8efa844b5933b7c054446d226a98503d7ae5ccf
Contents?: true
Size: 939 Bytes
Versions: 3
Compression:
Stored size: 939 Bytes
Contents
# frozen_string_literal: true module Codebreakergem class InformationPresenter class << self def rules I18n.t(:rules) end def stats result = I18n.t(:stats_header) stats_from_file = FileWorker.read_from_file(Game::FILE) return result unless stats_from_file if stats_from_file.is_a? Array sorted_data = stats_from_file.sort_by { |item| [item[:order], item[:attempts_used], item[:hints_used]] } sorted_data.each_with_index { |item, index| result += stats_constructor(index + 1, item) } else result += stats_constructor(1, stats_from_file) end result end private def stats_constructor(index, item) "#{index}\t #{item[:name]}\t #{item[:difficulty]}\t #{item[:attempts_total]}\t " \ "#{item[:attempts_used]}\t #{item[:hints_total]}\t #{item[:hints_used]}\n" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
codebreakergem-0.1.15 | lib/classes/information_presenter.rb |
codebreakergem-0.1.14 | lib/classes/information_presenter.rb |
codebreakergem-0.1.13 | lib/classes/information_presenter.rb |