Class: Arxiv::Downloader::AssetsCache
- Inherits:
-
Object
- Object
- Arxiv::Downloader::AssetsCache
- Defined in:
- lib/arxiv/downloader/assets_cache.rb
Constant Summary collapse
- SHARED_DIR =
'_shared'.freeze
Instance Method Summary collapse
- #fetch(url) ⇒ Object
-
#initialize(root:, client:) ⇒ AssetsCache
constructor
A new instance of AssetsCache.
Constructor Details
#initialize(root:, client:) ⇒ AssetsCache
Returns a new instance of AssetsCache.
9 10 11 12 |
# File 'lib/arxiv/downloader/assets_cache.rb', line 9 def initialize root:, client: @root = root @client = client end |
Instance Method Details
#fetch(url) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/arxiv/downloader/assets_cache.rb', line 14 def fetch url path = local_path_for url return path if File.exist? path FileUtils.mkdir_p File.dirname(path) File.binwrite path, @client.get(url).to_s path end |