Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Instance Method Summary collapse
-
#to_absolute_path ⇒ Object
Assuming the string is a file or path name, convert it into an absolute path.
Instance Method Details
#to_absolute_path ⇒ Object
Assuming the string is a file or path name, convert it into an absolute path.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/core_ext/string.rb', line 10 def to_absolute_path # Pathname is incompatible with Windows, but Windows doesn't have # real symlinks so File.expand_path is safe. if RUBY_PLATFORM =~ /(:?mswin|mingw)/ File.( self ) # Otherwise use Pathname#realpath which respects symlinks. else begin File.( Pathname.new( self ).realpath.to_s ) rescue Errno::ENOENT File.( Pathname.new( self ).cleanpath.to_s ) end end end |