Sha256: 1b360ec9b2d173ef8dc40157a41fae8e40fdf4644673a4d22ea46236cf62c5cb

Contents?: true

Size: 944 Bytes

Versions: 7

Compression:

Stored size: 944 Bytes

Contents

module IIIFManifest
  module V3
    class ManifestBuilder
      class ImageServiceBuilder
        attr_reader :iiif_endpoint, :iiif_service_factory
        def initialize(iiif_endpoint, iiif_service_factory:)
          @iiif_endpoint = iiif_endpoint
          @iiif_service_factory = iiif_service_factory
        end

        def apply(resource)
          service['@id'] = iiif_endpoint.url
          service['profile'] = iiif_endpoint.profile
          service['@type'] = determine_type(iiif_endpoint.context)
          resource.service = [service]
        end

        private

        def determine_type(context)
          case context
          when 'http://iiif.io/api/image/1/context.json'
            'ImageService1'
          when 'http://iiif.io/api/image/2/context.json'
            'ImageService2'
          end
        end

        def service
          @service ||= iiif_service_factory.new
        end
      end
    end
  end
end

Version data entries

7 entries across 7 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/v3/manifest_builder/image_service_builder.rb
iiif_manifest-1.6.0 lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb
iiif_manifest-1.5.0 lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb
iiif_manifest-1.4.0 lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb
iiif_manifest-1.3.1 lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb
iiif_manifest-1.3.0 lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb
iiif_manifest-1.2.0 lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb