Module: Songkicky::JsonApi
Instance Method Summary collapse
Instance Method Details
#all(path, thing) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/json_api.rb', line 8 def all(path, thing) things = [] per_page = total = nil page = 0 while !per_page || (page*per_page) < total json_page = json_data_from(append_to_path(path, "page=#{page+1}"))["resultsPage"] page = json_page["page"] per_page = json_page["perPage"] total = json_page["totalEntries"] next unless json_page["results"][thing] things += json_page["results"][thing] end things end |