Skip to content

Instantly share code, notes, and snippets.

@domgetter
Forked from VelizarHristov/before.rb
Last active January 9, 2016 16:57
Show Gist options
  • Save domgetter/7c170a0a210c346241b5 to your computer and use it in GitHub Desktop.
Save domgetter/7c170a0a210c346241b5 to your computer and use it in GitHub Desktop.
def state
case
when !collected? then 'booked'
when !ironed? then 'collected'
when !delivered? then 'ironed'
else 'delivered'
end
end
# ironed? might raise an exception if collected? is false
# delivered? might raise an exception if ironed? is false
STATES = ['booked', 'collected', 'ironed', 'delivered']
def state
begin
STATES[[collected?, ironed?, delivered?].take_while(&:itself).size]
rescue
# do exception handling here
end
# of course, by here you still don't know what state you're in
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment