Sha256: f250ebabc55d5342c91d8fd048ceda38f83fa9ad8010ec6e23e7e368b9b68ab2
Contents?: true
Size: 611 Bytes
Versions: 2
Compression:
Stored size: 611 Bytes
Contents
module Validation class Guess def self.validation(input_value:) return if input_value.scan(/\D/).empty? && size_check(input_value) && number_in_range?(input_value) raise ArgumentError, 'Guess - number, required, length - 4 digits, each digit is a number in the range 1-6' end def self.size_check(input_value) input_value.size == Game::CodeMaker::CODE_DIGITS_COUNT end def self.number_in_range?(input_value, range = (Game::CodeMaker::CODE_VALUE_MIN..Game::CodeMaker::CODE_VALUE_MAX)) input_value.to_i.digits.all? { |digit| range.cover?(digit) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_kosinskiy-0.1.2 | lib/codebreaker/validation/guess.rb |
codebreaker_kosinskiy-0.1.0 | lib/codebreaker/validation/guess.rb |