Module: Plumnailer::ImgComparator
- Defined in:
- lib/plumnailer/img_comparator.rb
Overview
Mixin for Magick::ImageList that adds a comparator for sorting by relevance.
Instance Method Summary collapse
Instance Method Details
#<=>(other) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/plumnailer/img_comparator.rb', line 6 def <=> other # can use doc here to take source page into account # square of smallest dimension result = ([other.rows, other.columns].min ** 2) <=> ([rows, columns].min ** 2) # if still tied use number of colors if result == 0 result = other.number_colors <=> number_colors end result end |