Class: Aspera::IdGenerator

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

Class Method Summary collapse

Class Method Details

.from_list(object_id) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aspera/id_generator.rb', line 13

def from_list(object_id)
  if object_id.is_a?(Array)
    # compact: remove nils
    object_id = object_id.compact.map do |i|
      i.is_a?(String) && i.start_with?('https://') ? URI.parse(i).host : i.to_s
    end.join(ID_SEPARATOR)
  end
  Aspera.assert_type(object_id, String)
  return object_id
      .gsub(WINDOWS_PROTECTED_CHAR, PROTECTED_CHAR_REPLACE) # remove windows forbidden chars
      .gsub('.', PROTECTED_CHAR_REPLACE) # keep dot for extension only (nicer)
      .downcase
end