Class: Elrio::Runner
- Inherits:
-
Object
- Object
- Elrio::Runner
- Defined in:
- lib/elrio/runner.rb
Instance Method Summary collapse
- #analyze(path) ⇒ Object
-
#initialize(cap_inset_detector = CapInsetDetector.new, image_optimizer = ImageOptimizer.new) ⇒ Runner
constructor
A new instance of Runner.
- #optimize(path) ⇒ Object
Constructor Details
#initialize(cap_inset_detector = CapInsetDetector.new, image_optimizer = ImageOptimizer.new) ⇒ Runner
Returns a new instance of Runner.
5 6 7 8 |
# File 'lib/elrio/runner.rb', line 5 def initialize(cap_inset_detector = CapInsetDetector.new, image_optimizer = ImageOptimizer.new) @cap_inset_detector = cap_inset_detector @image_optimizer = image_optimizer end |
Instance Method Details
#analyze(path) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/elrio/runner.rb', line 10 def analyze(path) image = ChunkyPNG::Image.from_file(path) scale = PointSize.from_filename(path) insets = @cap_inset_detector.detect_cap_insets(image) insets / scale end |
#optimize(path) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elrio/runner.rb', line 17 def optimize(path) image = ChunkyPNG::Image.from_file(path) scale = PointSize.from_filename(path) insets = @cap_inset_detector.detect_cap_insets(image) point_insets = insets / scale optimized_image = @image_optimizer.optimize(image, insets) if optimized_image optimized_path = optimized_path_for(path) optimized_image.save(optimized_path) end point_insets end |