Created
August 24, 2013 04:43
-
-
Save CameronCarroll/6326110 to your computer and use it in GitHub Desktop.
for Day.rb, a reference to valid day strings
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
def parse_day_argument(day) | |
case day | |
when 'su', 'sun', 'sunday', '0' | |
return :sunday | |
when 'm', 'mo', 'mon', 'monday', '1' | |
return :monday | |
when 'tu', 'tue', 'tues', 'tuesday', '2' | |
return :tuesday | |
when 'w', 'we', 'wed', 'wednesday', '3' | |
return :wednesday | |
when 'th', 'thu', 'thur', 'thurs', 'thursday', '4' | |
return :thursday | |
when 'f', 'fr', 'fri', 'friday', '5' | |
return :friday | |
when 'sa', 'sat', 'satu', 'satur', 'saturday', '6' | |
return :saturday | |
else | |
raise ArgumentError, 'Could not parse day argument! Check your day glyphs.' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment