Class: Imatcher::Result

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

Overview

Object containing comparison score and diff image

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode, threshold) ⇒ Result

Returns a new instance of Result.



7
8
9
10
11
12
# File 'lib/imatcher/result.rb', line 7

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

Instance Attribute Details

#diffObject (readonly)

Returns the value of attribute diff.



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

def diff
  @diff
end

#imageObject

Returns the value of attribute image.



4
5
6
# File 'lib/imatcher/result.rb', line 4

def image
  @image
end

#modeObject (readonly)

Returns the value of attribute mode.



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

def mode
  @mode
end

#scoreObject

Returns the value of attribute score.



4
5
6
# File 'lib/imatcher/result.rb', line 4

def score
  @score
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



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

def threshold
  @threshold
end

Instance Method Details

#difference_imageObject



14
15
16
# File 'lib/imatcher/result.rb', line 14

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

#match?Boolean

Returns true iff score less or equals to threshold

Returns:

  • (Boolean)


19
20
21
# File 'lib/imatcher/result.rb', line 19

def match?
  score <= threshold
end