Method: CampfireExport::Room#export

Defined in:
lib/campfire_export.rb

#export(start_date = nil, end_date = nil) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/campfire_export.rb', line 168

def export(start_date=nil, end_date=nil)
  # Figure out how to do the least amount of work while still conforming
  # to the requester's boundary dates.
  find_last_update
  start_date.nil? ? date = created_at      : date = [start_date, created_at].max
  end_date.nil?   ? end_date = last_update : end_date = [end_date, last_update].min
  
  while date <= end_date
    transcript = Transcript.new(self, date)
    transcript.export

    # Ensure that we stay well below the 37signals API limits.
    sleep(1.0/10.0)
    date = date.next
  end
end