Class: IIIF::V3::Presentation::AnnotationPage

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

Constant Summary collapse

TYPE =
'AnnotationPage'.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

#any_type_keys, from_ordered_hash, #hash_only_keys, #int_only_keys, #legal_viewing_direction_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

#initialize(hsh = {}) ⇒ AnnotationPage

Returns a new instance of AnnotationPage.



29
30
31
32
# File 'lib/iiif/v3/presentation/annotation_page.rb', line 29

def initialize(hsh={})
  hsh['type'] = TYPE unless hsh.has_key? 'type'
  super(hsh)
end

Instance Method Details

#array_only_keysObject



21
22
23
# File 'lib/iiif/v3/presentation/annotation_page.rb', line 21

def array_only_keys;
  super + %w{ items }
end


25
26
27
# File 'lib/iiif/v3/presentation/annotation_page.rb', line 25

def legal_viewing_hint_values
  super + %w{ none }
end

#prohibited_keysObject



12
13
14
15
# File 'lib/iiif/v3/presentation/annotation_page.rb', line 12

def prohibited_keys
  super + CONTENT_RESOURCE_PROPERTIES +
    %w{ first last total nav_date viewing_direction start_canvas content_annotations }
end

#required_keysObject



8
9
10
# File 'lib/iiif/v3/presentation/annotation_page.rb', line 8

def required_keys
  super + %w{ id }
end

#uri_only_keysObject



17
18
19
# File 'lib/iiif/v3/presentation/annotation_page.rb', line 17

def uri_only_keys
  super + %w{ id }
end

#validateObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/iiif/v3/presentation/annotation_page.rb', line 34

def validate
  super

  unless self['id'] =~ /^https?:/
    err_msg = "id must be an http(s) URI for #{self.class}"
    raise IIIF::V3::Presentation::IllegalValueError, err_msg
  end

  items = self['items']
  if items && items.any?
    unless items.all? { |entry| entry.instance_of?(IIIF::V3::Presentation::Annotation) }
      err_msg = 'All entries in the items list must be a IIIF::V3::Presentation::Annotation'
      raise IIIF::V3::Presentation::IllegalValueError, err_msg
    end
  end
end