Skip to content

Instantly share code, notes, and snippets.

@adelevie
Created July 10, 2013 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adelevie/5963273 to your computer and use it in GitHub Desktop.
Save adelevie/5963273 to your computer and use it in GitHub Desktop.
class ListFilings < PM::TableScreen
title "Docket No. 13-5"
def format_cell_title(item)
item["type_of_filing"].downcase.capitalize + " of " + item["name_of_filer"]
end
def on_load
url = "http://ruby-sample.initwithcode.com/promotion/dockets/13-5.json"
@request = BW::HTTP.get(url) do |response|
if response.ok?
json = BW::JSON.parse(response.body.to_str)
@json_table_data = [{
cells: json.map do |item|
{
title: item["title"],
subtitle: item["subtitle"],
action: :tapped_item,
arguments: { item: item },
cell_style: UITableViewCellStyleSubtitle
}
end
}]
update_table_data
elsif response.status_code.to_s =~ /40\d/
App.alert("Error")
else
App.alert(response.error_message)
end
end
end
def table_data
@json_table_data ||= []
end
def tapped_item(args={})
#open ViewFiling.new(nav_bar: true, filing: args[:item])
PM.logger.info args[:item] # => { name: "whatever", property: "prop" }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment