Sha256: 38d9c5fafb8a7f75e23ac44c7e98f561a93aac56770a803de16eb5d3af731a2a

Contents?: true

Size: 480 Bytes

Versions: 4

Compression:

Stored size: 480 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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
andrii_codebreaker-0.1.14 lib/andrii_codebreaker/difficulty.rb
andrii_codebreaker-0.1.13 lib/andrii_codebreaker/difficulty.rb
andrii_codebreaker-0.1.12 lib/andrii_codebreaker/difficulty.rb
andrii_codebreaker-0.1.11 lib/andrii_codebreaker/difficulty.rb