Sha256: d838d83817d1d454d55558af0054be16a62c1cc9d7390fa97a3e219b03a92407

Contents?: true

Size: 490 Bytes

Versions: 8

Compression:

Stored size: 490 Bytes

Contents

class String  
  def path
    self.extend PathString
  end      
end

module PathString
  def exists?  
    File.exist? self
  end

  def file?  
    File.file? self
  end

  def dir?  
    File.directory? self
  end

  def symlink?  
    File.symlink? self
  end
  
  def up lv
    ('../' * lv) + self
  end

  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
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sugar-high-0.2.8 lib/sugar-high/path.rb
sugar-high-0.2.7 lib/sugar-high/path.rb
sugar-high-0.2.6 lib/sugar-high/path.rb
sugar-high-0.2.5 lib/sugar-high/path.rb
sugar-high-0.2.4 lib/sugar-high/path.rb
sugar-high-0.2.2 lib/sugar-high/path.rb
sugar-high-0.2.1 lib/sugar-high/path.rb
sugar-high-0.2.0 lib/sugar-high/path.rb