Class: Pairtree::Obj

Inherits:
Dir
  • Object
show all
Defined in:
lib/pairtree/obj.rb

Constant Summary collapse

FILE_METHODS =
[:atime, :open, :read, :file?, :directory?, :exist?, :exists?, :file?, :ftype, :lstat, 
:mtime, :readable?, :size, :stat, :truncate, :writable?, :zero?]

Instance Method Summary collapse

Instance Method Details

#[](string) ⇒ Object



42
43
44
# File 'lib/pairtree/obj.rb', line 42

def [](string)
  glob(string, 0)
end

#delete(*args) ⇒ Object Also known as: unlink



12
13
14
# File 'lib/pairtree/obj.rb', line 12

def delete *args
  File.delete(*(prepend_filenames(args)))
end

#each(&block) ⇒ Object



33
34
35
# File 'lib/pairtree/obj.rb', line 33

def each &block
  super { |entry| yield(entry) unless entry =~ /^\.{1,2}$/ }
end

#entriesObject



29
30
31
# File 'lib/pairtree/obj.rb', line 29

def entries
  super - ['.','..']
end

#glob(string, flags = 0) ⇒ Object



37
38
39
40
# File 'lib/pairtree/obj.rb', line 37

def glob(string, flags = 0)
  result = Dir.glob(File.join(self.path, string), flags) - ['.','..']
  result.collect { |f| f.sub(%r{^#{self.path}/},'') }
end


17
18
19
# File 'lib/pairtree/obj.rb', line 17

def link *args
  File.link(*(prepend_filenames(args)))
end

#rename(*args) ⇒ Object



21
22
23
# File 'lib/pairtree/obj.rb', line 21

def rename *args
  File.rename(*(prepend_filenames(args)))
end

#utime(atime, mtime, *args) ⇒ Object



25
26
27
# File 'lib/pairtree/obj.rb', line 25

def utime atime, mtime, *args
  File.utime(atime, mtime, *(prepend_filenames(args)))
end