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
30 31 32 |
# File 'lib/phash.rb', line 30 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
27 28 29 |
# File 'lib/phash.rb', line 27 def path @path end |
Class Method Details
.for_paths(paths, *args) ⇒ Object
Init multiple image instances
35 36 37 38 39 |
# File 'lib/phash.rb', line 35 def self.for_paths(paths, *args) paths.map do |path| new(path, *args) end end |
.hash_type ⇒ Object
56 57 58 |
# File 'lib/phash.rb', line 56 def self.hash_type @hash_type ||= self.name.split('::').last.downcase end |
Instance Method Details
#compute_phash ⇒ Object
46 47 48 |
# File 'lib/phash.rb', line 46 def compute_phash Phash.send("#{self.class.hash_type}_hash", @path) end |
#phash ⇒ Object
Cached hash of text
42 43 44 |
# File 'lib/phash.rb', line 42 def phash @phash ||= compute_phash end |
#similarity(other, *args) ⇒ Object Also known as: %
Similarity with other phash
51 52 53 |
# File 'lib/phash.rb', line 51 def similarity(other, *args) phash.similarity(other.phash, *args) end |