lib/codeguessing/game.rb in codeguessing-0.3.0 vs lib/codeguessing/game.rb in codeguessing-0.3.1

- old
+ new

@@ -1,18 +1,18 @@ module Codeguessing class Game - attr_reader :result, :attempts, :hint_count, :state + attr_reader :attempts, :hint_count, :state attr_accessor :secret_code MAX_HINT = 2 MAX_ATTEMPTS = 5 def initialize(opt = {}) @secret_code = opt[:secret_code] || random @attempts = opt[:attempts] || MAX_ATTEMPTS @hint_count = opt[:hint_count] || MAX_HINT - @state = '' + @state = opt[:state] || '' end def guess(code) loose unless check?(use_attempt) res = '' @@ -47,12 +47,9 @@ hash[:name] = name self.instance_variables.each do |k, v| new_k = k.to_s.gsub('@','').to_sym hash[new_k] = self.instance_variable_get(k) end - hash.delete(:scores) - hash.delete(:result) - hash.delete(:state) hash end def valid?(code) return true if code =~ /^[1-6]{4}$/s