module Maseti::FileDownloader
Public Instance Methods
compute_hash_of(data)
click to toggle source
# File lib/maseti/file_downloader.rb, line 29 def compute_hash_of(data) { data: data }.hash end
download(file_path)
click to toggle source
save_path is defined in client.rb
# File lib/maseti/file_downloader.rb, line 10 def download(file_path) raise "save_path is undefined" if save_data && save_path == '' start_time = get_micro_second_time file_data = HTTParty.get("#{Maseti::Constants::BASE_URL}/#{file_path}") # TODO: Use the time end_time = get_micro_second_time if save_data File.open("#{save_path}/#{compute_filename(file_path)}", 'wb') do |file| file.write(file_data.body) end end file_data end
download_all_files()
click to toggle source
# File lib/maseti/file_downloader.rb, line 3 def download_all_files fetch_xls_paths_from_pages.map do |file_path| download(file_path) end end
Private Instance Methods
compute_filename(file_path)
click to toggle source
# File lib/maseti/file_downloader.rb, line 35 def compute_filename(file_path) file_path.scan(/[\/]\S+/).last end