Class: IIIF::V3::Presentation::Service

Inherits:
AbstractResource show all
Defined in:
lib/iiif/v3/presentation/service.rb

Overview

Constant Summary collapse

IIIF_IMAGE_V2_TYPE =

constants included here for convenience

'ImageService2'.freeze
IIIF_IMAGE_V2_LEVEL1_PROFILE =
'http://iiif.io/api/image/2/level1.json'.freeze
IIIF_AUTHENTICATION_V1_LOGIN_PROFILE =
'http://iiif.io/api/auth/1/login'.freeze
IIIF_AUTHENTICATION_V1_TOKEN_PROFILE =
'http://iiif.io/api/auth/1/token'.freeze

Constants inherited from AbstractResource

AbstractResource::CONTENT_RESOURCE_PROPERTIES, AbstractResource::PAGING_PROPERTIES

Constants included from HashBehaviours

HashBehaviours::SIMPLE_SELF_RETURNERS

Instance Method Summary collapse

Methods inherited from AbstractResource

#array_only_keys, from_ordered_hash, #hash_only_keys, #initialize, #int_only_keys, #legal_viewing_direction_values, #legal_viewing_hint_values, #numeric_only_keys, parse, #string_only_keys, #to_json, #to_ordered_hash

Methods included from HashBehaviours

#clear, #merge, #merge!, #reject!, #select, #select!

Constructor Details

This class inherits a constructor from IIIF::V3::AbstractResource

Instance Method Details

#any_type_keysObject



27
28
29
# File 'lib/iiif/v3/presentation/service.rb', line 27

def any_type_keys
  super + %w{ profile }
end

#prohibited_keysObject



18
19
20
21
# File 'lib/iiif/v3/presentation/service.rb', line 18

def prohibited_keys
  super + CONTENT_RESOURCE_PROPERTIES + PAGING_PROPERTIES +
    %w{ nav_date viewing_direction start_canvas content_annotations }
end

#required_keysObject

service class doesn't require type



14
15
16
# File 'lib/iiif/v3/presentation/service.rb', line 14

def required_keys
  super.reject {|el| el == 'type' }
end

#uri_only_keysObject



23
24
25
# File 'lib/iiif/v3/presentation/service.rb', line 23

def uri_only_keys
  super + %w{ @context id @id }
end

#validateObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/iiif/v3/presentation/service.rb', line 31

def validate
  super
  if IIIF_IMAGE_V2_TYPE == self['type'] || IIIF_IMAGE_V2_TYPE == self['@type']
    unless self.has_key?('id') || self.has_key?('@id')
      m = "id or @id values are required for IIIF::V3::Presentation::Service with type or @type #{IIIF_IMAGE_V2_TYPE}"
      raise IIIF::V3::Presentation::MissingRequiredKeyError, m
    end
    if self.has_key?('id') && self.has_key?('@id') && (self['@id'] != self['id'])
      m = "id and @id values must match for IIIF::V3::Presentation::Service with type or @type #{IIIF_IMAGE_V2_TYPE}"
      raise IIIF::V3::Presentation::IllegalValueError, m
    end
    unless self.has_key?('profile')
      m = "profile should be present for IIIF::V3::Presentation::Service with type or @type #{IIIF_IMAGE_V2_TYPE}"
      raise IIIF::V3::Presentation::MissingRequiredKeyError, m
    end
  end
end