Sha256: e63ff3e6eab5ac4067d6dab8beb5753ad530cf58b05b3900f34968521b4f46d9

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

module IIIFManifest
  class ManifestBuilder
    class ResourceBuilder
      attr_reader :display_image, :iiif_resource_factory, :image_service_builder_factory
      def initialize(display_image, iiif_resource_factory:, image_service_builder_factory:)
        @display_image = display_image
        @iiif_resource_factory = iiif_resource_factory
        @image_service_builder_factory = image_service_builder_factory
      end

      def apply(annotation)
        resource['@id'] = display_image.url
        resource['@type'] = 'dctypes:Image'
        resource['height'] = display_image.height
        resource['width'] = display_image.width
        resource['format'] = display_image.format
        image_service_builder.apply(resource) if iiif_endpoint
        annotation.resource = resource
      end

      private

      def resource
        @resource ||= iiif_resource_factory.new
      end

      def iiif_endpoint
        display_image.try(:iiif_endpoint)
      end

      def image_service_builder
        image_service_builder_factory.new(iiif_endpoint)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/iiif_manifest-1.5.0/lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.6.0 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.5.0 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.4.0 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.3.1 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.3.0 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.2.0 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.1.1 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-1.1.0 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-0.4.0 lib/iiif_manifest/manifest_builder/resource_builder.rb
iiif_manifest-0.3.0 lib/iiif_manifest/manifest_builder/resource_builder.rb