Class: ImageOptim::Runner::Results
- Inherits:
-
Object
- Object
- ImageOptim::Runner::Results
- Defined in:
- lib/image_optim/runner.rb
Overview
Collect and output results of optimization
Instance Method Summary collapse
- #add(original, optimized) ⇒ Object
-
#initialize ⇒ Results
constructor
A new instance of Results.
- #print ⇒ Object
Constructor Details
#initialize ⇒ Results
Returns a new instance of Results.
16 17 18 19 20 |
# File 'lib/image_optim/runner.rb', line 16 def initialize @lines = [] @original_size_sum = 0 @optimized_size_sum = 0 end |
Instance Method Details
#add(original, optimized) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/image_optim/runner.rb', line 22 def add(original, optimized) original_size = optimized ? optimized.original_size : original.size optimized_size = optimized ? optimized.size : original.size @lines << "#{size_percent(original_size, optimized_size)} #{original}" @original_size_sum += original_size @optimized_size_sum += optimized_size end |
#print ⇒ Object
30 31 32 33 |
# File 'lib/image_optim/runner.rb', line 30 def print puts @lines puts "Total: #{size_percent(@original_size_sum, @optimized_size_sum)}" end |