Class: Riiif::AbstractFileSystemResolver
- Inherits:
-
Object
- Object
- Riiif::AbstractFileSystemResolver
- Extended by:
- Deprecation
- Defined in:
- lib/riiif/abstract_file_system_resolver.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#base_path ⇒ Object
Returns the value of attribute base_path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #default_base_path ⇒ Object
- #find(id) ⇒ Object
-
#initialize(base_path: nil) ⇒ AbstractFileSystemResolver
constructor
A new instance of AbstractFileSystemResolver.
-
#path(id) ⇒ Object
The path of the file.
- #pattern(_id) ⇒ Object
Constructor Details
#initialize(base_path: nil) ⇒ AbstractFileSystemResolver
Returns a new instance of AbstractFileSystemResolver.
6 7 8 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 6 def initialize(base_path: nil) @base_path = base_path || default_base_path end |
Instance Attribute Details
#base_path ⇒ Object
Returns the value of attribute base_path.
4 5 6 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 4 def base_path @base_path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
17 18 19 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 17 def root @root end |
Instance Method Details
#default_base_path ⇒ Object
10 11 12 13 14 15 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 10 def default_base_path Deprecation.warn(self, 'Initializing a file resolver without setting the base path ' \ 'is deprecated and will be removed in Riiif 2.0', caller(2)) @root ||= ::File.(::File.join(::File.dirname(__FILE__), '../..')) ::File.join(@root, 'spec/samples') end |
#find(id) ⇒ Object
20 21 22 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 20 def find(id) Riiif::File.new(path(id)) end |
#path(id) ⇒ Object
Returns the path of the file.
26 27 28 29 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 26 def path(id) search = pattern(id) Dir.glob(search).first || raise(ImageNotFoundError, search) end |
#pattern(_id) ⇒ Object
31 32 33 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 31 def pattern(_id) raise NotImplementedError, "Implement `pattern(id)' in the concrete class" end |