Class: Cloudinary::CarrierWave::StoredFile

Inherits:
PreloadedFile show all
Defined in:
lib/cloudinary/carrier_wave/preloaded.rb

Constant Summary

Constants inherited from PreloadedFile

PreloadedFile::PRELOADED_CLOUDINARY_PATH

Instance Attribute Summary

Attributes inherited from PreloadedFile

#filename, #format, #public_id, #resource_type, #signature, #type, #version

Instance Method Summary collapse

Methods inherited from PreloadedFile

#identifier, split_format

Constructor Details

#initialize(file_info) ⇒ StoredFile

Returns a new instance of StoredFile.



60
61
62
63
64
65
66
67
68
69
# File 'lib/cloudinary/carrier_wave/preloaded.rb', line 60

def initialize(file_info)
  if file_info.match(STORED_CLOUDINARY_PATH)
    @resource_type, @type, @version, @filename = file_info.scan(STORED_CLOUDINARY_PATH).first 
  elsif file_info.match(SHORT_STORED_CLOUDINARY_PATH)
    @version, @filename = file_info.scan(SHORT_STORED_CLOUDINARY_PATH).first
  else
    raise(ArgumentError, "File #{file_info} is illegal") 
  end
  @public_id, @format = Cloudinary::PreloadedFile.split_format(@filename)
end

Instance Method Details

#deleteObject



75
76
77
# File 'lib/cloudinary/carrier_wave/preloaded.rb', line 75

def delete
  # Do nothing. This is a virtual file.
end

#original_filenameObject



79
80
81
# File 'lib/cloudinary/carrier_wave/preloaded.rb', line 79

def original_filename
  self.filename
end

#to_sObject



83
84
85
# File 'lib/cloudinary/carrier_wave/preloaded.rb', line 83

def to_s
  identifier
end

#valid?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/cloudinary/carrier_wave/preloaded.rb', line 71

def valid?
  true
end