Sha256: f21cc474f02e0a0e81fd3741553412cf7141645003d99a967164e222300e68ab

Contents?: true

Size: 386 Bytes

Versions: 5

Compression:

Stored size: 386 Bytes

Contents

require 'net/http'

module Net
  def self.download(url)
    Net::HTTP.get_response(URI.parse(url))
  end

  def self.download_and_save(url,path = nil)
    if path.nil?
      path = File.expand_path(url.split('/').last)
    else
      path = File.expand_path(path)
    end
    resp = download(url)
    open(path,'w') { |file| file.write(resp) } if resp.to_s.include?('HTTPOK')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
darkhelmet-darkext-0.9.3 lib/darkext/net.rb
darkhelmet-darkext-0.9.4 lib/darkext/net.rb
darkhelmet-darkext-0.9.5 lib/darkext/net.rb
darkhelmet-darkext-0.9.6 lib/darkext/net.rb
darkhelmet-darkext-0.9.7 lib/darkext/net.rb