Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/sashimi/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#to_path(absolute = false) ⇒ Object

Transform the current String to a system path, according to the current platform file system.

"path/to/app".to_path # => path/to/app (on *nix)
"path/to/app".to_path # => path\to\app (on Windows)

"path/to/app".to_path(true) # => /Users/luca/path/to/app (on *nix)
"path/to/app".to_path(true) # => C:\path\to\app (on Windows)


10
11
12
# File 'lib/sashimi/core_ext/string.rb', line 10

def to_path(absolute = false)
  self.split(/\/\\/).to_path(absolute)
end