Class: Compix::SubimageMatch
- Inherits:
-
Object
- Object
- Compix::SubimageMatch
- Defined in:
- lib/compix/match.rb
Instance Attribute Summary collapse
-
#coordinate_x ⇒ Object
readonly
Returns the value of attribute coordinate_x.
-
#coordinate_y ⇒ Object
readonly
Returns the value of attribute coordinate_y.
-
#pixels_compared ⇒ Object
readonly
Returns the value of attribute pixels_compared.
-
#pixels_matched ⇒ Object
readonly
Returns the value of attribute pixels_matched.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
-
#initialize(coord_x, coord_y, pixels_compared, pixels_matched) ⇒ SubimageMatch
constructor
A new instance of SubimageMatch.
- #match_percentage ⇒ Object
- #state ⇒ Object
Constructor Details
#initialize(coord_x, coord_y, pixels_compared, pixels_matched) ⇒ SubimageMatch
Returns a new instance of SubimageMatch.
7 8 9 10 11 12 13 |
# File 'lib/compix/match.rb', line 7 def initialize(coord_x, coord_y, pixels_compared, pixels_matched) raise ArgumentError.new("Matched more pixels ('#{pixels_matched}') than compared ('#{pixels_compared}')") if pixels_compared < pixels_matched @coordinate_x = coord_x @coordinate_y = coord_y @pixels_compared = pixels_compared @pixels_matched = pixels_matched end |
Instance Attribute Details
#coordinate_x ⇒ Object (readonly)
Returns the value of attribute coordinate_x.
5 6 7 |
# File 'lib/compix/match.rb', line 5 def coordinate_x @coordinate_x end |
#coordinate_y ⇒ Object (readonly)
Returns the value of attribute coordinate_y.
5 6 7 |
# File 'lib/compix/match.rb', line 5 def coordinate_y @coordinate_y end |
#pixels_compared ⇒ Object (readonly)
Returns the value of attribute pixels_compared.
5 6 7 |
# File 'lib/compix/match.rb', line 5 def pixels_compared @pixels_compared end |
#pixels_matched ⇒ Object (readonly)
Returns the value of attribute pixels_matched.
5 6 7 |
# File 'lib/compix/match.rb', line 5 def pixels_matched @pixels_matched end |
Instance Method Details
#eql?(other) ⇒ Boolean
20 21 22 |
# File 'lib/compix/match.rb', line 20 def eql?(other) other.class.eql?(self.class) && other.state.eql?(self.state) end |
#match_percentage ⇒ Object
15 16 17 18 |
# File 'lib/compix/match.rb', line 15 def match_percentage return 0 if pixels_compared == 0 pixels_matched.to_f / pixels_compared end |
#state ⇒ Object
24 25 26 |
# File 'lib/compix/match.rb', line 24 def state [@coordinate_x, @coordinate_y, @pixels_compared, @pixels_matched] end |