Class: Mongrel::UploadProgress

### Home Classes Methods

### In Files

- lib/mongrel_upload_progress/init.rb

### Parent

Object

### Methods

- ::new
- #add
- #check
- #finish
- #last_checked
- #list
- #mark
- #update_checked_time

### Class/Module Index

Quicksearch

- Mongrel
- Mongrel::UploadProgress
- Upload

No matching classes.

# Mongrel::UploadProgress

Keeps track of the status of all currently processing uploads

### Attributes

debug[RW]

### Public Class Methods

new() click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 50
    def initialize
      @guard    = Mutex.new
      @counters = {}
    end

### Public Instance Methods

add(upid, size) click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 67
    def add(upid, size)
      @guard.synchronize do
        @counters[upid] = [Time.now, {:size => size, :received => 0}]
        puts "#{upid}: Added" if @debug
      end
    end

check(upid) click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 55
    def check(upid)
      @counters[upid].last rescue nil
    end

finish(upid) click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 80
    def finish(upid)
      @guard.synchronize do
        puts "#{upid}: Finished" if @debug
        @counters.delete(upid)
      end
    end

last_checked(upid) click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 59
    def last_checked(upid)
      @counters[upid].first rescue nil
    end

list() click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 87
    def list
      @counters.keys.sort
    end

mark(upid, len) click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 74
    def mark(upid, len)
      return unless status = check(upid)
      puts "#{upid}: Marking" if @debug
      @guard.synchronize { status[:received] = status[:size] - len }
    end

update_checked_time(upid) click to toggle source

    # File lib/mongrel_upload_progress/init.rb, line 63
    def update_checked_time(upid)
      @guard.synchronize { @counters[upid][0] = Time.now }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.