class Assembly::ContentMetadata::File
Represents a single File
Attributes
file[R]
Public Class Methods
new(bundle: nil, file:, style: nil)
click to toggle source
@param [Symbol] bundle @param [Assembly::ObjectFile] file @param style
# File lib/assembly-objectfile/content_metadata/file.rb, line 12 def initialize(bundle: nil, file:, style: nil) @bundle = bundle @file = file @style = style end
Public Instance Methods
file_attributes(provided_file_attributes)
click to toggle source
# 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:)
click to toggle source
# 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()
click to toggle source
# File lib/assembly-objectfile/content_metadata/file.rb, line 34 def image_data { height: file.exif.imageheight, width: file.exif.imagewidth } end