Created
February 27, 2025 16:25
-
-
Save Snarp/12b5972eed00efd9568c1935a09d0f23 to your computer and use it in GitHub Desktop.
Extends Pathname to add #stemname instance method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extends Pathname to add #stemname instance method | |
class Pathname | |
# "dir/subdir/filename1.ext" => "filename1" | |
def stemname | |
bs = basename.to_s | |
bs.slice(0,bs.length-extname.length) | |
end | |
end | |
# - <https://github.com/ruby/pathname/blob/master/lib/pathname.rb> | |
# - <https://rubyapi.org/o/pathname> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment