Class: TTY::File::DownloadFile

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/file/download_file.rb

Constant Summary collapse

DEFAULT_REDIRECTS =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject (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

#limitObject (readonly)

Returns the value of attribute limit.



11
12
13
# File 'lib/tty/file/download_file.rb', line 11

def limit
  @limit
end

#uriObject (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

#callObject

Download a file



26
27
28
# File 'lib/tty/file/download_file.rb', line 26

def call
  download(uri, dest_path, limit)
end