Module: Codebreaker::Storage

Included in:
Game
Defined in:
lib/modules/storage.rb

Constant Summary collapse

STORAGE_FILE =
'storage.yml'

Instance Method Summary collapse

Instance Method Details

#show_statisticsObject



21
22
23
# File 'lib/modules/storage.rb', line 21

def show_statistics
  tp(statistics_with_raiting).class
end

#statistics_with_raitingObject



13
14
15
16
17
18
19
# File 'lib/modules/storage.rb', line 13

def statistics_with_raiting
  raiting = 0
  sort_data_for_statistics.map do |row|
    raiting += 1
    Hash[:raiting, raiting].merge!(row)
  end
end

#store_gameObject



7
8
9
10
11
# File 'lib/modules/storage.rb', line 7

def store_game
  saved_games = load_games_history
  saved_games << self
  File.write(STORAGE_FILE, saved_games.to_yaml)
end