Class: Riiif::AbstractFileSystemResolver
- Inherits:
-
Object
- Object
- Riiif::AbstractFileSystemResolver
- 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
Returns the value of attribute root.
Instance Method Summary collapse
- #find(id) ⇒ Object
-
#initialize ⇒ AbstractFileSystemResolver
constructor
A new instance of AbstractFileSystemResolver.
-
#path(id) ⇒ Object
The path of the file.
- #pattern(_id) ⇒ Object
Constructor Details
#initialize ⇒ AbstractFileSystemResolver
Returns a new instance of AbstractFileSystemResolver.
5 6 7 8 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 5 def initialize @root = ::File.(::File.join(::File.dirname(__FILE__), '../..')) @base_path = ::File.join(root, 'spec/samples') end |
Instance Attribute Details
#base_path ⇒ Object
Returns the value of attribute base_path.
3 4 5 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 3 def base_path @base_path end |
#root ⇒ Object
Returns the value of attribute root.
3 4 5 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 3 def root @root end |
Instance Method Details
#find(id) ⇒ Object
10 11 12 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 10 def find(id) Riiif::File.new(path(id)) end |
#path(id) ⇒ Object
Returns the path of the file.
16 17 18 19 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 16 def path(id) search = pattern(id) Dir.glob(search).first || raise(ImageNotFoundError, search) end |
#pattern(_id) ⇒ Object
21 22 23 |
# File 'lib/riiif/abstract_file_system_resolver.rb', line 21 def pattern(_id) raise NotImplementedError, "Implement `pattern(id)' in the concrete class" end |