Class: Riiif::AbstractFileSystemResolver

Inherits:
Object
  • Object
show all
Extended by:
Deprecation
Defined in:
app/resolvers/riiif/abstract_file_system_resolver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_path: nil) ⇒ AbstractFileSystemResolver

Returns a new instance of AbstractFileSystemResolver.



6
7
8
# File 'app/resolvers/riiif/abstract_file_system_resolver.rb', line 6

def initialize(base_path: nil)
  @base_path = base_path
end

Instance Attribute Details

#base_pathObject

Returns the value of attribute base_path.



4
5
6
# File 'app/resolvers/riiif/abstract_file_system_resolver.rb', line 4

def base_path
  @base_path
end

Instance Method Details

#find(id) ⇒ Object



10
11
12
# File 'app/resolvers/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.

Parameters:

  • id (String)

    the id to resolve

Returns:

  • the path of the file



16
17
18
19
# File 'app/resolvers/riiif/abstract_file_system_resolver.rb', line 16

def path(id)
  search = pattern(id)
  search && Dir.glob(search).first || raise(ImageNotFoundError, search)
end

#pattern(_id) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'app/resolvers/riiif/abstract_file_system_resolver.rb', line 21

def pattern(_id)
  raise NotImplementedError, "Implement `pattern(id)' in the concrete class"
end