Class: Arxiv::Downloader::SourceArchive
- Inherits:
-
Object
- Object
- Arxiv::Downloader::SourceArchive
- Defined in:
- lib/arxiv/downloader/source_archive.rb
Instance Method Summary collapse
- #download(to:) ⇒ Object
-
#initialize(identifier, client:) ⇒ SourceArchive
constructor
A new instance of SourceArchive.
Constructor Details
#initialize(identifier, client:) ⇒ SourceArchive
Returns a new instance of SourceArchive.
9 10 11 12 |
# File 'lib/arxiv/downloader/source_archive.rb', line 9 def initialize identifier, client: @identifier = identifier @client = client end |
Instance Method Details
#download(to:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/arxiv/downloader/source_archive.rb', line 14 def download to: FileUtils.mkdir_p to body = @client.get(url).to_s Zlib::GzipReader.wrap StringIO.new(body) do |gz| Gem::Package::TarReader.new(gz) do |tar| tar.each { |entry| extract entry, to } end end end |