class WaxIiif::Config

Config provides a data structure for holding the configuration settings for the WaxIiif class.

@author David Newbury <david.newbury@gmail.com>

Constants

DEFAULT_COLLECTION_LABEL

@return [String] The default collection label ~> `collection/{LABEL}.json`

DEFAULT_IMAGE_DIRECTORY_NAME

@return [String] The name of the subdirectory where generated images live

DEFAULT_OUTPUT_DIRECTORY

@return [String] The default path for writing generated image files

DEFAULT_THUMBNAIL_SIZE

@return [Number] The default thumbnail size in pixels

DEFAULT_TILE_SCALE_FACTORS

@return [Array<Number>] The default tile scaling factors

DEFAULT_TILE_WIDTH

@return [Number] The default tile width/height in pixels

DEFAULT_URL

@return [String] The default URL to append to all IDs.

Attributes

base_url[R]

@!attribute [r] base_url @return [String] The protocol, domain, and port used for generating URIs.

Defaults to {WaxIiif::Config::DEFAULT_URL}
collection_label[R]

@!attribute [r] collection_label @return [String] the label for the collection

image_directory_name[R]

@!attribute [r] image_directory_name @return [String] The name of the directory/prefix where image files will be

located.
Defaults to WaxIiif::Config::DEFAULT_IMAGE_DIRECTORY_NAME
output_dir[R]

@!attribute [r] output_dir @return [String] The directory on the local file system where the output

files should be saved
Defaults to {WaxIiif::Config::DEFAULT_OUTPUT_DIRECTORY}
prefix[R]

@!attribute [r] prefix @return [String] A prefix to be appended between the base URI and the id.

  Can be blank,and it will automatically prepend a slash if one is not
  provided.
Defaults to ''
thumbnail_size[R]

@!attribute [r] thumbnail_size @return [Number] The max width in pixels for a thumbnail image

tile_scale_factors[R]

@!attribute [r] tile @return [Array<Number>] An array of tile ratios to be uploaded.

Defaults to WaxIiif::Config::DEFAULT_TILE_SCALE_FACTORS
tile_width[R]

@!attribute [r] tile_width @return [Number] The width (and height) of each individual tile.

Defaults to WaxIiif::Config::DEFAULT_TILE_WIDTH
use_extensions[R]

@!attribute [r] use_extensions @return [Boolean] Should generated IDs and files have a .json extension?

Defaults to true
variants[R]

@!attribute [r] variants @return [Hash] A Hash of key/value pairs. Each key should be the name of a variant,

each value the maximum pixel dimension of the longest side.
Defaults to {}
verbose[R]

@!attribute [r] verbose @return [Bool] Should the program log information to the console?

verbose?[R]

@!attribute [r] verbose @return [Bool] Should the program log information to the console?

Public Class Methods

new(opts = {}) click to toggle source

Initialize a new configuration option.

@param [Hash] opts @option opts [Number] :tile_width The width in pixels for generated tiles.

Defaults to {DEFAULT_TILE_WIDTH}

@option opts [Array<Number>] :tile_scale_factors An array of ratios for generated tiles.

Defaults to {DEFAULT_TILE_SCALE_FACTORS}

@option opts [String] :image_directory_name The name of the subdirectory for actual

image data. Defaults to {DEFAULT_IMAGE_DIRECTORY_NAME}

@option opts [String] :output_dir The name of the directory for generated files.

image data. Defaults to {DEFAULT_OUTPUT_DIRECTORY}

@option opts [String] :base_url The base URL for the generated URIs. Defaults to

{DEFAULT_URL}

@option opts [Number] :thumbnail_size the size in pixels

for the largest side of the thumbnail images.  Defaults to {DEFAULT_THUMBNAIL_SIZE}.

@option opts [Bool] :use_extensions (true) should files have exensions appended? @option opts [Bool] :verbose (false) Should debug information be printed to the console? @option opts [String] :prefix ('') a prefix (read: subdirectory) for the generated URIs. @option opts [Hash{String: String}] :variants

# File lib/wax_iiif/config.rb, line 100
def initialize(opts = {})
  @tile_width           = opts[:tile_width]           || DEFAULT_TILE_WIDTH
  @tile_scale_factors   = opts[:tile_scale_factors]   || DEFAULT_TILE_SCALE_FACTORS
  @image_directory_name = opts[:image_directory_name] || DEFAULT_IMAGE_DIRECTORY_NAME
  @base_url             = opts[:base_url]             || DEFAULT_URL
  @collection_label     = opts[:collection_label]     || DEFAULT_COLLECTION_LABEL
  @use_extensions       = opts.fetch(:use_extensions, true) ## true
  @output_dir           = opts[:output_dir]           || DEFAULT_OUTPUT_DIRECTORY
  @variants             = opts[:variants]             || {}
  @thumbnail_size       = opts[:thumbnail_size]       || DEFAULT_THUMBNAIL_SIZE
  @verbose              = opts.fetch(:verbose, false) ## false
  @prefix               = opts[:prefix] || ''
  @prefix               = "/#{@prefix}" if @prefix.length.positive? && @prefix[0] != '/'
end

Public Instance Methods

==(other) click to toggle source

Compare two configuration files

@param [WaxIiif::Config] other_config The configuration file to compare @return [Bool] True if they are the same, false otherwise

# File lib/wax_iiif/config.rb, line 120
def ==(other)
  valid = true
  self.instance_variables.each do |v|
    valid &&= instance_variable_get(v) == other.instance_variable_get(v)
  end
  valid
end