Class: Evm::RemoteFile

Inherits:
Object
  • Object
show all
Defined in:
lib/evm/remote_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ RemoteFile

Returns a new instance of RemoteFile.



5
6
7
8
9
10
# File 'lib/evm/remote_file.rb', line 5

def initialize(url, options = {})
  @url = url
  @options = options
  @file = options[:file] ||= File
  @uri = options[:uri] ||= URI
end

Instance Method Details

#download(path) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/evm/remote_file.rb', line 12

def download(path)
  unless @file.exist?(path)
    @file.open(path, 'w') do |file|
      file.write(@uri.parse(@url).read)
    end
  end
end