Class: Imatcher::Matcher
- Inherits:
-
Object
- Object
- Imatcher::Matcher
- Defined in:
- lib/imatcher/matcher.rb
Overview
Matcher contains information about compare mode
Constant Summary collapse
- MODES =
{ rgb: 'RGB', delta: 'Delta', grayscale: 'Grayscale' }.freeze
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
Instance Method Summary collapse
- #compare(path_1, path_2) ⇒ Object
-
#initialize(options = {}) ⇒ Matcher
constructor
A new instance of Matcher.
Constructor Details
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
14 15 16 |
# File 'lib/imatcher/matcher.rb', line 14 def mode @mode end |
#threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
14 15 16 |
# File 'lib/imatcher/matcher.rb', line 14 def threshold @threshold end |
Instance Method Details
#compare(path_1, path_2) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/imatcher/matcher.rb', line 21 def compare(path_1, path_2) a = Image.from_file(path_1) b = Image.from_file(path_2) raise SizesMismatchError, "Size mismatch: first image size: " \ "#{a.width}x#{a.height}, " \ "second image size: " \ "#{b.width}x#{b.height}" unless a.sizes_match?(b) mode.compare(a, b) end |