Skip to content

Instantly share code, notes, and snippets.

@jamonholmgren
Forked from adelevie/table.rb
Last active December 19, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamonholmgren/5963282 to your computer and use it in GitHub Desktop.
Save jamonholmgren/5963282 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 cell_whitelist
[ :title, :subtitle ]
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|
item.keep_if{|k,v| cell_whitelist.include?(k.to_sym)}.merge({
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