Sha256: 83c1b9be4e3225aae8e2e8b3926896a662473f44cd8ca8f20750c76e4cf39cd9

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 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

3 entries across 3 versions & 1 rubygems

Version Path
purple_shoes-0.0.126 lib/shoes/download.rb
purple_shoes-0.0.115 lib/shoes/download.rb
purple_shoes-0.0.101 lib/shoes/download.rb