Class: Partridge::Pairtree

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

Overview

Takes an oid and returns a string representing a pairtree path

Class Method Summary collapse

Class Method Details

.oid_to_pairtree(oid) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/partridge.rb', line 9

def self.oid_to_pairtree(oid)
  formatted_oid = format('%<number>02d', number: oid)
  prefix = formatted_oid[-2..-1]
  digest_path_structure = oid.to_s.scan(/../)
  digest_path_structure.each do |oiddir|
    prefix += "/#{oiddir}"
  end
  prefix
end