Sha256: 2367d6367240c73597f9ec9e2c3cd3b748c2a350bdc16e7ccb606e1cdee14e4a
Contents?: true
Size: 917 Bytes
Versions: 3
Compression:
Stored size: 917 Bytes
Contents
module PlatinaWorld class Path attr_reader :file_path def initialize(file_path) @file_path = file_path end def file_name path[:file] end def directory_name path[:directory] end def directory? file_name == "" end def has_directory? directory_name != "" end private # Return file name and dirctory name as Array # @params [String] file path (e.g "a/b/c") # @return [[String, String]] first is file path name and second is directory path name # # Examples. # file_and_dir_name("a/b/c") => ["a/b", "c"] # file_and_dir_name("a/b/c/") => ["a/b/c", ""] def path @path ||= begin path = file_path.split("/", -1) file_name = path.pop directory_name = path.join("/") { file: file_name, directory: directory_name } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
platina_world-0.1.2.1 | lib/platina_world/path.rb |
platina_world-0.1.2 | lib/platina_world/path.rb |
platina_world-0.1.1 | lib/platina_world/path.rb |