-
-
Save domgetter/7c170a0a210c346241b5 to your computer and use it in GitHub Desktop.
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 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 |
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
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