Sha256: 85df5288d2152900c992b1c9ef7409ae2349cd4a206632f7a9072ae5af5775af

Contents?: true

Size: 519 Bytes

Versions: 1

Compression:

Stored size: 519 Bytes

Contents

# frozen_string_literal: true

module AndriiCodebreaker
  class Difficulty
    include Constant

    attr_reader :name, :hints, :attempts

    def initialize(name)
      validate_difficulty(name)
      @name = name
      @hints = DIFFICULTY[name.to_sym][:hints]
      @attempts = DIFFICULTY[name.to_sym][:attempts]
    end

    def validate_difficulty(name)
      return DIFFICULTY[name.to_sym] if DIFFICULTY.keys.include? name.to_sym

      raise ArgumentError, I18n.t('game.difficulty_input_error')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
andrii_codebreaker-0.1.10 lib/andrii_codebreaker/difficulty.rb