Class: WaxIiif::Config
- Inherits:
-
Object
- Object
- WaxIiif::Config
- Defined in:
- lib/wax_iiif/config.rb
Overview
Config provides a data structure for holding the configuration settings for the WaxIiif class.
Constant Summary collapse
- DEFAULT_URL =
Returns The default URL to append to all IDs.
'http://0.0.0.0'.freeze
- DEFAULT_IMAGE_DIRECTORY_NAME =
Returns The name of the subdirectory where generated images live.
'images'.freeze
- DEFAULT_OUTPUT_DIRECTORY =
Returns The default path for writing generated image files.
'./build'.freeze
- DEFAULT_TILE_WIDTH =
Returns The default tile width/height in pixels.
512- DEFAULT_TILE_SCALE_FACTORS =
Returns The default tile scaling factors.
[1, 2, 4, 8].freeze
- DEFAULT_THUMBNAIL_SIZE =
Returns The default thumbnail size in pixels.
250- DEFAULT_COLLECTION_LABEL =
Returns The default collection label ~> ‘collection/LABEL.json`.
'top'.freeze
Instance Attribute Summary collapse
-
#base_url ⇒ String
readonly
The protocol, domain, and port used for generating URIs.
-
#collection_label ⇒ String
readonly
The label for the collection.
-
#image_directory_name ⇒ String
readonly
The name of the directory/prefix where image files will be located.
-
#output_dir ⇒ String
readonly
The directory on the local file system where the output files should be saved Defaults to DEFAULT_OUTPUT_DIRECTORY.
-
#prefix ⇒ String
readonly
Defaults to ”.
-
#thumbnail_size ⇒ Number
readonly
The max width in pixels for a thumbnail image.
-
#tile ⇒ Array<Number>
readonly
An array of tile ratios to be uploaded.
-
#tile_scale_factors ⇒ Array<Number>
readonly
An array of tile ratios to be uploaded.
-
#tile_width ⇒ Number
readonly
The width (and height) of each individual tile.
-
#use_extensions ⇒ Boolean
readonly
Should generated IDs and files have a .json extension? Defaults to true.
-
#variants ⇒ Hash
readonly
A Hash of key/value pairs.
-
#verbose ⇒ Bool
(also: #verbose?)
readonly
Should the program log information to the console?.
Instance Method Summary collapse
-
#==(other) ⇒ Bool
Compare two configuration files.
-
#initialize(opts = {}) ⇒ Config
constructor
Initialize a new configuration option.
Constructor Details
#initialize(opts = {}) ⇒ Config
Initialize a new configuration option.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# 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 |
Instance Attribute Details
#base_url ⇒ String (readonly)
Returns The protocol, domain, and port used for generating URIs. Defaults to DEFAULT_URL.
26 27 28 |
# File 'lib/wax_iiif/config.rb', line 26 def base_url @base_url end |
#collection_label ⇒ String (readonly)
Returns the label for the collection.
74 75 76 |
# File 'lib/wax_iiif/config.rb', line 74 def collection_label @collection_label end |
#image_directory_name ⇒ String (readonly)
Returns The name of the directory/prefix where image files will be located. Defaults to WaxIiif::Config::DEFAULT_IMAGE_DIRECTORY_NAME.
50 51 52 |
# File 'lib/wax_iiif/config.rb', line 50 def image_directory_name @image_directory_name end |
#output_dir ⇒ String (readonly)
Returns The directory on the local file system where the output files should be saved Defaults to DEFAULT_OUTPUT_DIRECTORY.
37 38 39 |
# File 'lib/wax_iiif/config.rb', line 37 def output_dir @output_dir end |
#prefix ⇒ String (readonly)
Defaults to ”
44 45 46 |
# File 'lib/wax_iiif/config.rb', line 44 def prefix @prefix end |
#thumbnail_size ⇒ Number (readonly)
Returns The max width in pixels for a thumbnail image.
70 71 72 |
# File 'lib/wax_iiif/config.rb', line 70 def thumbnail_size @thumbnail_size end |
#tile ⇒ Array<Number> (readonly)
Returns An array of tile ratios to be uploaded. Defaults to WaxIiif::Config::DEFAULT_TILE_SCALE_FACTORS.
60 |
# File 'lib/wax_iiif/config.rb', line 60 attr_reader :tile_scale_factors |
#tile_scale_factors ⇒ Array<Number> (readonly)
Returns An array of tile ratios to be uploaded. Defaults to WaxIiif::Config::DEFAULT_TILE_SCALE_FACTORS.
60 61 62 |
# File 'lib/wax_iiif/config.rb', line 60 def tile_scale_factors @tile_scale_factors end |
#tile_width ⇒ Number (readonly)
Returns The width (and height) of each individual tile. Defaults to WaxIiif::Config::DEFAULT_TILE_WIDTH.
55 56 57 |
# File 'lib/wax_iiif/config.rb', line 55 def tile_width @tile_width end |
#use_extensions ⇒ Boolean (readonly)
Returns Should generated IDs and files have a .json extension? Defaults to true.
31 32 33 |
# File 'lib/wax_iiif/config.rb', line 31 def use_extensions @use_extensions end |
#variants ⇒ Hash (readonly)
Returns 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 {}.
66 67 68 |
# File 'lib/wax_iiif/config.rb', line 66 def variants @variants end |
#verbose ⇒ Bool (readonly) Also known as: verbose?
Returns Should the program log information to the console?.
78 79 80 |
# File 'lib/wax_iiif/config.rb', line 78 def verbose @verbose end |
Instance Method Details
#==(other) ⇒ Bool
Compare two configuration files
120 121 122 123 124 125 126 |
# 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 |