Sha256: 00216abfe2543c5b316b37a00b0edc07a9a78993c998c2f5b9b9fffa54595268

Contents?: true

Size: 445 Bytes

Versions: 6

Compression:

Stored size: 445 Bytes

Contents

# frozen_string_literal: true

module Meta
  module Utils
    class Path
      class << self
        def normalize_path(path)
          path = '/' unless path
          path = '/' + path unless path.start_with?('/')
          path = path.delete_suffix('/') if path.end_with?('/')
          path
        end

        def join(p1, p2)
          normalize_path(normalize_path(p1) + '/' + normalize_path(p2))
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
meta-api-0.0.6 lib/meta/utils/path.rb
meta-api-0.0.5 lib/meta/utils/path.rb
meta-api-0.0.4 lib/meta/utils/path.rb
meta-api-0.0.3 lib/meta/utils/path.rb
meta-api-0.0.2 lib/meta/utils/path.rb
meta-api-0.0.1 lib/meta/utils/path.rb