Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Pathname#sub

sub(*args)

Return a pathname which is substituted by String#sub.

Example
path1 = Pathname.new('/usr/bin/perl')
path1.sub('perl', 'ruby')
    #=> #<Pathname:/usr/bin/ruby>
See also #sticky? #sub_ext #stat #symlink? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0