class EasyDownloader::Result

Attributes

errors[RW]
files_loaded[RW]

Public Class Methods

new() click to toggle source
# File lib/easy_downloader/result.rb, line 5
def initialize
  @header, @started, @finished, @errors= ''
  @files_loaded = []
  @progress = ["Progress:"]
end

Public Instance Methods

finished() click to toggle source
# File lib/easy_downloader/result.rb, line 33
def finished
  @finished= Time.now
end
finished_at() click to toggle source
# File lib/easy_downloader/result.rb, line 37
def finished_at; @finished; end
finished_path(path) click to toggle source
# File lib/easy_downloader/result.rb, line 54
def finished_path(path)
  @progress << "Finished loading #{path}"
end
found(total_found, file_names) click to toggle source
# File lib/easy_downloader/result.rb, line 21
def found(total_found, file_names)
  @found = total_found
  @header= "We found #{total_found} file(s) to load with the following names: \n"
  @found_list = file_names
end
loaded(total = false) click to toggle source
# File lib/easy_downloader/result.rb, line 41
def loaded(total = false)
  if total
    @loaded = total
    @footer= "Loaded #{total} file(s)"
  else
    @loaded
  end
end
started() click to toggle source
# File lib/easy_downloader/result.rb, line 27
def started
  @started= Time.now
end
started_at() click to toggle source
# File lib/easy_downloader/result.rb, line 31
def started_at; @started; end
starting_path(path) click to toggle source
# File lib/easy_downloader/result.rb, line 50
def starting_path(path)
  @progress << "Starting to load #{path}"
end
to_s() click to toggle source
# File lib/easy_downloader/result.rb, line 11
def to_s 
  [@header,
   found_list,
   started_string,
   progress,
   @errors,
   finished_string,
   @footer].join("\n")
end

Private Instance Methods

finished_string() click to toggle source
# File lib/easy_downloader/result.rb, line 76
def finished_string
  "Finished loading at #{@finished}"
end
found_list() click to toggle source
# File lib/easy_downloader/result.rb, line 64
def found_list
  full_list = ''
  @found_list.each_with_index do |file_name, index|
    full_list += "##{(index+1).to_s}. #{file_name} "
  end
  full_list
end
progress() click to toggle source
# File lib/easy_downloader/result.rb, line 60
def progress
  @progress.join("\n")
end
started_string() click to toggle source
# File lib/easy_downloader/result.rb, line 72
def started_string
  "Started loading at #{@started}"
end