Class: Assembly::ContentMetadata::File
- Inherits:
-
Object
- Object
- Assembly::ContentMetadata::File
- Defined in:
- lib/assembly-objectfile/content_metadata/file.rb
Overview
Represents a single File
Instance Method Summary collapse
- #file_attributes(provided_file_attributes) ⇒ Object
- #file_id(common_path:, flatten_folder_structure:) ⇒ Object
- #image_data ⇒ Object
-
#initialize(bundle: nil, file:, style: nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(bundle: nil, file:, style: nil) ⇒ File
Returns a new instance of File.
12 13 14 15 16 |
# File 'lib/assembly-objectfile/content_metadata/file.rb', line 12 def initialize(bundle: nil, file:, style: nil) @bundle = bundle @file = file @style = style end |
Instance Method Details
#file_attributes(provided_file_attributes) ⇒ Object
30 31 32 |
# File 'lib/assembly-objectfile/content_metadata/file.rb', line 30 def file_attributes(provided_file_attributes) file.file_attributes || provided_file_attributes[mimetype] || provided_file_attributes['default'] || Assembly::FILE_ATTRIBUTES[mimetype] || Assembly::FILE_ATTRIBUTES['default'] end |
#file_id(common_path:, flatten_folder_structure:) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/assembly-objectfile/content_metadata/file.rb', line 20 def file_id(common_path:, flatten_folder_structure:) # set file id attribute, first check the relative_path parameter on the object, and if it is set, just use that return file.relative_path if file.relative_path # if the relative_path attribute is not set, then use the path attribute and check to see if we need to remove the common part of the path file_id = common_path ? file.path.gsub(common_path, '') : file.path file_id = ::File.basename(file_id) if flatten_folder_structure file_id end |
#image_data ⇒ Object
34 35 36 |
# File 'lib/assembly-objectfile/content_metadata/file.rb', line 34 def image_data { height: file.exif.imageheight, width: file.exif.imagewidth } end |