Skip to content

Instantly share code, notes, and snippets.

@copiousfreetime
Created September 22, 2018 17:09
Show Gist options
  • Save copiousfreetime/3d58329eb1910c851b72db5c84638527 to your computer and use it in GitHub Desktop.
Save copiousfreetime/3d58329eb1910c851b72db5c84638527 to your computer and use it in GitHub Desktop.
Using ruby case statement
case [beacon_event.data.event, open_visits.any?]
when [BeaconEvent::ENTERED, true]
# beacon sent another entered event and the visit is already registered
when [BeaconEvent::ENTERED, false]
# beacon sent entered event and the visit hasn't been registered
when [BeaconEvent::EXITED, true]
# beacon sent an exited event and the visit is registered
when [BeaconEvent::EXITED, false]
# beacon sent an exited event and the visit is not registered
else
# WTF!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment