Sha256: 8fba0c143e23117c20d8570107ee58248cb86b0857dc137df66d25c573abc999

Contents?: true

Size: 611 Bytes

Versions: 41

Compression:

Stored size: 611 Bytes

Contents

class Shoes
  class Download
    def initialize name, args, &blk
      require 'open-uri'
      Thread.new do
        open name,
          content_length_proc: lambda{|len| @content_length, @started = len, true},
          progress_proc: lambda{|size| @progress = size} do |sio|
          open(args[:save], 'wb'){|fw| fw.print sio.read} if args[:save]
          blk[sio] if blk
          @finished = true
        end
      end
    end
    
    attr_reader :progress, :content_length
    
    def started?
      @started
    end
    
    def finished?
      @finished
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
green_shoes-1.1.374 lib/shoes/download.rb
green_shoes-1.1.373 lib/shoes/download.rb
green_shoes-1.1.367 lib/shoes/download.rb
green_shoes-1.1.366 lib/shoes/download.rb
green_shoes-1.1.365 lib/shoes/download.rb
green_shoes-1.1.364 lib/shoes/download.rb
green_shoes-1.1.363 lib/shoes/download.rb
green_shoes-1.1.362 lib/shoes/download.rb
green_shoes-1.1.358 lib/shoes/download.rb
green_shoes-1.1.357 lib/shoes/download.rb
green_shoes-1.1.354 lib/shoes/download.rb
green_shoes-1.1.348 lib/shoes/download.rb
green_shoes-1.0.337 lib/shoes/download.rb
green_shoes-1.0.331 lib/shoes/download.rb
green_shoes-1.0.322 lib/shoes/download.rb
green_shoes-1.0.320 lib/shoes/download.rb
green_shoes-1.0.309 lib/shoes/download.rb
green_shoes-1.0.303 lib/shoes/download.rb
green_shoes-1.0.282 lib/shoes/download.rb
green_shoes-1.0.273 lib/shoes/download.rb