Class: Pairtree::Obj
- Inherits:
-
Dir
- Object
- Dir
- Pairtree::Obj
- 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
- #[](string) ⇒ Object
- #delete(*args) ⇒ Object (also: #unlink)
- #each(&block) ⇒ Object
- #entries ⇒ Object
- #glob(string, flags = 0) ⇒ Object
- #link(*args) ⇒ Object
- #rename(*args) ⇒ Object
- #utime(atime, mtime, *args) ⇒ Object
Instance Method Details
#[](string) ⇒ Object
41 42 43 |
# File 'lib/pairtree/obj.rb', line 41 def [](string) glob(string, 0) end |
#delete(*args) ⇒ Object Also known as: unlink
11 12 13 |
# File 'lib/pairtree/obj.rb', line 11 def delete *args File.delete(*prepend_filenames(args)) end |
#each(&block) ⇒ Object
32 33 34 |
# File 'lib/pairtree/obj.rb', line 32 def each &block super { |entry| yield(entry) unless /^\.{1,2}$/.match?(entry) } end |
#entries ⇒ Object
28 29 30 |
# File 'lib/pairtree/obj.rb', line 28 def entries super - [".", ".."] end |
#glob(string, flags = 0) ⇒ Object
36 37 38 39 |
# File 'lib/pairtree/obj.rb', line 36 def glob(string, flags = 0) result = Dir.glob(File.join(path, string), flags) - [".", ".."] result.collect { |f| f.sub(%r{^#{path}/}, "") } end |
#link(*args) ⇒ Object
16 17 18 |
# File 'lib/pairtree/obj.rb', line 16 def link *args File.link(*prepend_filenames(args)) end |
#rename(*args) ⇒ Object
20 21 22 |
# File 'lib/pairtree/obj.rb', line 20 def rename *args File.rename(*prepend_filenames(args)) end |
#utime(atime, mtime, *args) ⇒ Object
24 25 26 |
# File 'lib/pairtree/obj.rb', line 24 def utime atime, mtime, *args File.utime(atime, mtime, *prepend_filenames(args)) end |