Sha256: e20c80952df9e593d8f6d0b3591d0e08df5f930dc476ff360cef634d61c58965

Contents?: true

Size: 395 Bytes

Versions: 58

Compression:

Stored size: 395 Bytes

Contents

# frozen_string_literal: true

require 'pathname'

class Pathname
  # Indicate if +self+ is child of +parent_path+.
  #
  # @return [Boolean]
  def child_of?(parent_path)
    self_parts = expand_path.each_filename.to_a
    parent_parts = parent_path.expand_path.each_filename.to_a
    return false if self_parts == parent_parts

    parent_parts.zip(self_parts).all? { |x, y| x == y }
  end
end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
eac_ruby_utils-0.123.0 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.121.0 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.120.0 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.76.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.76.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.75.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.119.2 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.75.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.75.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.119.1 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.74.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.74.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.73.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.119.0 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.72.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.118.1 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.118.0 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.70.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.70.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.69.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb