Skip to content

Instantly share code, notes, and snippets.

@andrewhavens
Created August 6, 2016 07:37
Show Gist options
  • Save andrewhavens/ca21f9bf6d177630e41c3d7a3a1a4b5a to your computer and use it in GitHub Desktop.
Save andrewhavens/ca21f9bf6d177630e41c3d7a3a1a4b5a to your computer and use it in GitHub Desktop.
class ListEventsScreen < PM::TableScreen
title "Upcoming Events"
def on_load
@events = []
load_events
end
def load_events
AFMotion::JSON.get("http://calagator.org/events.json") do |response|
if response.success?
@events = response.object
update_table_data
else
app.alert "Sorry, there was an error while trying to load the events."
end
end
end
def table_data
[{
cells: @events.map do |event|
{ title: event["title"] }
end
}]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment