class Assembly::ContentMetadata::FileSet
Represents a groups of related Files, such as a single master file and the derivatives
Attributes
dpg[R]
resource_files[R]
style[R]
Public Class Methods
new(dpg: false, resource_files:, style:)
click to toggle source
@param [Boolean] dpg (false) is it a dpg bundle? @param [Array<Assembly::ObjectFile>] resource_files
@param style
# File lib/assembly-objectfile/content_metadata/file_set.rb, line 12 def initialize(dpg: false, resource_files:, style:) @dpg = dpg @resource_files = resource_files @style = style end
Public Instance Methods
files()
click to toggle source
# File lib/assembly-objectfile/content_metadata/file_set.rb, line 28 def files resource_files.map { |file| File.new(file: file) } end
label_from_file(default:)
click to toggle source
# File lib/assembly-objectfile/content_metadata/file_set.rb, line 24 def label_from_file(default:) resource_files.find { |obj| obj.label.present? }&.label || default end
resource_type_description()
click to toggle source
objects in the special DPG folders are always type=object when we using :bundle=>:dpg otherwise look at the style to determine the resource_type_description
# File lib/assembly-objectfile/content_metadata/file_set.rb, line 20 def resource_type_description @resource_type_description ||= special_dpg_resource? ? 'object' : resource_type_descriptions end
Private Instance Methods
resource_type_descriptions()
click to toggle source
# File lib/assembly-objectfile/content_metadata/file_set.rb, line 42 def resource_type_descriptions # grab all of the file types within a resource into an array so we can decide what the resource type should be resource_file_types = resource_files.collect(&:object_type) resource_has_non_images = !(resource_file_types - [:image]).empty? case style when :simple_image 'image' when :file 'file' when :simple_book # in a simple book project, all resources are pages unless they are *all* non-images -- if so, switch the type to object resource_has_non_images && resource_file_types.include?(:image) == false ? 'object' : 'page' when :book_as_image # same as simple book, but all resources are images instead of pages, unless we need to switch them to object type resource_has_non_images && resource_file_types.include?(:image) == false ? 'object' : 'image' when :book_with_pdf # in book with PDF type, if we find a resource with *any* non images, switch it's type from book to object resource_has_non_images ? 'object' : 'page' when :map 'image' when :'3d' resource_extensions = resource_files.collect(&:ext) if (resource_extensions & VALID_THREE_DIMENSION_EXTENTIONS).empty? # if this resource contains no known 3D file extensions, the resource type is file 'file' else # otherwise the resource type is 3d '3d' end end end
special_dpg_resource?()
click to toggle source
# File lib/assembly-objectfile/content_metadata/file_set.rb, line 36 def special_dpg_resource? return false unless dpg resource_files.collect { |obj| ContentMetadata.special_dpg_folder?(obj.dpg_folder) }.include?(true) end