Created
June 29, 2014 13:03
-
-
Save ascendbruce/f962c82b391f8a4cfe4a to your computer and use it in GitHub Desktop.
code club #4 候選題目
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Timer | |
def times(env) | |
value_s = env['interval'] | |
if value_s == nil | |
raise "interval missing" | |
end | |
value = Integer(value_s) | |
if value <= 0 | |
raise "interval should be > 0" | |
end | |
check_interval = value | |
value_s = env['duration'] | |
raise "duration missing" if value_s.nil? | |
value = Integer(value_s) | |
if value <= 0 | |
raise "duration should be > 0" | |
end | |
if (value % check_interval) != 0 | |
raise "duration should be multiple of interval" | |
end | |
monitor_time = value | |
value_s = env['departure'] | |
if value_s.nil? | |
raise "departure missing" | |
end | |
value = Integer(value_s) | |
raise "departure should be > 0" if value <= 0 | |
if (value % check_interval) != 0 | |
raise "departure should be multiple of interval" | |
end | |
departure_offset = value | |
[check_interval, monitor_time, departure_offset] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment