Class: IiifS3::Config
- Inherits:
-
Object
- Object
- IiifS3::Config
- Defined in:
- lib/iiif_s3/config.rb
Overview
Config provides a data structure for holding the configuration settings for the IiifS3 class.
Constant Summary collapse
- DEFAULT_URL =
Returns The default URL to append to all IDs.
"http://0.0.0.0"- DEFAULT_IMAGE_DIRECTORY_NAME =
Returns The name of the subdirectory where generated images live.
"images"- DEFAULT_OUTPUT_DIRECTORY =
Returns The default path for writing generated image files.
"./build"- 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]
- DEFAULT_THUMBNAIL_SIZE =
Returns The default thumbnail size in pixels.
250
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#image_directory_name ⇒ Object
readonly
Returns the value of attribute image_directory_name.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#s3 ⇒ Object
readonly
Returns the value of attribute s3.
-
#thumbnail_size ⇒ Object
readonly
Returns the value of attribute thumbnail_size.
-
#tile ⇒ Array<Number>
readonly
Defaults to IiifS3::Config::DEFAULT_TILE_SCALE_FACTORS.
-
#tile_scale_factors ⇒ Object
readonly
Returns the value of attribute tile_scale_factors.
-
#tile_width ⇒ Object
readonly
Returns the value of attribute tile_width.
-
#upload_to_s3 ⇒ Object
readonly
Returns the value of attribute upload_to_s3.
-
#use_extensions ⇒ Object
readonly
Returns the value of attribute use_extensions.
-
#variants ⇒ Object
readonly
Returns the value of attribute variants.
-
#verbose ⇒ Object
(also: #verbose?)
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#==(other_config) ⇒ Bool
Compare two configuration files.
-
#initialize(opts = {}) ⇒ Config
constructor
Initialize a new configuration option.
Constructor Details
#initialize(opts = {}) ⇒ Config
Initialize a new configuration option.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/iiif_s3/config.rb', line 109 def initialize(opts = {}) @upload_to_s3 = opts[:upload_to_s3] || false @s3 = IiifS3::AmazonS3.new if @upload_to_s3 @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] || ( @upload_to_s3 ? @s3.bucket.url : DEFAULT_URL) @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] || "" if @prefix.length > 0 && @prefix[0] != "/" @prefix = "/#{@prefix}" end end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
27 28 29 |
# File 'lib/iiif_s3/config.rb', line 27 def base_url @base_url end |
#image_directory_name ⇒ Object (readonly)
Returns the value of attribute image_directory_name.
51 52 53 |
# File 'lib/iiif_s3/config.rb', line 51 def image_directory_name @image_directory_name end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
38 39 40 |
# File 'lib/iiif_s3/config.rb', line 38 def output_dir @output_dir end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
45 46 47 |
# File 'lib/iiif_s3/config.rb', line 45 def prefix @prefix end |
#s3 ⇒ Object (readonly)
Returns the value of attribute s3.
85 86 87 |
# File 'lib/iiif_s3/config.rb', line 85 def s3 @s3 end |
#thumbnail_size ⇒ Object (readonly)
Returns the value of attribute thumbnail_size.
76 77 78 |
# File 'lib/iiif_s3/config.rb', line 76 def thumbnail_size @thumbnail_size end |
#tile ⇒ Array<Number> (readonly)
Defaults to IiifS3::Config::DEFAULT_TILE_SCALE_FACTORS
61 |
# File 'lib/iiif_s3/config.rb', line 61 attr_reader :tile_scale_factors |
#tile_scale_factors ⇒ Object (readonly)
Returns the value of attribute tile_scale_factors.
61 62 63 |
# File 'lib/iiif_s3/config.rb', line 61 def tile_scale_factors @tile_scale_factors end |
#tile_width ⇒ Object (readonly)
Returns the value of attribute tile_width.
56 57 58 |
# File 'lib/iiif_s3/config.rb', line 56 def tile_width @tile_width end |
#upload_to_s3 ⇒ Object (readonly)
Returns the value of attribute upload_to_s3.
72 73 74 |
# File 'lib/iiif_s3/config.rb', line 72 def upload_to_s3 @upload_to_s3 end |
#use_extensions ⇒ Object (readonly)
Returns the value of attribute use_extensions.
32 33 34 |
# File 'lib/iiif_s3/config.rb', line 32 def use_extensions @use_extensions end |
#variants ⇒ Object (readonly)
Returns the value of attribute variants.
67 68 69 |
# File 'lib/iiif_s3/config.rb', line 67 def variants @variants end |
#verbose ⇒ Object (readonly) Also known as: verbose?
Returns the value of attribute verbose.
80 81 82 |
# File 'lib/iiif_s3/config.rb', line 80 def verbose @verbose end |
Instance Method Details
#==(other_config) ⇒ Bool
Compare two configuration files
134 135 136 137 138 139 140 |
# File 'lib/iiif_s3/config.rb', line 134 def ==(other_config) valid = true self.instance_variables.each do |v| valid &&= instance_variable_get(v) == other_config.instance_variable_get(v) end valid end |