Parent

RText::DefaultLoader::ProgressMonitor

Public Class Methods

new(on_progress_proc, files) click to toggle source
# File lib/rtext/default_loader.rb, line 94
def initialize(on_progress_proc, files)
  @on_progress_proc = on_progress_proc || lambda {|frag, work_done, work_overall| }
  # there is a progress call twice for each element (in tokenizer and instantiator)
  @work_overall = num_elements(files)*2
  @work_done = 0
  @work_last_sent = 0
end

Public Instance Methods

after_fragment_load(frag) click to toggle source
# File lib/rtext/default_loader.rb, line 106
def after_fragment_load(frag)
  @work_done += frag.elements.size*2 if @loading_cached
  @on_progress_proc.call(frag, @work_done, @work_overall)
  @work_last_sent = @work_done
end
before_fragment_load(frag, kind) click to toggle source
# File lib/rtext/default_loader.rb, line 102
def before_fragment_load(frag, kind)
  @loading_cached = (kind == :load_cached)
end
instantiator_progress(frag) click to toggle source
# File lib/rtext/default_loader.rb, line 112
def instantiator_progress(frag)
  @work_done += 1
  if @work_done > @work_last_sent + 100
    @on_progress_proc.call(frag, @work_done, @work_overall)
    @work_last_sent = @work_done
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.