Class: Codebreaker::Statistics
- Inherits:
-
Object
- Object
- Codebreaker::Statistics
- Defined in:
- lib/codebreaker/statistics.rb
Constant Summary collapse
- DEFAULT_PATH_TO_FILE =
"./lib/codebreaker/data/stat.yml".freeze
Instance Method Summary collapse
-
#initialize(path_to_file = DEFAULT_PATH_TO_FILE) ⇒ Statistics
constructor
A new instance of Statistics.
- #stats ⇒ Object
Constructor Details
#initialize(path_to_file = DEFAULT_PATH_TO_FILE) ⇒ Statistics
5 6 7 |
# File 'lib/codebreaker/statistics.rb', line 5 def initialize(path_to_file = DEFAULT_PATH_TO_FILE) @storage = StorageInterceptor.new(path_to_file) end |
Instance Method Details
#stats ⇒ Object
9 10 11 12 13 14 |
# File 'lib/codebreaker/statistics.rb', line 9 def stats return unless codebreaker_data = @storage.read_database codebreaker_data.sort_by! { |stat| [stat[:level_num], stat[:hints], stat[:attempts]] } codebreaker_data.each { |stat| stat.delete_if { |key, _value| key == :level_num } } end |