Sha256: 74b1e5d3418aa6b6687d74aba8092f457c47915b12ef5740e41a764cb190be2a

Contents?: true

Size: 647 Bytes

Versions: 5

Compression:

Stored size: 647 Bytes

Contents

require 'sugar-high/string'

class File
  def self.blank? file_name
    raise ArgumentError, "Filename argument must not be blank" if file_name.blank?
    raise ArgumentError, "There is no file at: #{file_name}" if !File.file?(file_name)
    File.zero?(file_name)
  end
  
  def blank?
    File.zero?(self.path)
  end
end                  

class String  
  def path
    self.extend PathString
  end 
end

module PathString
  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

5 entries across 5 versions & 1 rubygems

Version Path
sugar-high-0.1.5 lib/sugar-high/file.rb
sugar-high-0.1.4 lib/sugar-high/file.rb
sugar-high-0.1.2 lib/sugar-high/file.rb
sugar-high-0.1.1 lib/sugar-high/file.rb
sugar-high-0.1.0 lib/sugar-high/file.rb