Class: Assembly::ContentMetadata::FileSetBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/assembly-objectfile/content_metadata/file_set_builder.rb

Overview

Builds a groups of related Files, based on bundle

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bundle:, objects:, style:) ⇒ FileSetBuilder

Returns a new instance of FileSetBuilder.



14
15
16
17
18
# File 'lib/assembly-objectfile/content_metadata/file_set_builder.rb', line 14

def initialize(bundle:, objects:, style:)
  @bundle = bundle
  @objects = objects
  @style = style
end

Class Method Details

.build(bundle:, objects:, style:) ⇒ Object

Parameters:

  • bundle (Symbol)

    one of: :default, :filename, :dpg or :prebundled

  • objects (Array<Assembly::ObjectFile>)
  • style (Symbol)

    one of: :simple_image, :file, :simple_book, :book_as_image, :book_with_pdf, :map, or :ā€˜3dā€™



10
11
12
# File 'lib/assembly-objectfile/content_metadata/file_set_builder.rb', line 10

def self.build(bundle:, objects:, style:)
  new(bundle: bundle, objects: objects, style: style).build
end

Instance Method Details

#buildArray<FileSet>

Returns a list of filesets in the object.

Returns:

  • (Array<FileSet>)

    a list of filesets in the object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/assembly-objectfile/content_metadata/file_set_builder.rb', line 21

def build
  case bundle
  when :default # one resource per object
    objects.collect { |obj| FileSet.new(resource_files: [obj], style: style) }
  when :filename # one resource per distinct filename (excluding extension)
    build_for_filename
  when :dpg # group by DPG filename
    build_for_dpg
  when :prebundled
    # if the user specifies this method, they will pass in an array of arrays, indicating resources, so we don't need to bundle in the gem
    # This is used by the assemblyWF if you have stubContentMetadata.xml
    objects.map { |inner| FileSet.new(resource_files: inner, style: style) }
  else
    raise 'Invalid bundle method'
  end
end