Module: Poleica::Pathable

Included in:
Polei
Defined in:
lib/poleica/pathable.rb

Overview

Path methods

Instance Method Summary collapse

Instance Method Details

#path_for_extension(extension) ⇒ Object



5
6
7
# File 'lib/poleica/pathable.rb', line 5

def path_for_extension(extension)
  "#{path_without_extension}.#{extension}"
end

#path_with_md5(extension = self.extension) ⇒ Object



13
14
15
16
17
18
# File 'lib/poleica/pathable.rb', line 13

def path_with_md5(extension = self.extension)
  data   = File.read(self.path)
  md5    = Digest::MD5.new
  digest = md5.hexdigest(data)
  "#{path_without_extension}-#{digest}.#{extension}"
end

#path_without_extensionObject



9
10
11
# File 'lib/poleica/pathable.rb', line 9

def path_without_extension
  File.join(File.dirname(self.path), File.basename(self.path, '.*'))
end