Class: EasyDownloader::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_downloader/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



5
6
7
8
9
# File 'lib/easy_downloader/result.rb', line 5

def initialize
  @header, @started, @finished, @errors= ''
  @files_loaded = []
  @progress = ["Progress:"]
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



3
4
5
# File 'lib/easy_downloader/result.rb', line 3

def errors
  @errors
end

#files_loadedObject

Returns the value of attribute files_loaded.



3
4
5
# File 'lib/easy_downloader/result.rb', line 3

def files_loaded
  @files_loaded
end

Instance Method Details

#finishedObject



33
34
35
# File 'lib/easy_downloader/result.rb', line 33

def finished
  @finished= Time.now
end

#finished_atObject



37
# File 'lib/easy_downloader/result.rb', line 37

def finished_at; @finished; end

#finished_path(path) ⇒ Object



54
55
56
# File 'lib/easy_downloader/result.rb', line 54

def finished_path(path)
  @progress << "Finished loading #{path}"
end

#found(total_found, file_names) ⇒ Object



21
22
23
24
25
# 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) ⇒ Object



41
42
43
44
45
46
47
48
# 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

#startedObject



27
28
29
# File 'lib/easy_downloader/result.rb', line 27

def started
  @started= Time.now
end

#started_atObject



31
# File 'lib/easy_downloader/result.rb', line 31

def started_at; @started; end

#starting_path(path) ⇒ Object



50
51
52
# File 'lib/easy_downloader/result.rb', line 50

def starting_path(path)
  @progress << "Starting to load #{path}"
end

#to_sObject



11
12
13
14
15
16
17
18
19
# File 'lib/easy_downloader/result.rb', line 11

def to_s 
  [@header,
   found_list,
   started_string,
   progress,
   @errors,
   finished_string,
   @footer].join("\n")
end