Class: Cloudinary::PreloadedFile
- Defined in:
- lib/cloudinary/preloaded_file.rb
Direct Known Subclasses
Constant Summary collapse
- PRELOADED_CLOUDINARY_PATH =
/^([^\/]+)\/([^\/]+)\/v(\d+)\/([^\/]+)#([^\/]+)$/
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#public_id ⇒ Object
readonly
Returns the value of attribute public_id.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #identifier ⇒ Object
-
#initialize(file_info) ⇒ PreloadedFile
constructor
A new instance of PreloadedFile.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(file_info) ⇒ PreloadedFile
Returns a new instance of PreloadedFile.
5 6 7 8 |
# File 'lib/cloudinary/preloaded_file.rb', line 5 def initialize(file_info) @resource_type, @type, @version, @filename, @signature = file_info.scan(PRELOADED_CLOUDINARY_PATH).first @public_id = @resource_type == "image" ? @filename[0..(@filename.rindex(".")-1)] : @filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/cloudinary/preloaded_file.rb', line 4 def filename @filename end |
#public_id ⇒ Object (readonly)
Returns the value of attribute public_id.
4 5 6 |
# File 'lib/cloudinary/preloaded_file.rb', line 4 def public_id @public_id end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
4 5 6 |
# File 'lib/cloudinary/preloaded_file.rb', line 4 def resource_type @resource_type end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
4 5 6 |
# File 'lib/cloudinary/preloaded_file.rb', line 4 def signature @signature end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/cloudinary/preloaded_file.rb', line 4 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
4 5 6 |
# File 'lib/cloudinary/preloaded_file.rb', line 4 def version @version end |
Instance Method Details
#identifier ⇒ Object
15 16 17 |
# File 'lib/cloudinary/preloaded_file.rb', line 15 def identifier "v#{version}/#{filename}" end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/cloudinary/preloaded_file.rb', line 19 def to_s "#{resource_type}/#{type}/v#{version}/#{filename}##{signature}" end |
#valid? ⇒ Boolean
10 11 12 13 |
# File 'lib/cloudinary/preloaded_file.rb', line 10 def valid? expected_signature = Cloudinary::Utils.api_sign_request({:public_id=>public_id, :version=>version}, Cloudinary.config.api_secret) @signature == expected_signature end |