Skip to content

Instantly share code, notes, and snippets.

@CameronCarroll
Created August 24, 2013 04:43
Show Gist options
  • Save CameronCarroll/6326110 to your computer and use it in GitHub Desktop.
Save CameronCarroll/6326110 to your computer and use it in GitHub Desktop.
for Day.rb, a reference to valid day strings
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