Class: Floccus::Filename
- Inherits:
-
Object
- Object
- Floccus::Filename
- Defined in:
- lib/floccus/filename.rb
Class Method Summary collapse
-
.generate(filename) ⇒ Object
Generate a hashed filename based on the contents.
Class Method Details
.generate(filename) ⇒ Object
Generate a hashed filename based on the contents
Returns the hash followed by the filename
6 7 8 9 10 11 12 |
# File 'lib/floccus/filename.rb', line 6 def self.generate(filename) file_path = File.(filename) contents = File.read(file_path) hash = Digest::MD5.hexdigest(contents) "#{hash}-#{filename}" end |