Class: Codebreakergem::InformationPresenter
- Inherits:
-
Object
- Object
- Codebreakergem::InformationPresenter
- Defined in:
- lib/classes/information_presenter.rb
Class Method Summary collapse
Class Method Details
.rules ⇒ Object
6 7 8 |
# File 'lib/classes/information_presenter.rb', line 6 def rules I18n.t(:rules) end |
.stats ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/classes/information_presenter.rb', line 10 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 |
.stats_as_hash ⇒ Object
24 25 26 27 28 29 |
# File 'lib/classes/information_presenter.rb', line 24 def stats_as_hash stats = FileWorker.read_from_file(Game::FILE) return stats.sort_by { |item| [item[:order], item[:attempts_used], item[:hints_used]] } if stats.is_a? Array [stats].compact end |