Skip to content

Instantly share code, notes, and snippets.

@dblock
Created March 31, 2012 14:59
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 dblock/2265877 to your computer and use it in GitHub Desktop.
Save dblock/2265877 to your computer and use it in GitHub Desktop.
An iterator over all Google Analytics results with Garb
module Garb
module Model
def all(profile, options = {}, &block)
limit = options.delete(:limit)
total = 0
while ((rs = results(profile, options)) && rs.any?)
rs.each do |r|
yield r
total += 1
break if limit and total >= limit
end
options[:offset] = total
end
self
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment