Class: CarrierWave::Storage::Yandex::Disk::File
- Inherits:
-
Object
- Object
- CarrierWave::Storage::Yandex::Disk::File
- Includes:
- Utilities::Uri
- Defined in:
- lib/carrierwave/yandex/storage/disk.rb
Overview
Rubocop, shut up
Instance Method Summary collapse
- #delete ⇒ Object
- #extension ⇒ Object
- #filename ⇒ Object
-
#initialize(public_url, location, yandex_disk_client) ⇒ File
constructor
A new instance of File.
- #public_url ⇒ Object
- #storage_path ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(public_url, location, yandex_disk_client) ⇒ File
Returns a new instance of File.
73 74 75 76 77 |
# 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 |
Instance Method Details
#delete ⇒ Object
105 106 107 108 |
# 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 ⇒ Object
83 84 85 |
# File 'lib/carrierwave/yandex/storage/disk.rb', line 83 def extension ::File.extname @location end |
#filename ⇒ Object
79 80 81 |
# File 'lib/carrierwave/yandex/storage/disk.rb', line 79 def filename ::File.basename @location end |
#public_url ⇒ Object
96 97 98 |
# File 'lib/carrierwave/yandex/storage/disk.rb', line 96 def public_url CGI.unescape @public_url end |
#storage_path ⇒ Object
100 101 102 103 |
# 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 ⇒ Object
87 88 89 90 91 92 93 94 |
# 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 |