class Pulse::Downloader::Client
Attributes
base_url[R]
drop_exitsing_files_in_path[R]
end_time[R]
file_paths[R]
file_type[R]
folder_urls[R]
headers[R]
progress_bar[R]
read_from_save_path[R]
report_time[R]
save_and_dont_return[R]
save_data[R]
save_path[R]
scrape_images[R]
start_time[R]
traverse_folders[R]
url[R]
verify_ssl[R]
Public Class Methods
new(url:, file_type:, scrape_images: false, save_data: false, save_path: '', read_from_save_path: false, traverse_folders: false, verify_ssl: true, headers: nil, drop_exitsing_files_in_path: false, save_and_dont_return: true, report_time: false, progress_bar: false)
click to toggle source
TODO: Validation TODO: Retry TODO: DNS TODO: lib/pulse/downloader/file_downloader.rb:13: warning: URI.escape is obsolete
# File lib/pulse/downloader/client.rb, line 35 def initialize(url:, file_type:, scrape_images: false, save_data: false, save_path: '', read_from_save_path: false, traverse_folders: false, verify_ssl: true, headers: nil, 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 @traverse_folders = traverse_folders @verify_ssl = verify_ssl @headers = headers @drop_exitsing_files_in_path = drop_exitsing_files_in_path @save_and_dont_return = save_and_dont_return @report_time = report_time @progress_bar = progress_bar @base_url = get_base_url @folder_urls = [] end
Public Instance Methods
call()
click to toggle source
# File lib/pulse/downloader/client.rb, line 71 def call return false unless valid? @file_paths = fetch_file_paths if @progress_bar @progress_bar = ::ProgressBar.new(file_paths.size) end file_paths.map do |file_path| download(file_path, @progress_bar) if save_data @progress_bar.increment! end end
call!()
click to toggle source
# File lib/pulse/downloader/client.rb, line 67 def call! call end
valid?()
click to toggle source
# File lib/pulse/downloader/client.rb, line 86 def valid? true # TODO end
Private Instance Methods
get_base_url()
click to toggle source
# File lib/pulse/downloader/client.rb, line 92 def get_base_url url_breakdown = url.split('/') if url_breakdown.first.include?('https') url_breakdown[2] else url_breakdown.first end end
get_micro_second_time()
click to toggle source
# File lib/pulse/downloader/client.rb, line 102 def get_micro_second_time (Time.now.to_f * 1000).to_i end
print_time(progress_bar=nil)
click to toggle source
# File lib/pulse/downloader/client.rb, line 106 def print_time(progress_bar=nil) output = "Request time: #{end_time - start_time} ms." if progress_bar progress_bar.puts output else puts output end end