Class: Pulse::Downloader::Client
- Inherits:
-
Object
- Object
- Pulse::Downloader::Client
- Includes:
- FileChecker, FileDownloader, WebPageParser
- Defined in:
- lib/pulse/downloader/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#drop_exitsing_files_in_path ⇒ Object
readonly
Returns the value of attribute drop_exitsing_files_in_path.
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#file_type ⇒ Object
readonly
Returns the value of attribute file_type.
-
#progress_bar ⇒ Object
readonly
Returns the value of attribute progress_bar.
-
#read_from_save_path ⇒ Object
readonly
Returns the value of attribute read_from_save_path.
-
#report_time ⇒ Object
readonly
Returns the value of attribute report_time.
-
#save_and_dont_return ⇒ Object
readonly
Returns the value of attribute save_and_dont_return.
-
#save_data ⇒ Object
readonly
Returns the value of attribute save_data.
-
#save_path ⇒ Object
readonly
Returns the value of attribute save_path.
-
#scrape_images ⇒ Object
readonly
Returns the value of attribute scrape_images.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#verify_ssl ⇒ Object
readonly
Returns the value of attribute verify_ssl.
Instance Method Summary collapse
- #call ⇒ Object
- #call! ⇒ Object
-
#initialize(url:, file_type:, scrape_images: false, save_data: false, save_path: '', read_from_save_path: false, verify_ssl: true, drop_exitsing_files_in_path: false, save_and_dont_return: true, report_time: false, progress_bar: false) ⇒ Client
constructor
TODO: Validation TODO: Retry TODO: DNS TODO: Multiple filetypes TODO: lib/pulse/downloader/file_downloader.rb:13: warning: URI.escape is obsolete.
- #valid? ⇒ Boolean
Methods included from FileDownloader
#compute_hash_of, #download, #fetch_save_paths
Methods included from FileChecker
Methods included from WebPageParser
Constructor Details
#initialize(url:, file_type:, scrape_images: false, save_data: false, save_path: '', read_from_save_path: false, verify_ssl: true, drop_exitsing_files_in_path: false, save_and_dont_return: true, report_time: false, progress_bar: false) ⇒ Client
TODO: Validation TODO: Retry TODO: DNS TODO: Multiple filetypes TODO: lib/pulse/downloader/file_downloader.rb:13: warning: URI.escape is obsolete
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pulse/downloader/client.rb', line 32 def initialize(url:, file_type:, scrape_images: false, save_data: false, save_path: '', read_from_save_path: false, verify_ssl: true, drop_exitsing_files_in_path: false, save_and_dont_return: true, report_time: false, progress_bar: false) @url = url @file_type = file_type @scrape_images = scrape_images @save_data = save_data @save_path = save_path @read_from_save_path = read_from_save_path @verify_ssl = verify_ssl @drop_exitsing_files_in_path = drop_exitsing_files_in_path @save_and_dont_return = save_and_dont_return @report_time = report_time @progress_bar = @base_url = get_base_url end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def base_url @base_url end |
#drop_exitsing_files_in_path ⇒ Object (readonly)
Returns the value of attribute drop_exitsing_files_in_path.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def drop_exitsing_files_in_path @drop_exitsing_files_in_path end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def end_time @end_time end |
#file_type ⇒ Object (readonly)
Returns the value of attribute file_type.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def file_type @file_type end |
#progress_bar ⇒ Object (readonly)
Returns the value of attribute progress_bar.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def @progress_bar end |
#read_from_save_path ⇒ Object (readonly)
Returns the value of attribute read_from_save_path.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def read_from_save_path @read_from_save_path end |
#report_time ⇒ Object (readonly)
Returns the value of attribute report_time.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def report_time @report_time end |
#save_and_dont_return ⇒ Object (readonly)
Returns the value of attribute save_and_dont_return.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def save_and_dont_return @save_and_dont_return end |
#save_data ⇒ Object (readonly)
Returns the value of attribute save_data.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def save_data @save_data end |
#save_path ⇒ Object (readonly)
Returns the value of attribute save_path.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def save_path @save_path end |
#scrape_images ⇒ Object (readonly)
Returns the value of attribute scrape_images.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def scrape_images @scrape_images end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def start_time @start_time end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def url @url end |
#verify_ssl ⇒ Object (readonly)
Returns the value of attribute verify_ssl.
9 10 11 |
# File 'lib/pulse/downloader/client.rb', line 9 def verify_ssl @verify_ssl end |
Instance Method Details
#call ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pulse/downloader/client.rb', line 63 def call return false unless valid? if @progress_bar @progress_bar = ::ProgressBar.new(fetch_file_paths.size) end fetch_file_paths.map do |file_path| download(file_path, @progress_bar) @progress_bar.increment! end end |
#call! ⇒ Object
59 60 61 |
# File 'lib/pulse/downloader/client.rb', line 59 def call! call end |
#valid? ⇒ Boolean
76 77 78 |
# File 'lib/pulse/downloader/client.rb', line 76 def valid? true # TODO end |