Module: Texd::Attachment
- Defined in:
- lib/texd/attachment.rb
Defined Under Namespace
Classes: Base, Dynamic, File, Reference, RenameError
Class Method Summary collapse
-
.name(path, with_extension = true) ⇒ String
Computes the file name of a given path, and returns it with or without file extension.
Class Method Details
.name(path, with_extension = true) ⇒ String
Computes the file name of a given path, and returns it with or without file extension.
167 168 169 170 171 172 173 174 175 |
# File 'lib/texd/attachment.rb', line 167 def self.name(path, with_extension = true) # rubocop:disable Style/OptionalBooleanParameter basename = ::File.basename(path) return basename if with_extension dot = basename.rindex(".") return basename if dot == 0 # file starts with "." basename.slice(0, dot) end |