Sha256: 20302d970a6f00c299c198894ba5ff1699bdaf367ea7569bfd7ff10442e725c5

Contents?: true

Size: 317 Bytes

Versions: 9

Compression:

Stored size: 317 Bytes

Contents

module Codebreaker
  class SecretCodeGenerator
    LENGTH = 4
    RANGE = (1..6).freeze
    VALID_REGEXP = /^[#{RANGE.min}-#{RANGE.max}]{#{LENGTH}}$/.freeze

    def self.string_valid?(secret_code)
      VALID_REGEXP.match?(secret_code)
    end

    def call
      Array.new(LENGTH) { rand(RANGE) }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cb-core-0.1.10 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.9 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.8 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.7 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.6 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.4 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.3 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.2 lib/codebreaker/secret_code_generator.rb
cb-core-0.1.1 lib/codebreaker/secret_code_generator.rb