module Asciidoctor::Helpers
def basename filename, drop_ext = nil
# => "tiger"
Helpers.basename 'images/tiger.png', '.png'
# => "tiger"
Helpers.basename 'images/tiger.png', true
Examples
or an explicit String extension to drop (default: nil).
drop_ext - A Boolean flag indicating whether to drop the extension
filename - The String file name to process.
Public: Retrieves the basename of the filename, optionally removing the extension, if present
def basename filename, drop_ext = nil if drop_ext ::File.basename filename, (drop_ext == true ? (extname filename) : drop_ext) else ::File.basename filename end end