Ruby File/Folder Operations

Ruby, 2015-10-04 00:12:41 UTC
file = "/the/path/file_name.wow"

file_name = File.basename file        # => "file_name.wow"
extname = File.extname  file        # => ".wow"
basename = File.basename file, extn  # => "file_name"
path = File.dirname  file        # => "/the/path"

Share: