Class: Pathname

Inherits:
Object show all
Defined in:
lib/eac_ruby_utils/patches/pathname/parent_n.rb,
lib/eac_ruby_utils/patches/pathname/basename_sub.rb

Instance Method Summary collapse

Instance Method Details

#basename_sub(suffix = '') ⇒ Object


6
7
8
# File 'lib/eac_ruby_utils/patches/pathname/basename_sub.rb', line 6

def basename_sub(suffix = '')
  parent.join(yield(basename(suffix)))
end

#parent_n(n) ⇒ Pathname

Apply .parent n times.

Returns:


8
9
10
# File 'lib/eac_ruby_utils/patches/pathname/parent_n.rb', line 8

def parent_n(n) # rubocop:disable Naming/MethodParameterName
  n.times.inject(self) { |a, _e| a.parent }
end