Class: CheckList::Validations

Inherits:
Object
  • Object
show all
Defined in:
lib/validations.rb

Overview

Checklist Validations

Class Method Summary collapse

Class Method Details

.validate(value, array) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/validations.rb', line 6

def self.validate(value, array)
  return 0 if value == 'q'

  return value.to_i if array && value.to_i < array.length + 1 && !value.to_i.zero?

  return false unless array

  nil
end

.validate_response(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/validations.rb', line 16

def self.validate_response(value)
    case value
    when 'y'
        value
    when 'n'
        value
    when 'na'
        value
    when 'q'
        value
    else
        0
    end
end