Class: OCFL::Layouts::DruidTree

Inherits:
Object
  • Object
show all
Defined in:
lib/ocfl/layouts/druid_tree.rb

Overview

An OCFL Storage Root layout for the druid-tree structure

Constant Summary collapse

DRUID_PARTS_PATTERN =
/\A([b-df-hjkmnp-tv-z]{2})([0-9]{3})([b-df-hjkmnp-tv-z]{2})([0-9]{4})\z/i

Class Method Summary collapse

Class Method Details

.path_to(identifier) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/ocfl/layouts/druid_tree.rb', line 10

def self.path_to(identifier)
  segments = Array(identifier&.match(DRUID_PARTS_PATTERN)&.captures)

  raise "druid '#{identifier}' is invalid" unless segments.count == 4

  Pathname.new(
    File.join(segments)
  )
end