Module: Checker
- Included in:
- Calcpace
- Defined in:
- lib/calcpace/checker.rb
Overview
Module to check if the input is valid or of the correct type
Instance Method Summary collapse
Instance Method Details
#check_positive(number) ⇒ Object
5 6 7 |
# File 'lib/calcpace/checker.rb', line 5 def check_positive(number) raise ArgumentError, 'It must be a positive number' unless number.is_a?(Numeric) && number.positive? end |
#check_time(time_string) ⇒ Object
9 10 11 |
# File 'lib/calcpace/checker.rb', line 9 def check_time(time_string) raise ArgumentError, 'It must be a valid time in the format XX:XX:XX' unless time_string =~ /^\d{1,2}:\d{2}:\d{2}$/ end |