Skip to content

Instantly share code, notes, and snippets.

@VelizarHristov
Created January 9, 2016 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save VelizarHristov/6a0a8bacabf68569e210 to your computer and use it in GitHub Desktop.
Save VelizarHristov/6a0a8bacabf68569e210 to your computer and use it in GitHub Desktop.
def state
if not collected?
'booked'
elsif not ironed?
'collected'
elsif not delivered?
'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
STATES[[collected?, ironed?, delivered?].take_while(&:itself).size]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment