module PathString
Public Instance Methods
dir?()
click to toggle source
# File lib/sugar-high/path.rb, line 39 def dir? File.directory? self end
Also aliased as: is_dir?
down(lv)
click to toggle source
# File lib/sugar-high/path.rb, line 54 def down lv up_dir = Regexp.escape('../') orig = self.clone lv.times do self.gsub! /^#{up_dir}/, '' return self if self == orig end self end
exists?()
click to toggle source
# File lib/sugar-high/path.rb, line 29 def exists? File.exist? self end
Also aliased as: there?
file?()
click to toggle source
# File lib/sugar-high/path.rb, line 34 def file? File.file? self end
Also aliased as: is_file?
post_down(lv)
click to toggle source
# File lib/sugar-high/path.rb, line 68 def post_down lv up_dir = Regexp.escape('/..') orig = self.clone lv.times do self.gsub! /#{up_dir}$/, '' return self if self == orig end self end
post_up(lv)
click to toggle source
# File lib/sugar-high/path.rb, line 64 def post_up lv self + ('/..' * lv) end
symlink?()
click to toggle source
# File lib/sugar-high/path.rb, line 45 def symlink? File.symlink? self end
Also aliased as: is_symlink?
to_dir(option=nil)
click to toggle source
# File lib/sugar-high/path.rb, line 15 def to_dir option=nil raise ArgumentError, "Dir doesn't exist" if option == :raise && !File.directory?(self) Dir.new(self) if File.directory? self end
to_file(option=nil)
click to toggle source
# File lib/sugar-high/path.rb, line 8 def to_file option=nil raise ArgumentError, "File doesn't exist" if option == :raise && !File.directory?(self) File.new(self) if File.file? self end
to_symlink(new_path)
click to toggle source
# File lib/sugar-high/path.rb, line 22 def to_symlink new_path #, option=nil # raise ArgumentError, "New link location doesn't exist" if option == :raise && !File.exist?(new_path) File.symlink(self, new_path) end
Also aliased as: new_symlink, symlink
up(lv)
click to toggle source
# File lib/sugar-high/path.rb, line 50 def up lv ('../' * lv) + self end