Class: IIIF::V3::Presentation::Manifest
Constant Summary
collapse
- TYPE =
'Manifest'.freeze
AbstractResource::CONTENT_RESOURCE_PROPERTIES, AbstractResource::PAGING_PROPERTIES
HashBehaviours::SIMPLE_SELF_RETURNERS
Instance Method Summary
collapse
#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
#clear, #merge, #merge!, #reject!, #select, #select!
Constructor Details
#initialize(hsh = {}) ⇒ Manifest
34
35
36
37
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 34
def initialize(hsh={})
hsh['type'] = TYPE unless hsh.has_key? 'type'
super(hsh)
end
|
Instance Method Details
#array_only_keys ⇒ Object
23
24
25
26
27
28
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 23
def array_only_keys
super + %w{ items structures sequences }
end
|
#legal_viewing_hint_values ⇒ Object
30
31
32
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 30
def legal_viewing_hint_values
%w{ individuals paged continuous auto-advance }
end
|
#prohibited_keys ⇒ Object
15
16
17
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 15
def prohibited_keys
super + CONTENT_RESOURCE_PROPERTIES + PAGING_PROPERTIES + %w{ start_canvas content_annotation }
end
|
#required_keys ⇒ Object
8
9
10
11
12
13
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 8
def required_keys
super + %w{ id label }
end
|
#uri_only_keys ⇒ Object
19
20
21
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 19
def uri_only_keys
super + %w{ id }
end
|
#validate ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 39
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
unless self&.[]('items')&.any?
m = 'The items list must have at least one entry (and it must be a IIIF::V3::Presentation::Canvas)'
raise IIIF::V3::Presentation::MissingRequiredKeyError, m
end
validate_items_list(self['items']) if self['items']
if self['structures']
unless self['structures'].all? { |entry| entry.instance_of?(IIIF::V3::Presentation::Range)}
m = 'All entries in the structures list must be a IIIF::V3::Presentation::Range'
raise IIIF::V3::Presentation::IllegalValueError, m
end
end
end
|
#validate_items_list(items_array) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/iiif/v3/presentation/manifest.rb', line 66
def validate_items_list(items_array)
unless items_array.size >= 1
m = 'The items list must have at least one entry (and it must be a IIIF::V3::Presentation::Canvas)'
raise IIIF::V3::Presentation::MissingRequiredKeyError, m
end
unless items_array.all? { |entry| entry.instance_of?(IIIF::V3::Presentation::Canvas) }
m = 'All entries in the items list must be a IIIF::V3::Presentation::Canvas'
raise IIIF::V3::Presentation::IllegalValueError, m
end
end
|