Class: Monet::DiffStrategy
- Inherits:
-
Object
- Object
- Monet::DiffStrategy
- Includes:
- ChunkyPNG::Color
- Defined in:
- lib/monet/diff_strategy.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #calculate_for_pixel(pixel, x, y) ⇒ Object
-
#initialize(base_image, diff_image) ⇒ DiffStrategy
constructor
A new instance of DiffStrategy.
- #save(filename) ⇒ Object
Constructor Details
#initialize(base_image, diff_image) ⇒ DiffStrategy
Returns a new instance of DiffStrategy.
9 10 11 12 13 14 15 |
# File 'lib/monet/diff_strategy.rb', line 9 def initialize(base_image, diff_image) @base_image = base_image @diff_image = diff_image @score = [] raise Errors::DifferentDimensions unless dimensions_match? end |
Instance Attribute Details
#score ⇒ Object (readonly)
Returns the value of attribute score.
7 8 9 |
# File 'lib/monet/diff_strategy.rb', line 7 def score @score end |
Instance Method Details
#calculate_for_pixel(pixel, x, y) ⇒ Object
17 18 19 |
# File 'lib/monet/diff_strategy.rb', line 17 def calculate_for_pixel(pixel, x, y) @score << [x,y] unless pixel == @diff_image[x,y] end |
#save(filename) ⇒ Object
21 22 23 |
# File 'lib/monet/diff_strategy.rb', line 21 def save(filename) @output.save(filename) end |