class CarrierWave::Storage::Yandex::Disk::File

Rubocop, shut up

Public Class Methods

new(public_url, location, yandex_disk_client) click to toggle source
# File lib/carrierwave/yandex/storage/disk.rb, line 73
def initialize(public_url, location, yandex_disk_client)
  @public_url = public_url
  @location = location
  @yandex_disk_client = yandex_disk_client
end

Public Instance Methods

delete() click to toggle source
# File lib/carrierwave/yandex/storage/disk.rb, line 105
def delete
  @yandex_disk_client.delete @location
  @yandex_disk_client.delete(::File.dirname(@location))
end
extension() click to toggle source
# File lib/carrierwave/yandex/storage/disk.rb, line 83
def extension
  ::File.extname @location
end
filename() click to toggle source
# File lib/carrierwave/yandex/storage/disk.rb, line 79
def filename
  ::File.basename @location
end
public_url() click to toggle source
# File lib/carrierwave/yandex/storage/disk.rb, line 96
def public_url
  CGI.unescape @public_url
end
storage_path() click to toggle source
# File lib/carrierwave/yandex/storage/disk.rb, line 100
def storage_path
  # deviation from http://www.rubydoc.info/gems/carrierwave/CarrierWave/Storage/Fog/File
  @location
end
url() click to toggle source
# File lib/carrierwave/yandex/storage/disk.rb, line 87
def url
  query = 'https://cloud-api.yandex.net/v1/disk/public/resources/' \
  "download?public_key=#{@public_url}"
  uri = URI query
  res = Net::HTTP.get(uri)
  hash = JSON.parse(res)
  hash['href']
end