Sha256: dbbaa4ce3f57eb8156a7171d9a99468af667760c16dc2fa7ff20d59ec6688278

Contents?: true

Size: 469 Bytes

Versions: 4

Compression:

Stored size: 469 Bytes

Contents

# frozen_string_literal: true

module Codebreaker
  class Statistics
    class << self
      def save(stats, path)
        stats[:date] = Time.now
        YamlMapper.save(stats, path)
      end

      def output(path)
        array_stats = load(path)
        array_stats.sort_by! { |stats| [stats[:attempts_used], stats[:hints_used]] }.reverse
        array_stats
      end

      private

      def load(path)
        YamlMapper.load(path)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codebreaker_rg_game-1.11 lib/codebreaker/utils/statistics.rb
codebreaker_rg_game-1.10 lib/codebreaker/utils/statistics.rb
codebreaker_rg_game-1.9 lib/codebreaker/utils/statistics.rb
codebreaker_rg_game-1.8 lib/codebreaker/utils/statistics.rb