Module: CodebreakerAp::Validation
- Included in:
- Validator
- Defined in:
- lib/codebreaker_ap/modules/validation.rb
Instance Method Summary collapse
- #check_chars_range(value, range) ⇒ Object
- #check_difficulty(difficulty_name, all_difficulty_names) ⇒ Object
- #check_length(value, length) ⇒ Object
Instance Method Details
#check_chars_range(value, range) ⇒ Object
7 8 9 |
# File 'lib/codebreaker_ap/modules/validation.rb', line 7 def check_chars_range(value, range) raise WrongNumbersError unless value.chars.all? { |number| range.include? number.to_i } end |
#check_difficulty(difficulty_name, all_difficulty_names) ⇒ Object
11 12 13 |
# File 'lib/codebreaker_ap/modules/validation.rb', line 11 def check_difficulty(difficulty_name, all_difficulty_names) raise WrongDifficultyError unless all_difficulty_names.include?(difficulty_name) end |
#check_length(value, length) ⇒ Object
3 4 5 |
# File 'lib/codebreaker_ap/modules/validation.rb', line 3 def check_length(value, length) raise WrongLengthError unless length.include? value.length end |