Sha256: 4484555438fd306e5d310cfa552cae6d4153d397cdf699e25ccd4e14edfa0352
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'pathname' class FSPath < Pathname class << self # Return current user home path if called without argument. # If called with argument return specified user home path. def ~(name = nil) new(File.expand_path("~#{name}")) end end # Join paths using File.join def /(other) self.class.new(File.join(@path, other.to_s)) end unless (new('a') + 'b').is_a?(self) # Fixing Pathname.+ def +(part) self.class.new(super + part) end end # Write data to file def write(data) open('wb') do |f| f.write(data) end end # Append data to file def append(data) open('ab') do |f| f.write(data) end end # Escape characters in glob pattern def escape_glob self.class.new(@path.gsub(/([\*\?\[\]\{\}])/, '\\\\\1')) end # Expand glob def glob(*args, &block) flags = args.last.is_a?(Fixnum) ? args.pop : nil args = [File.join(self, *args)] args << flags if flags self.class.glob(*args, &block) end if RUBY_PLATFORM.downcase.include?('darwin') end end module Kernel # FSPath(path) method def FSPath(path) FSPath.new(path) end private :Pathname end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fspath-0.0.3-darwin | lib/fspath.rb |
fspath-0.0.3 | lib/fspath.rb |