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_tools-0.60.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.60.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.60.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.59.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.58.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.57.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.56.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.56.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.7 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.6 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.5 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.4 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.3 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.112.0 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_ruby_utils-0.111.0 lib/eac_ruby_utils/patches/pathname/child_of.rb
eac_tools-0.55.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/child_of.rb