Class: Monet::DiffStrategy

Inherits:
Object
  • Object
show all
Includes:
ChunkyPNG::Color
Defined in:
lib/monet/diff_strategy.rb

Direct Known Subclasses

ColorBlend, Grayscale, Highlight

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#scoreObject (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