Sha256: 5b3ca925a7f83f8ce36b2e8b80540d8c6d67bfb22c5807e24c4a876c40a07b60
Contents?: true
Size: 899 Bytes
Versions: 1
Compression:
Stored size: 899 Bytes
Contents
# frozen_string_literal: true require_relative 'bootstrap' module Codebreaker class User < BaseEntity attr_reader :name, :difficulty, :used_attempts, :used_hints NAME_MIN_LENGTH = 3 NAME_MAX_LENGTH = 20 def initialize(name, difficulty) @name = name @difficulty = difficulty @used_attempts = 0 @used_hints = 0 super end def hints? difficulty.hints = used_hints end def attempts? difficulty.attempts = used_attempts end def hint @used_hints += 1 end def attempt @used_attempts += 1 end private def validate raise Errors::ClassValidError unless valid_class?(String, name) raise Errors::MinLengthError unless valid_string_min_length?(name, NAME_MIN_LENGTH) raise Errors::MaxLengthError unless valid_string_max_length?(name, NAME_MAX_LENGTH) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_manfly-0.1.2 | lib/codebreaker/user.rb |