Sha256: 7eed0f6fd4f2439e3be54c79e45202f912177f8953e2c1ab6b60388180816001

Contents?: true

Size: 587 Bytes

Versions: 2

Compression:

Stored size: 587 Bytes

Contents

# frozen_string_literal: true

require_relative 'autoload'
require_relative 'settings'

class User
  attr_reader :name, :difficulty, :attempts, :hints

  def initialize(name, difficulty)
    validation(name, difficulty)
    @name = name
    @difficulty = Settings::DIFFICULTY[difficulty]
    @attempts = { all: @difficulty[:attempts], used: 0 }
    @hints = { all: @difficulty[:hints], used: 0 }
  end

  def validation(name, difficulty)
    Validations.validate_name(name)
    Validations.validate_difficulty(difficulty)
  rescue StandardError => e
    puts e.message
    nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codebreaker_kirill-1.0.2 lib/codebreaker_kirill/user.rb
codebreaker_kirill-0.3.1 lib/codebreaker_kirill/user.rb