Class: ImageCompare::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/image_compare/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode, threshold:, lower_threshold:) ⇒ Result

Returns a new instance of Result.



8
9
10
11
12
13
14
# File 'lib/image_compare/result.rb', line 8

def initialize(mode, threshold:, lower_threshold:)
  @score = 0.0
  @diff = []
  @threshold = threshold
  @lower_threshold = lower_threshold
  @mode = mode
end

Instance Attribute Details

#diffObject (readonly)

Returns the value of attribute diff.



6
7
8
# File 'lib/image_compare/result.rb', line 6

def diff
  @diff
end

#imageObject

Returns the value of attribute image.



5
6
7
# File 'lib/image_compare/result.rb', line 5

def image
  @image
end

#lower_thresholdObject (readonly)

Returns the value of attribute lower_threshold.



6
7
8
# File 'lib/image_compare/result.rb', line 6

def lower_threshold
  @lower_threshold
end

#modeObject (readonly)

Returns the value of attribute mode.



6
7
8
# File 'lib/image_compare/result.rb', line 6

def mode
  @mode
end

#scoreObject

Returns the value of attribute score.



5
6
7
# File 'lib/image_compare/result.rb', line 5

def score
  @score
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



6
7
8
# File 'lib/image_compare/result.rb', line 6

def threshold
  @threshold
end

Instance Method Details

#difference_imageObject



16
17
18
# File 'lib/image_compare/result.rb', line 16

def difference_image
  @diff_image ||= mode.diff(image, diff)
end

#match?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/image_compare/result.rb', line 20

def match?
  score <= threshold && score >= lower_threshold
end