Module: Storage

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

Constant Summary collapse

STORAGE_FILE =
File.expand_path('storage.yml')

Instance Method Summary collapse

Instance Method Details

#show_statisticsObject



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

def show_statistics
  tp(statistics_with_raiting).class
end

#statistics_with_raitingObject



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

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

#store_gameObject



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

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