class BitlyExporter::Exporter
Constants
- LIMIT
- NO_MAX
Attributes
user[R]
Public Class Methods
new(user)
click to toggle source
# File lib/bitly_exporter/exporter.rb, line 7 def initialize(user) @user = user end
Public Instance Methods
export(progress=false, max=NO_MAX) { |link| ... }
click to toggle source
# File lib/bitly_exporter/exporter.rb, line 11 def export(progress=false, max=NO_MAX) results = [] offset = 0 begin links, result_count = user.link_history(limit: LIMIT, offset: offset) links.each do |link| results << link yield link if block_given? end offset = offset + LIMIT sleep(0.5) # Let's not bull rush the API print "\r#{offset} links retrieved..." if progress end while links.count > 0 && offset < max puts "\nFinished. #{results.count} links retrieved." if progress results end