Class: ImgFetcher::Stats
- Inherits:
-
Object
- Object
- ImgFetcher::Stats
- Defined in:
- lib/img_fetcher/stats.rb
Instance Attribute Summary collapse
-
#retrieved_images ⇒ Object
readonly
Returns the value of attribute retrieved_images.
-
#total_lines ⇒ Object
readonly
Returns the value of attribute total_lines.
Instance Method Summary collapse
- #add_line ⇒ Object
- #add_retrieved_image ⇒ Object
- #end ⇒ Object
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
- #start ⇒ Object
- #total_time ⇒ Object
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
5 6 7 8 9 10 11 |
# File 'lib/img_fetcher/stats.rb', line 5 def initialize @total_lines = 0 @retrieved_images = 0 @semaphore = Mutex.new @start_time = nil @end_time = nil end |
Instance Attribute Details
#retrieved_images ⇒ Object (readonly)
Returns the value of attribute retrieved_images.
3 4 5 |
# File 'lib/img_fetcher/stats.rb', line 3 def retrieved_images @retrieved_images end |
#total_lines ⇒ Object (readonly)
Returns the value of attribute total_lines.
3 4 5 |
# File 'lib/img_fetcher/stats.rb', line 3 def total_lines @total_lines end |
Instance Method Details
#add_line ⇒ Object
13 14 15 16 17 |
# File 'lib/img_fetcher/stats.rb', line 13 def add_line @semaphore.synchronize do @total_lines += 1 end end |
#add_retrieved_image ⇒ Object
19 20 21 22 23 |
# File 'lib/img_fetcher/stats.rb', line 19 def add_retrieved_image @semaphore.synchronize do @retrieved_images += 1 end end |
#end ⇒ Object
29 30 31 |
# File 'lib/img_fetcher/stats.rb', line 29 def end @end_time = now end |
#start ⇒ Object
25 26 27 |
# File 'lib/img_fetcher/stats.rb', line 25 def start @start_time = now end |
#total_time ⇒ Object
33 34 35 |
# File 'lib/img_fetcher/stats.rb', line 33 def total_time @end_time - @start_time end |