Module: Shrine::Plugins::PrettyLocation::InstanceMethods

Defined in:
lib/shrine/plugins/pretty_location.rb

Instance Method Summary collapse

Instance Method Details

#generate_location(io, **options) ⇒ Object


13
14
15
# File 'lib/shrine/plugins/pretty_location.rb', line 13

def generate_location(io, **options)
  pretty_location(io, **options)
end

#pretty_location(io, name: nil, record: nil, version: nil, derivative: nil, identifier: nil, metadata: {}) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/shrine/plugins/pretty_location.rb', line 17

def pretty_location(io, name: nil, record: nil, version: nil, derivative: nil, identifier: nil, metadata: {}, **)
  if record
    namespace    = record_namespace(record)
    identifier ||= record_identifier(record)
  end

  basename = basic_location(io, metadata: )
  basename = [*(version || derivative), basename].join("-")

  [*namespace, *identifier, *name, basename].join("/")
end