Class: Riiif::HttpFileResolver
- Inherits:
-
Object
- Object
- Riiif::HttpFileResolver
- Defined in:
- app/resolvers/riiif/http_file_resolver.rb
Defined Under Namespace
Classes: RemoteFile
Instance Attribute Summary collapse
-
#basic_auth_credentials ⇒ Object
Returns the value of attribute basic_auth_credentials.
-
#cache_path ⇒ Object
Returns the value of attribute cache_path.
-
#id_to_uri ⇒ Object
Set a lambda that maps the first parameter (id) to a URL Example:.
Instance Method Summary collapse
- #find(id) ⇒ Object
-
#initialize(cache_path: 'tmp/network_files') ⇒ HttpFileResolver
constructor
A new instance of HttpFileResolver.
Constructor Details
#initialize(cache_path: 'tmp/network_files') ⇒ HttpFileResolver
Returns a new instance of HttpFileResolver.
18 19 20 |
# File 'app/resolvers/riiif/http_file_resolver.rb', line 18 def initialize(cache_path: 'tmp/network_files') @cache_path = cache_path end |
Instance Attribute Details
#basic_auth_credentials ⇒ Object
Returns the value of attribute basic_auth_credentials.
15 16 17 |
# File 'app/resolvers/riiif/http_file_resolver.rb', line 15 def basic_auth_credentials @basic_auth_credentials end |
#cache_path ⇒ Object
Returns the value of attribute cache_path.
16 17 18 |
# File 'app/resolvers/riiif/http_file_resolver.rb', line 16 def cache_path @cache_path end |
#id_to_uri ⇒ Object
Set a lambda that maps the first parameter (id) to a URL Example:
resolver = Riiif::HttpFileResolver.new resolver.id_to_uri = lambda do |id|
"http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/#{id}.jpg/600px-#{id}.jpg"
end
14 15 16 |
# File 'app/resolvers/riiif/http_file_resolver.rb', line 14 def id_to_uri @id_to_uri end |
Instance Method Details
#find(id) ⇒ Object
22 23 24 25 26 27 |
# File 'app/resolvers/riiif/http_file_resolver.rb', line 22 def find(id) remote = RemoteFile.new(uri(id), cache_path: cache_path, basic_auth_credentials: basic_auth_credentials) Riiif::File.new(remote.fetch) end |