Class: Middleman::Imageoptim::Optimizer
- Inherits:
-
Object
- Object
- Middleman::Imageoptim::Optimizer
- Defined in:
- lib/middleman-imageoptim/optimizer.rb
Overview
Optimizer class that accepts an options object and processes files and passes them off to image_optim to be processed
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#byte_savings ⇒ Object
readonly
Returns the value of attribute byte_savings.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app, builder, options) ⇒ Optimizer
constructor
A new instance of Optimizer.
- #process_images ⇒ Object
Constructor Details
#initialize(app, builder, options) ⇒ Optimizer
Returns a new instance of Optimizer.
15 16 17 18 19 20 |
# File 'lib/middleman-imageoptim/optimizer.rb', line 15 def initialize(app, builder, ) @app = app @builder = builder = @byte_savings = 0 end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
9 10 11 |
# File 'lib/middleman-imageoptim/optimizer.rb', line 9 def app @app end |
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
9 10 11 |
# File 'lib/middleman-imageoptim/optimizer.rb', line 9 def builder @builder end |
#byte_savings ⇒ Object (readonly)
Returns the value of attribute byte_savings.
9 10 11 |
# File 'lib/middleman-imageoptim/optimizer.rb', line 9 def byte_savings @byte_savings end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/middleman-imageoptim/optimizer.rb', line 9 def end |
Class Method Details
.optimize!(app, builder, options) ⇒ Object
11 12 13 |
# File 'lib/middleman-imageoptim/optimizer.rb', line 11 def self.optimize!(app, builder, ) new(app, builder, ).process_images end |
Instance Method Details
#process_images ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/middleman-imageoptim/optimizer.rb', line 22 def process_images images = updated_images modes = preoptimize_modes(images) optimizer.optimize_images(images) do |source, destination| process_image(source, destination, modes.fetch(source.to_s)) end update_manifest say_status 'Total savings: %{data}', data: Utils.format_size(byte_savings) end |