Sha256: 8c3a39ca146f2a804ffd83c468d14ae375985ce157af4e708acf298867907c90

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

module Thwomp
  # Downloads SWF files
  class Downloader < Struct.new(:swf_url)

    # tests if the given file remote
    def remote?
      swf_url =~ /^http(s)?::/
    end

    # tests if the given file is local
    def local?
      !remote?
    end

    # returns filename of local/remote file
    def filename
      local?? swf_url : tmp_file.path
    end

    private

    def download!
      @download ||= tmp_file.write(response)
    end

    def tmp_file
      @tmp_file ||= Tempfile.new('thwomp')
    end

    def response
      @response ||= http.get(swf_url)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thwomp-0.1.0 lib/thwomp/downloader.rb
thwomp-0.0.6 lib/thwomp/downloader.rb