Sha256: 44e9b3d2557ae95ae5e2379e407398d1b9dc17bd7090ab35e1327a68a8245c26

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

module Codebreaker
  class Statistics
    include Database

    def winners(base)
      data = multi_sort(base)
      to_table(data)
    end

    private

    def to_table(data)
      rows = []
      data.map do |i|
        row = []
        row << i.name
        row << i.difficulty
        row << i.attempts_total
        row << i.attempts_left
        row << i.hints_total
        row << i.have_hints
        row << i.date
        rows << row
      end
      rows
    end

    def multi_sort(items)
      items.sort_by { |player| [player.difficulty, player.attempts_used, player.hints_used] }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codebreaker_PI-0.6.5 lib/entities/statistics.rb