HEX
Server: Apache
System: Linux vps35971 6.8.0-79-generic #79~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 15 16:54:53 UTC 2 x86_64
User: haitiopendh (6209306)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: //lib/ruby/vendor_ruby/hike/paths.rb
require 'pathname'
require 'hike/normalized_array'

module Hike
  # `Paths` is an internal collection for tracking path strings.
  class Paths < NormalizedArray
    def initialize(root = ".")
      @root = Pathname.new(root)
      super()
    end

    # Relative paths added to this array are expanded relative to `@root`.
    #
    #     paths = Paths.new("/usr/local")
    #     paths << "tmp"
    #     paths << "/tmp"
    #
    #     paths
    #     # => ["/usr/local/tmp", "/tmp"]
    #
    def normalize_element(path)
      path = Pathname.new(path)
      path = @root.join(path) if path.relative?
      path.expand_path.to_s
    end
  end
end