HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
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