Module: CodebreakerSmn::ValidationHelper

Included in:
Game
Defined in:
lib/codebreaker_smn/helpers/validation_helper.rb

Instance Method Summary collapse

Instance Method Details

#not_empty_string(input) ⇒ Object



6
7
8
# File 'lib/codebreaker_smn/helpers/validation_helper.rb', line 6

def not_empty_string(input)
  (input.is_a? String) && !input.empty?
end

#positive_integer(input) ⇒ Object



18
19
20
# File 'lib/codebreaker_smn/helpers/validation_helper.rb', line 18

def positive_integer(input)
  (input.is_a? Integer) && input.positive?
end

#positive_integers(input) ⇒ Object



14
15
16
# File 'lib/codebreaker_smn/helpers/validation_helper.rb', line 14

def positive_integers(input)
  input.all? { |char| positive_integer(char) }
end

#valid_digit(digit, range) ⇒ Object



26
27
28
# File 'lib/codebreaker_smn/helpers/validation_helper.rb', line 26

def valid_digit(digit, range)
  range.include?(digit)
end

#valid_digits(input, range) ⇒ Object



22
23
24
# File 'lib/codebreaker_smn/helpers/validation_helper.rb', line 22

def valid_digits(input, range)
  input.all? { |digit| valid_digit(digit, range) }
end

#valid_length(input:, from:, to:) ⇒ Object



10
11
12
# File 'lib/codebreaker_smn/helpers/validation_helper.rb', line 10

def valid_length(input:, from:, to:)
  input.size.between?(from, to)
end