class Algorithmia::DataFile

Public Instance Methods

delete() click to toggle source
# File lib/algorithmia/data_file.rb, line 39
def delete
  Algorithmia::Requester.new(@client).delete(@url)
  true
end
exists?() click to toggle source
# File lib/algorithmia/data_file.rb, line 6
def exists?
  Algorithmia::Requester.new(@client).head(@url)
  true
rescue Errors::NotFoundError
  false
end
get() click to toggle source
# File lib/algorithmia/data_file.rb, line 24
def get
  Algorithmia::Requester.new(@client).get(@url).body
end
get_file() click to toggle source
# File lib/algorithmia/data_file.rb, line 13
def get_file
  response = get

  tempfile = Tempfile.open(File.basename(@url)) do |f|
    f.write response
    f
  end

  File.new(tempfile.path)
end
put(data) click to toggle source
# File lib/algorithmia/data_file.rb, line 28
def put(data)
  Algorithmia::Requester.new(@client).put(@url, data, headers: {})
end
Also aliased as: put_json
put_file(file_path) click to toggle source
# File lib/algorithmia/data_file.rb, line 34
def put_file(file_path)
  data = File.binread(file_path)
  put(data)
end
put_json(data)
Alias for: put