Class: Cocina::Models::Mapping::Purl

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/purl.rb

Overview

Utility methods for generating purl links

Class Method Summary collapse

Class Method Details

.for(druid:) ⇒ Object



10
11
12
13
14
# File 'lib/cocina/models/mapping/purl.rb', line 10

def self.for(druid:)
  return nil if druid.nil?

  "#{base_url}/#{druid.delete_prefix('druid:')}"
end

.hostObject

the purl without the protocol part



21
22
23
# File 'lib/cocina/models/mapping/purl.rb', line 21

def self.host
  @host ||= base_url.sub(%r{^https?://}, '')
end

.purl?(node) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/cocina/models/mapping/purl.rb', line 16

def self.purl?(node)
  node.start_with?("https://#{host}") || node.start_with?("http://#{host}")
end