Class: Phash::FileHash
- Inherits:
-
Object
- Object
- Phash::FileHash
- Defined in:
- lib/phash.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.for_paths(paths, *args) ⇒ Object
Init multiple image instances.
- .hash_type ⇒ Object
Instance Method Summary collapse
- #compute_phash ⇒ Object
-
#initialize(path) ⇒ FileHash
constructor
File path.
-
#phash ⇒ Object
Cached hash of text.
-
#similarity(other, *args) ⇒ Object
(also: #%)
Similarity with other phash.
Constructor Details
#initialize(path) ⇒ FileHash
File path
26 27 28 |
# File 'lib/phash.rb', line 26 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
23 24 25 |
# File 'lib/phash.rb', line 23 def path @path end |
Class Method Details
.for_paths(paths, *args) ⇒ Object
Init multiple image instances
31 32 33 34 35 |
# File 'lib/phash.rb', line 31 def self.for_paths(paths, *args) paths.map do |path| new(path, *args) end end |
.hash_type ⇒ Object
52 53 54 |
# File 'lib/phash.rb', line 52 def self.hash_type @hash_type ||= self.name.split('::').last.downcase end |
Instance Method Details
#compute_phash ⇒ Object
42 43 44 |
# File 'lib/phash.rb', line 42 def compute_phash Phash.send("#{self.class.hash_type}_hash", @path) end |
#phash ⇒ Object
Cached hash of text
38 39 40 |
# File 'lib/phash.rb', line 38 def phash @phash ||= compute_phash end |
#similarity(other, *args) ⇒ Object Also known as: %
Similarity with other phash
47 48 49 |
# File 'lib/phash.rb', line 47 def similarity(other, *args) phash.similarity(other.phash, *args) end |