Sha256: cb6ab0c098a0beb5e77430764c8f947b28b0d412a1567b3184d5c97b65685fee
Contents?: true
Size: 1010 Bytes
Versions: 1
Compression:
Stored size: 1010 Bytes
Contents
module Mastermind class Player include Helper attr_reader :record, :name, :guesses, :time_taken, :date_played # attr_accessor :name, :trials, :time_taken, :date_played def initialize(response: nil, player: nil) @response = response || Message.new set_attr player if player end def set_attr(input) @name = input[:name] if input[:name] @guesses = input[:guesses] if input[:guesses] @time_taken = input[:time_taken] if input[:time_taken] @date_played = input[:date_played] if input[:date_played] end def winner_response @response.winner(@name, @guesses, time).message end def time if @time_taken mins = @time_taken/60 secs = @time_taken%60 "#{mins}m#{secs}s" end end def to_h player = Hash.new(nil) player[:name] = @name player[:guesses] = @guesses player[:time_taken] = @time_taken player[:date_played] = @date_played player end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
master_mind-0.1.2 | lib/mastermind/player.rb |