Class: ImageProcessing::Processor
- Inherits:
-
Object
- Object
- ImageProcessing::Processor
show all
- Defined in:
- lib/image_processing/processor.rb
Instance Method Summary
collapse
Constructor Details
#initialize(pipeline) ⇒ Processor
Returns a new instance of Processor.
3
4
5
|
# File 'lib/image_processing/processor.rb', line 3
def initialize(pipeline)
@pipeline = pipeline
end
|
Instance Method Details
#apply(image, operations) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/image_processing/processor.rb', line 7
def apply(image, operations)
operations.inject(image) do |result, (name, args)|
if args == true || args.nil?
apply_operation(name, result)
else
apply_operation(name, result, *args)
end
end
end
|
#apply_operation(name, image, *args) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/image_processing/processor.rb', line 17
def apply_operation(name, image, *args)
if respond_to?(name)
public_send(name, image, *args)
else
image.send(name, *args)
end
end
|
#custom(image, block) ⇒ Object
25
26
27
|
# File 'lib/image_processing/processor.rb', line 25
def custom(image, block)
(block && block.call(image)) || image
end
|