Class: Cocina::Models::Mapping::Purl
- Inherits:
-
Object
- Object
- Cocina::Models::Mapping::Purl
- Defined in:
- lib/cocina/models/mapping/purl.rb
Overview
Utility methods for generating purl links
Class Method Summary collapse
- .for(druid:) ⇒ Object
-
.host ⇒ Object
the purl without the protocol part.
- .purl?(node) ⇒ Boolean
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 |
.host ⇒ Object
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
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 |