Class: AIPP::Downloader::File
- Inherits:
-
Object
- Object
- AIPP::Downloader::File
- Defined in:
- lib/aipp/downloader/file.rb
Overview
Local file
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #fetch_to(path) ⇒ Object
- #fetched_file ⇒ Object
-
#initialize(archive: nil, file:, type: nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(archive: nil, file:, type: nil) ⇒ File
Returns a new instance of File.
8 9 10 11 |
# File 'lib/aipp/downloader/file.rb', line 8 def initialize(archive: nil, file:, type: nil) @archive = Pathname(archive) if archive @file, @type = Pathname(file), type&.to_s end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/aipp/downloader/file.rb', line 6 def file @file end |
Instance Method Details
#fetch_to(path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aipp/downloader/file.rb', line 13 def fetch_to(path) path.join(fetched_file).tap do |target| if @archive fail NotFoundError unless @archive.exist? extract(file, from: @archive, as: target) else fail NotFoundError unless file.exist? FileUtils.cp(file, target) end end self end |
#fetched_file ⇒ Object
26 27 28 |
# File 'lib/aipp/downloader/file.rb', line 26 def fetched_file [name, type].join('.') end |