Class: TTY::File::DownloadFile
- Inherits:
-
Object
- Object
- TTY::File::DownloadFile
- Defined in:
- lib/tty/file/download_file.rb
Constant Summary collapse
- DEFAULT_REDIRECTS =
3
Instance Attribute Summary collapse
-
#dest_path ⇒ Object
readonly
Returns the value of attribute dest_path.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#call ⇒ Object
Download a file.
-
#initialize(url, dest_path, limit: nil) ⇒ DownloadFile
constructor
A new instance of DownloadFile.
Constructor Details
#initialize(url, dest_path, limit: nil) ⇒ DownloadFile
Returns a new instance of DownloadFile.
17 18 19 20 21 |
# File 'lib/tty/file/download_file.rb', line 17 def initialize(url, dest_path, limit: nil) @uri = URI.parse(url) @dest_path = dest_path @limit = limit || DEFAULT_REDIRECTS end |
Instance Attribute Details
#dest_path ⇒ Object (readonly)
Returns the value of attribute dest_path.
11 12 13 |
# File 'lib/tty/file/download_file.rb', line 11 def dest_path @dest_path end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
11 12 13 |
# File 'lib/tty/file/download_file.rb', line 11 def limit @limit end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
11 12 13 |
# File 'lib/tty/file/download_file.rb', line 11 def uri @uri end |
Instance Method Details
#call ⇒ Object
Download a file
26 27 28 |
# File 'lib/tty/file/download_file.rb', line 26 def call download(uri, dest_path, limit) end |