wax_iiif 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +25 -0
  4. data/.travis.yml +2 -2
  5. data/Gemfile +3 -2
  6. data/README.md +4 -4
  7. data/lib/wax_iiif.rb +34 -44
  8. data/lib/wax_iiif/base_properties.rb +90 -0
  9. data/lib/wax_iiif/builder.rb +252 -0
  10. data/lib/wax_iiif/collection.rb +58 -0
  11. data/lib/{iiif_s3 → wax_iiif}/config.rb +46 -60
  12. data/lib/{iiif_s3 → wax_iiif}/errors.rb +6 -12
  13. data/lib/{iiif_s3 → wax_iiif}/full_image.rb +3 -8
  14. data/lib/wax_iiif/image_info.rb +89 -0
  15. data/lib/{iiif_s3 → wax_iiif}/image_record.rb +48 -63
  16. data/lib/{iiif_s3 → wax_iiif}/image_tile.rb +8 -14
  17. data/lib/{iiif_s3 → wax_iiif}/image_variant.rb +20 -38
  18. data/lib/wax_iiif/manifest.rb +151 -0
  19. data/lib/{iiif_s3 → wax_iiif}/thumbnail.rb +5 -9
  20. data/lib/{iiif_s3 → wax_iiif}/utilities.rb +5 -5
  21. data/lib/{iiif_s3 → wax_iiif}/utilities/helpers.rb +18 -48
  22. data/lib/{iiif_s3 → wax_iiif}/utilities/pdf_splitter.rb +20 -23
  23. data/spec/base_properties_spec.rb +8 -12
  24. data/spec/shared_contexts.rb +28 -92
  25. data/spec/spec_helper.rb +3 -3
  26. data/spec/wax_iiif/builder_spec.rb +143 -0
  27. data/spec/wax_iiif/collection_spec.rb +53 -0
  28. data/spec/wax_iiif/config_spec.rb +15 -0
  29. data/spec/wax_iiif/image_info_spec.rb +57 -0
  30. data/spec/wax_iiif/image_record_spec.rb +82 -0
  31. data/spec/wax_iiif/image_variant_spec.rb +66 -0
  32. data/spec/wax_iiif/manifest_spec.rb +97 -0
  33. data/spec/wax_iiif/utilities/pdf_splitter_spec.rb +14 -0
  34. data/wax_iiif.gemspec +15 -19
  35. metadata +52 -97
  36. data/Guardfile +0 -10
  37. data/Rakefile +0 -24
  38. data/lib/iiif_s3/base_properties.rb +0 -95
  39. data/lib/iiif_s3/builder.rb +0 -241
  40. data/lib/iiif_s3/collection.rb +0 -61
  41. data/lib/iiif_s3/image_info.rb +0 -96
  42. data/lib/iiif_s3/manifest.rb +0 -151
  43. data/lib/iiif_s3/version.rb +0 -5
  44. data/spec/iiif_s3/builder_spec.rb +0 -152
  45. data/spec/iiif_s3/collection_spec.rb +0 -68
  46. data/spec/iiif_s3/config_spec.rb +0 -15
  47. data/spec/iiif_s3/image_info_spec.rb +0 -57
  48. data/spec/iiif_s3/image_record_spec.rb +0 -96
  49. data/spec/iiif_s3/image_variant_spec.rb +0 -68
  50. data/spec/iiif_s3/manifest_spec.rb +0 -97
  51. data/spec/iiif_s3/utilities/pdf_splitter_spec.rb +0 -17
  52. data/test.rb +0 -77
@@ -0,0 +1,58 @@
1
+ module WaxIiif
2
+ # Class Collection is an abstraction over the IIIF Collection, which is an aggregation
3
+ # of IIIF manifests.
4
+ #
5
+ # @author David Newbury <david.newbury@gmail.com>
6
+ #
7
+ class Collection
8
+ # @return [String] The IIIF Type for collections
9
+ TYPE = 'sc:Collection'.freeze
10
+ include BaseProperties
11
+ attr_reader :collections, :manifests, :label
12
+
13
+ def initialize(config)
14
+ raise WaxIiif::Error::MissingCollectionName if config.collection_label.to_s.empty?
15
+
16
+ @config = config
17
+ @manifests = []
18
+ @collections = []
19
+ @label = @config.collection_label
20
+
21
+ self.id = "collection/#{@label}"
22
+ end
23
+
24
+ def add_collection(collection)
25
+ raise WaxIiif::Error::NotACollection unless collection.respond_to?(:type) && collection.type == Collection::TYPE
26
+ @collections.push(collection)
27
+ end
28
+
29
+ def add_manifest(manifest)
30
+ raise WaxIiif::Error::NotAManifest unless manifest.respond_to?(:type) && manifest.type == Manifest::TYPE
31
+ @manifests.push(manifest)
32
+ end
33
+
34
+ # The JSON representation of this collection in the IIIF-expected format
35
+ #
36
+ #
37
+ # @return [String] The JSON representation as a string
38
+ #
39
+ def to_json
40
+ obj = base_properties
41
+ obj['collections'] = collect_object(collections) unless collections.empty?
42
+ obj['manifests'] = collect_object(manifests) unless manifests.empty?
43
+ JSON.pretty_generate obj
44
+ end
45
+
46
+ protected
47
+
48
+ def collect_object(things)
49
+ things.collect do |thing|
50
+ {
51
+ '@id' => thing.id,
52
+ '@type' => thing.type,
53
+ 'label' => thing.label
54
+ }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,95 +1,86 @@
1
- module IiifS3
2
-
1
+ module WaxIiif
3
2
  # Config provides a data structure for holding the configuration settings
4
- # for the IiifS3 class.
3
+ # for the WaxIiif class.
5
4
  #
6
5
  # @author David Newbury <david.newbury@gmail.com>
7
6
  #
8
7
  class Config
9
-
10
8
  # @return [String] The default URL to append to all IDs.
11
- DEFAULT_URL = "http://0.0.0.0"
9
+ DEFAULT_URL = 'http://0.0.0.0'.freeze
12
10
  # @return [String] The name of the subdirectory where generated images live
13
- DEFAULT_IMAGE_DIRECTORY_NAME = "images"
11
+ DEFAULT_IMAGE_DIRECTORY_NAME = 'images'.freeze
14
12
  # @return [String] The default path for writing generated image files
15
- DEFAULT_OUTPUT_DIRECTORY = "./build"
13
+ DEFAULT_OUTPUT_DIRECTORY = './build'.freeze
16
14
  # @return [Number] The default tile width/height in pixels
17
15
  DEFAULT_TILE_WIDTH = 512
18
16
  # @return [Array<Number>] The default tile scaling factors
19
- DEFAULT_TILE_SCALE_FACTORS = [1,2,4,8]
17
+ DEFAULT_TILE_SCALE_FACTORS = [1, 2, 4, 8].freeze
20
18
  # @return [Number] The default thumbnail size in pixels
21
19
  DEFAULT_THUMBNAIL_SIZE = 250
20
+ # @return [String] The default collection label ~> `collection/{LABEL}.json`
21
+ DEFAULT_COLLECTION_LABEL = 'top'.freeze
22
22
 
23
- #
24
23
  # @!attribute [r] base_url
25
- # @return [String] The protocol, domain, and port used for generating URIs.
26
- # Defaults to {IiifS3::Config::DEFAULT_URL}
24
+ # @return [String] The protocol, domain, and port used for generating URIs.
25
+ # Defaults to {WaxIiif::Config::DEFAULT_URL}
27
26
  attr_reader :base_url
28
27
  #
29
28
  # @!attribute [r] use_extensions
30
- # @return [Boolean] Should generated IDs and files have a .json extension?
29
+ # @return [Boolean] Should generated IDs and files have a .json extension?
31
30
  # Defaults to true
32
31
  attr_reader :use_extensions
33
32
  #
34
33
  # @!attribute [r] output_dir
35
- # @return [String] The directory on the local file system where the output
34
+ # @return [String] The directory on the local file system where the output
36
35
  # files should be saved
37
- # Defaults to {IiifS3::Config::DEFAULT_OUTPUT_DIRECTORY}
36
+ # Defaults to {WaxIiif::Config::DEFAULT_OUTPUT_DIRECTORY}
38
37
  attr_reader :output_dir
39
38
  #
40
39
  # @!attribute [r] prefix
41
- # @return [String] A prefix to be appended between the base URI and the id.
40
+ # @return [String] A prefix to be appended between the base URI and the id.
42
41
  # Can be blank,and it will automatically prepend a slash if one is not
43
42
  # provided.
44
- # Defaults to ""
43
+ # Defaults to ''
45
44
  attr_reader :prefix
46
45
  #
47
46
  # @!attribute [r] image_directory_name
48
- # @return [String] The name of the directory/prefix where image files will be
47
+ # @return [String] The name of the directory/prefix where image files will be
49
48
  # located.
50
- # Defaults to IiifS3::Config::DEFAULT_IMAGE_DIRECTORY_NAME
49
+ # Defaults to WaxIiif::Config::DEFAULT_IMAGE_DIRECTORY_NAME
51
50
  attr_reader :image_directory_name
52
51
  #
53
52
  # @!attribute [r] tile_width
54
- # @return [Number] The width (and height) of each individual tile.
55
- # Defaults to IiifS3::Config::DEFAULT_TILE_WIDTH
53
+ # @return [Number] The width (and height) of each individual tile.
54
+ # Defaults to WaxIiif::Config::DEFAULT_TILE_WIDTH
56
55
  attr_reader :tile_width
57
56
  #
58
57
  # @!attribute [r] tile
59
- # @return [Array<Number>] An array of tile ratios to be uploaded.
60
- # Defaults to IiifS3::Config::DEFAULT_TILE_SCALE_FACTORS
58
+ # @return [Array<Number>] An array of tile ratios to be uploaded.
59
+ # Defaults to WaxIiif::Config::DEFAULT_TILE_SCALE_FACTORS
61
60
  attr_reader :tile_scale_factors
62
61
  #
63
62
  # @!attribute [r] variants
64
- # @return [Hash] A Hash of key/value pairs. Each key should be the name of a variant,
65
- # each value the maximum pixel dimension of the longest side.
63
+ # @return [Hash] A Hash of key/value pairs. Each key should be the name of a variant,
64
+ # each value the maximum pixel dimension of the longest side.
66
65
  # Defaults to {}
67
66
  attr_reader :variants
68
- #
69
- # @!attribute [r] upload_to_s3
70
- # @return [Boolean] Should the files that are created by automatically uploaded to Amazon S3?
71
- # Defaults to false
72
- attr_reader :upload_to_s3
73
67
 
74
68
  # @!attribute [r] thumbnail_size
75
- # @return [Number] The max width in pixels for a thumbnail image
69
+ # @return [Number] The max width in pixels for a thumbnail image
76
70
  attr_reader :thumbnail_size
77
71
 
72
+ # @!attribute [r] collection_label
73
+ # @return [String] the label for the collection
74
+ attr_reader :collection_label
75
+
78
76
  # @!attribute [r] verbose
79
- # @return [Bool] Should the program log information to the console?
77
+ # @return [Bool] Should the program log information to the console?
80
78
  attr_reader :verbose
81
- alias :verbose? :verbose
82
-
83
- # @!attribute [r] s3
84
- # @return [IiifS3::AmazonS3] the S3 object for this system
85
- attr_reader :s3
86
-
79
+ alias verbose? verbose
87
80
 
88
81
  # Initialize a new configuration option.
89
82
  #
90
83
  # @param [Hash] opts
91
- # @option opts [Boolean] :upload_to_s3 if true, images and metadata will be
92
- # uploaded to Amazon S3. Defaults to False.
93
84
  # @option opts [Number] :tile_width The width in pixels for generated tiles.
94
85
  # Defaults to {DEFAULT_TILE_WIDTH}
95
86
  # @option opts [Array<Number>] :tile_scale_factors An array of ratios for generated tiles.
@@ -99,42 +90,37 @@ module IiifS3
99
90
  # @option opts [String] :output_dir The name of the directory for generated files.
100
91
  # image data. Defaults to {DEFAULT_OUTPUT_DIRECTORY}
101
92
  # @option opts [String] :base_url The base URL for the generated URIs. Defaults to
102
- # {DEFAULT_URL} if not auto-uploading to S3 and to the s3 bucket if upload_to_s3 is enabled.
93
+ # {DEFAULT_URL}
103
94
  # @option opts [Number] :thumbnail_size the size in pixels
104
95
  # for the largest side of the thumbnail images. Defaults to {DEFAULT_THUMBNAIL_SIZE}.
105
96
  # @option opts [Bool] :use_extensions (true) should files have exensions appended?
106
97
  # @option opts [Bool] :verbose (false) Should debug information be printed to the console?
107
- # @option opts [String] :prefix ("") a prefix (read: subdirectory) for the generated URIs.
98
+ # @option opts [String] :prefix ('') a prefix (read: subdirectory) for the generated URIs.
108
99
  # @option opts [Hash{String: String}] :variants
109
100
  def initialize(opts = {})
110
- @upload_to_s3 = opts[:upload_to_s3] || false
111
- @s3 = IiifS3::AmazonS3.new if @upload_to_s3
112
- @tile_width = opts[:tile_width] || DEFAULT_TILE_WIDTH
113
- @tile_scale_factors = opts[:tile_scale_factors] || DEFAULT_TILE_SCALE_FACTORS
101
+ @tile_width = opts[:tile_width] || DEFAULT_TILE_WIDTH
102
+ @tile_scale_factors = opts[:tile_scale_factors] || DEFAULT_TILE_SCALE_FACTORS
114
103
  @image_directory_name = opts[:image_directory_name] || DEFAULT_IMAGE_DIRECTORY_NAME
115
- @base_url = opts[:base_url] || ( @upload_to_s3 ? @s3.bucket.url : DEFAULT_URL)
116
- @use_extensions = opts.fetch(:use_extensions, true) ## true
117
- @output_dir = opts[:output_dir] || DEFAULT_OUTPUT_DIRECTORY
118
- @variants = opts[:variants] || {}
119
- @thumbnail_size = opts[:thumbnail_size] || DEFAULT_THUMBNAIL_SIZE
120
- @verbose = opts.fetch(:verbose, false) ## false
121
- @prefix = opts[:prefix] || ""
122
- if @prefix.length > 0 && @prefix[0] != "/"
123
- @prefix = "/#{@prefix}"
124
- end
104
+ @base_url = opts[:base_url] || DEFAULT_URL
105
+ @collection_label = opts[:collection_label] || DEFAULT_COLLECTION_LABEL
106
+ @use_extensions = opts.fetch(:use_extensions, true) ## true
107
+ @output_dir = opts[:output_dir] || DEFAULT_OUTPUT_DIRECTORY
108
+ @variants = opts[:variants] || {}
109
+ @thumbnail_size = opts[:thumbnail_size] || DEFAULT_THUMBNAIL_SIZE
110
+ @verbose = opts.fetch(:verbose, false) ## false
111
+ @prefix = opts[:prefix] || ''
112
+ @prefix = "/#{@prefix}" if @prefix.length.positive? && @prefix[0] != '/'
125
113
  end
126
114
 
127
-
128
115
  # Compare two configuration files
129
116
  #
130
- # @param [IiifS3::Config] other_config The configuration file to compare
131
- #
117
+ # @param [WaxIiif::Config] other_config The configuration file to compare
132
118
  # @return [Bool] True if they are the same, false otherwise
133
119
  #
134
- def ==(other_config)
120
+ def ==(other)
135
121
  valid = true
136
122
  self.instance_variables.each do |v|
137
- valid &&= instance_variable_get(v) == other_config.instance_variable_get(v)
123
+ valid &&= instance_variable_get(v) == other.instance_variable_get(v)
138
124
  end
139
125
  valid
140
126
  end
@@ -1,37 +1,31 @@
1
- module IiifS3
2
-
3
- #
4
- # Module Error collects standard errors for th IiifS3 library.
1
+ module WaxIiif
2
+ # Module Error collects standard errors for th WaxIiif library.
5
3
  module Error
6
-
7
4
  # Class BlankCSV indicates that a provided CSV has no data.
8
5
  class BlankCSV < StandardError; end
9
6
 
10
7
  # Class InvalidCSV indicates that there is something wrong with the provided CSV.
11
8
  class InvalidCSV < StandardError; end
12
9
 
13
- # Class BadAmazonCredentials indicates that something was wrong with the Amazon login information.
14
- class BadAmazonCredentials < StandardError; end
15
-
16
10
  # Class MissingCollectionName indicates that the collection provided did not have a label.
17
11
  class MissingCollectionName < StandardError; end
18
12
 
19
13
  # Class NotACollection indicates that the object provided was not a sc:Collection.
20
14
  class NotACollection < StandardError; end
21
-
15
+
22
16
  # Class NotAManifest indicates that the object provided was not a sc:Manifest.
23
17
  class NotAManifest < StandardError; end
24
-
18
+
25
19
  # Class InvalidCSV indicates that there is something wrong with the provided Image Data.
26
20
  class InvalidImageData < StandardError; end
27
21
 
28
22
  # Class InvalidViewingDirection indicates that the direction provided was not a valid viewing direction.
29
23
  class InvalidViewingDirection < InvalidImageData; end
30
-
24
+
31
25
  # Class MultiplePrimaryImages indicates that multiple images were tagged as primary for a given manifest.
32
26
  class MultiplePrimaryImages < InvalidImageData; end
33
27
 
34
28
  # Class NoMasterError indicates that all of the images in a collection are secondary images.
35
29
  class NoMasterError < InvalidImageData; end
36
30
  end
37
- end
31
+ end
@@ -1,20 +1,15 @@
1
-
2
- require "mini_magick"
1
+ require 'mini_magick'
3
2
  require 'fileutils'
4
3
 
5
- module IiifS3
6
-
7
- #
4
+ module WaxIiif
8
5
  # Class FullImage is a standard image variant that does not resize the image at all.
9
6
  class FullImage < ImageVariant
10
-
11
7
  protected
12
8
 
13
9
  def filestring
14
- "/full/full/0"
10
+ '/full/full/0'
15
11
  end
16
12
 
17
13
  def resize(width); end
18
-
19
14
  end
20
15
  end
@@ -0,0 +1,89 @@
1
+ module WaxIiif
2
+ # Class ImageInfo is a data object for the JSON representation of the image.
3
+ #
4
+ # It is designed to support the http://iiif.io/api/image/2.0/#image-information spec.
5
+ class ImageInfo
6
+ attr_accessor :id
7
+ attr_accessor :width
8
+ attr_accessor :height
9
+ attr_accessor :tile_width
10
+ attr_accessor :tile_scale_factors
11
+
12
+ def initialize(uri, variants, tile_width = nil, tile_scale_factors = nil)
13
+ raise WaxIiif::Error::InvalidImageData, "No full variant provided: variants: #{variants}" unless variants['full']
14
+ raise WaxIiif::Error::InvalidImageData, "No thumbnail variant provided: variants: #{variants}" unless variants['thumbnail']
15
+ raise WaxIiif::Error::InvalidImageData, 'No URI was provided for this image!' if uri.nil?
16
+
17
+ @id = uri
18
+ full = variants['full']
19
+ @variants = variants
20
+ @width = full.width
21
+ @height = full.height
22
+ @tile_width = tile_width
23
+ @tile_scale_factors = tile_scale_factors
24
+ end
25
+
26
+ # @return [Hash] a collection of valid sizes based on the available image variants
27
+ #
28
+ def sizes
29
+ @variants.collect do |_name, obj|
30
+ { 'width' => obj.width, 'height' => obj.height }
31
+ end
32
+ end
33
+
34
+ # The hash of tile information, or nil if the information does not exist.
35
+ #
36
+ # @return [Hash, nil] A hash of the tile metadata properly formatted for IIIF JSON.
37
+ #
38
+ def tiles
39
+ return nil if @tile_scale_factors.nil? || @tile_scale_factors.empty?
40
+
41
+ [{
42
+ 'width' => @tile_width,
43
+ 'scaleFactors' => @tile_scale_factors
44
+ }]
45
+ end
46
+
47
+ # Generate the JSON data for this image in the IIIF-expected format.
48
+ #
49
+ # @return [String] the JSON representation of this image
50
+ #
51
+ def to_json
52
+ obj = {
53
+ '@context' => context,
54
+ '@id' => id,
55
+ 'protocol' => protocol,
56
+ 'width' => width,
57
+ 'height' => height,
58
+ 'sizes' => sizes,
59
+ 'profile' => profile
60
+ }
61
+ obj['tiles'] = tiles unless tiles.nil?
62
+ obj['profile'] = profile
63
+ obj['service'] = service unless service.nil?
64
+ JSON.pretty_generate obj
65
+ end
66
+
67
+ # @return [String] The IIIF context for this image
68
+ def context
69
+ WaxIiif::IMAGE_CONTEXT
70
+ end
71
+
72
+ # @return [String] The IIIF protocol for this image
73
+ def protocol
74
+ WaxIiif::IMAGE_PROTOCOL
75
+ end
76
+
77
+ # @return [String] The IIIF profile this image supports
78
+ def profile
79
+ [WaxIiif::LEVEL_0, {
80
+ supports: %w[cors sizeByWhListed baseUriRedirect]
81
+ }]
82
+ end
83
+
84
+ # TODO: Implement this. See <http://iiif.io/api/annex/services/#physical-dimensions>
85
+ def service
86
+ nil
87
+ end
88
+ end
89
+ end
@@ -1,16 +1,17 @@
1
- module IiifS3
1
+ module WaxIiif
2
2
  # Class ImageRecord provides a data structure for a single image file.
3
3
  # It contains information for content from the manifest level down to the
4
- # specific variants of the images.
5
- #
4
+ # specific variants of the images.
5
+ #
6
6
  # It has the concept of primary images, which are the first (or only) image
7
- # in the sequence. This is the image where much of the top-level metadata is
8
- # taken from. Each sequence can only have a single primary image, but that
9
- # constraint in enforced
7
+ # in the sequence. This is the image where much of the top-level metadata is
8
+ # taken from. Each sequence can only have a single primary image, but that
9
+ # constraint isnt enforced
10
10
  #
11
11
  # @author David Newbury <david.newbury@gmail.com>
12
12
  #
13
13
  class ImageRecord
14
+ attr_accessor :manifest_id
14
15
  attr_accessor :id
15
16
  attr_accessor :label
16
17
  attr_accessor :description
@@ -20,32 +21,25 @@ module IiifS3
20
21
 
21
22
  attr_accessor :logo
22
23
  attr_accessor :variants
23
-
24
- attr_writer :page_number
24
+
25
25
  attr_writer :section
26
26
  attr_writer :section_label
27
27
  attr_writer :is_document
28
-
29
- # @param [Hash] opts
30
- # @option opts [String] :id The primary ID for the object.
28
+
29
+ # @param [Hash] opts
30
+
31
31
  # @option opts [String] :label The human-readable label for all grouped records
32
32
  # @option opts [String] :description A longer, human-readable description of the gropued records
33
33
  # @option opts [String] :logo A URL pointing to a logo of the institution
34
34
  # @option opts [Hash] :variants A hash of derivative names and sizes
35
- # @example {thumb: 150}
36
- def initialize(opts={})
35
+ #
36
+ # @example {thumb: 150}
37
+ def initialize(opts = {})
37
38
  opts.each do |key, val|
38
- self.send("#{key}=",val) if self.methods.include? "#{key}=".to_sym
39
+ self.send("#{key}=", val) if self.methods.include? "#{key}=".to_sym
39
40
  end
40
41
  end
41
42
 
42
- # The page number of this image. Defaults to 1.
43
- #
44
- # @return [Number]
45
- def page_number
46
- @page_number || 1
47
- end
48
-
49
43
  # The path to this image.
50
44
  #
51
45
  # @return [String]
@@ -53,89 +47,80 @@ module IiifS3
53
47
  @path
54
48
  end
55
49
 
56
- def path=(_path)
57
- raise IiifS3::Error::InvalidImageData, "Path is invalid: '#{_path}'" unless _path && File.exist?(_path)
58
- @path = _path
50
+ def path=(path)
51
+ raise WaxIiif::Error::InvalidImageData, "Path is invalid: '#{path}'" unless path && File.exist?(path)
52
+ @path = path
59
53
  end
60
54
 
61
- # Is this image part of a document, or is it a standalone image (or image sequence)?
62
- #
63
- # Currently, the only effects the page viewing hint for the image sequence.
64
- # This will only have an effect on the primary image for this sequence.
55
+ # The name of the section this image is contained in.
56
+ # Currently used to id the canvas for this image.
65
57
  #
66
- # @return [Bool]
67
- #
68
- def is_document
69
- return !!@is_document
70
- end
71
- alias :is_document? :is_document
72
-
73
- # The name of the section this image is contained in.
74
- # Currently used to id the canvas for this image.
75
- #
76
- # defaults to IiifS3::DEFAULT_CANVAS_LABEL
58
+ # defaults to WaxIiif::DEFAULT_CANVAS_LABEL
77
59
  #
78
60
  # @return [String]
79
- #
61
+ #
80
62
  def section
81
63
  @section || DEFAULT_CANVAS_LABEL
82
64
  end
83
65
 
84
- # The label for the section this image is contained in.
85
- # Currently used to label the canvas for this image.
66
+ # The label for the section this image is contained in.
67
+ # Currently used to label the canvas for this image.
68
+ #
69
+ # defaults to WaxIiif::DEFAULT_CANVAS_LABEL
86
70
  #
87
- # defaults to IiifS3::DEFAULT_CANVAS_LABEL
71
+ # @return [String]
88
72
  #
89
- # @return [String]
90
- #
91
73
  def section_label
92
74
  @section_label || DEFAULT_CANVAS_LABEL
93
75
  end
94
76
 
95
77
  # @return [String] The prefered viewing direction for this image.
96
- # Will default to IiifS3::DEFAULT_VIEWING_DIRECTION
97
- #
78
+ # Will default to WaxIiif::DEFAULT_VIEWING_DIRECTION
79
+ #
98
80
  def viewing_direction
99
81
  @viewing_direction || DEFAULT_VIEWING_DIRECTION
100
82
  end
101
83
 
102
84
  def viewing_direction=(dir)
103
- raise Error::InvalidViewingDirection unless IiifS3.is_valid_viewing_direction(dir)
104
- @viewing_direction = dir
85
+ raise Error::InvalidViewingDirection unless WaxIiif.valid_viewing_direction?(dir)
86
+ @viewing_direction = dir
87
+ end
88
+
89
+ # Is this image part of a document, or is it a standalone image (or image sequence)?
90
+ #
91
+ # Currently, the only effects the page viewing hint for the image sequence.
92
+ # This will only have an effect on the primary image for this sequence.
93
+ #
94
+ # @return [Bool]
95
+ #
96
+ def document?
97
+ !!@is_document
105
98
  end
106
99
 
107
100
  # Is this image the master image for its sequence?
108
101
  #
109
102
  # Each image sequence has a single image chosen as the primary image for
110
103
  # the sequence. By default, page one is the master image, but another image
111
- # could be chosen as the master if desired.
112
- #
104
+ # could be chosen as the master if desired.
105
+ #
113
106
  # This is, for instance, the image whose thumbnail is the representation for
114
107
  # the entire sequence, and it defined viewing direction and other top-level
115
108
  # metadata.
116
109
  #
117
110
  # @return [Bool]
118
111
  #
119
- def is_primary
120
- if @is_primary.nil?
121
- self.page_number == 1
122
- else
123
- @is_primary
124
- end
112
+ def primary?
113
+ !!@is_primary
125
114
  end
126
115
 
127
- alias :is_primary? :is_primary
128
- alias :is_master :is_primary # Depriciated, but around for backwards compatibility
129
-
130
-
131
116
  # Set this image record as the master record for the sequence
132
117
  #
133
118
  # @param [Bool] val Is this image the master
134
119
  #
135
120
  # @return [Bool]
136
- #
121
+ #
137
122
  def is_primary=(val)
138
123
  @is_primary = !!val
139
124
  end
140
125
  end
141
- end
126
+ end