Sha256: 265892eca8cd1d14c54cc5229c282ac460f6641b6bb95602b8f6ba2e96b1eadd
Contents?: true
Size: 676 Bytes
Versions: 5
Compression:
Stored size: 676 Bytes
Contents
module AlexCodebreaker class PlayersRating attr_accessor :stats def initialize @stats = [] load_and_sort_stats end private def load_and_sort_stats return unless File.exist?(winners_path) load_stats sort_stats end def load_stats File.open(winners_path) do |file| @stats = Array.new(YAML.load_stream(file)) end end def sort_stats @stats.sort_by! { |value| [-value.difficulty_level, value.attempts_used, value.hints_used] } end def winners_path "#{AlexCodebreaker.configuration.winners_folder_path}#{AlexCodebreaker::Session::WINNERS_FILE_NAME}" end end end
Version data entries
5 entries across 5 versions & 1 rubygems