Class: Neo4j::RakeTasks::Download
- Inherits:
-
Object
- Object
- Neo4j::RakeTasks::Download
- Defined in:
- lib/neo4j/rake_tasks/download.rb
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #fetch(message) ⇒ Object
-
#initialize(url) ⇒ Download
constructor
A new instance of Download.
Constructor Details
#initialize(url) ⇒ Download
Returns a new instance of Download.
7 8 9 |
# File 'lib/neo4j/rake_tasks/download.rb', line 7 def initialize(url) @url = url end |
Instance Method Details
#exists? ⇒ Boolean
11 12 13 14 |
# File 'lib/neo4j/rake_tasks/download.rb', line 11 def exists? status = head(@url).code.to_i (200...300).cover?(status) end |
#fetch(message) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/neo4j/rake_tasks/download.rb', line 16 def fetch() require 'open-uri' open(@url, content_length_proc: lambda do |total| (, total) if total && total > 0 end, progress_proc: method(:update_progress_bar)).read end |