Class: Phashion::Image

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

Constant Summary collapse

SETTINGS =
{
  :dupe_threshold => 15
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Image

Returns a new instance of Image.



18
19
20
# File 'lib/phashion.rb', line 18

def initialize(filename)
  @filename = filename
end

Instance Attribute Details

#filename ⇒ Object (readonly)

Returns the value of attribute filename.



17
18
19
# File 'lib/phashion.rb', line 17

def filename
  @filename
end

Instance Method Details

#duplicate?(other) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/phashion.rb', line 22

def duplicate?(other)
  Phashion.hamming_distance(fingerprint, other.fingerprint) < SETTINGS[:dupe_threshold]
end

#fingerprint ⇒ Object



26
27
28
# File 'lib/phashion.rb', line 26

def fingerprint
  @hash ||= Phashion.image_hash_for(@filename)
end