Class: Cloudinary::CarrierWave::CloudinaryFile
- Defined in:
- lib/cloudinary/carrier_wave.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#public_id ⇒ Object
readonly
Returns the value of attribute public_id.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
-
#storage_type ⇒ Object
readonly
Returns the value of attribute storage_type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(identifier, uploader) ⇒ CloudinaryFile
constructor
A new instance of CloudinaryFile.
- #read(options = {}) ⇒ Object
Constructor Details
#initialize(identifier, uploader) ⇒ CloudinaryFile
Returns a new instance of CloudinaryFile.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/cloudinary/carrier_wave.rb', line 141 def initialize(identifier, uploader) @uploader = uploader @identifier = identifier if @identifier.match(%r(^v([0-9]+)/(.*))) @version = $1 @filename = $2 else @filename = @identifier @version = nil end @storage_type = uploader.class.storage_type @resource_type = Cloudinary::Utils.resource_type_for_format(@filename) @public_id, @format = Cloudinary::PreloadedFile.split_format(@filename) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
140 141 142 |
# File 'lib/cloudinary/carrier_wave.rb', line 140 def filename @filename end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
140 141 142 |
# File 'lib/cloudinary/carrier_wave.rb', line 140 def format @format end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
140 141 142 |
# File 'lib/cloudinary/carrier_wave.rb', line 140 def identifier @identifier end |
#public_id ⇒ Object (readonly)
Returns the value of attribute public_id.
140 141 142 |
# File 'lib/cloudinary/carrier_wave.rb', line 140 def public_id @public_id end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
140 141 142 |
# File 'lib/cloudinary/carrier_wave.rb', line 140 def resource_type @resource_type end |
#storage_type ⇒ Object (readonly)
Returns the value of attribute storage_type.
140 141 142 |
# File 'lib/cloudinary/carrier_wave.rb', line 140 def storage_type @storage_type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
140 141 142 |
# File 'lib/cloudinary/carrier_wave.rb', line 140 def version @version end |
Instance Method Details
#delete ⇒ Object
158 159 160 161 |
# File 'lib/cloudinary/carrier_wave.rb', line 158 def delete public_id = @resource_type == "raw" ? self.filename : self.public_id Cloudinary::Uploader.destroy(public_id, :type=>self.storage_type, :resource_type=>self.resource_type) if @uploader.delete_remote? end |
#exists? ⇒ Boolean
163 164 165 |
# File 'lib/cloudinary/carrier_wave.rb', line 163 def exists? Cloudinary::Uploader.exists?(self.identifier, :type=>self.storage_type, :resource_type=>self.resource_type) end |
#read(options = {}) ⇒ Object
167 168 169 170 |
# File 'lib/cloudinary/carrier_wave.rb', line 167 def read(={}) parameters={:type=>self.storage_type, :resource_type=>self.resource_type}.merge() Cloudinary::Downloader.download(self.identifier, parameters) end |