Sha256: 319ae295642ef42bd716ff9d20805c44bbae71b98dbd30b48b08e89bf4d0fc8b

Contents?: true

Size: 615 Bytes

Versions: 3

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

module Codebreaker
  class Difficulty
    attr_reader :level

    DIFFICULTIES = {
      simple: {
        hints: 2,
        attempts: 15,
        level: 'simple'
      },

      middle: {
        hints: 1,
        attempts: 10,
        level: 'middle'
      },

      hard: {
        hints: 1,
        attempts: 5,
        level: 'hard'
      }
    }.freeze

    def initialize(input)
      @level = DIFFICULTIES[input]
    end

    def self.find(input)
      input_as_key = input.to_sym
      return unless DIFFICULTIES.key?(input_as_key)

      new(input_as_key)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codebreaker_Shkidchenko-1.3.0 lib/app/entities/difficulty.rb
codebreaker_Shkidchenko-0.2.0 lib/app/entities/difficulty.rb
codebreaker_Shkidchenko-0.1.0 lib/app/entities/difficulty.rb