Class: Chitin::FileObject

Inherits:
FSObject show all
Defined in:
lib/chitin/file.rb

Direct Known Subclasses

Symlink

Instance Attribute Summary

Attributes inherited from FSObject

#path, #search

Instance Method Summary collapse

Methods inherited from FSObject

#directory?, #each, #files, #initialize, #lstat, #size, #symlink?, #to_a, #to_s, #unknown_type?

Constructor Details

This class inherits a constructor from Chitin::FSObject

Instance Method Details

#deleteObject



89
90
91
# File 'lib/chitin/file.rb', line 89

def delete
  File.safe_unlink @path
end

#executable?(force = false) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/chitin/file.rb', line 93

def executable?(force=false)
  @executable = force ? File.executable?(path) : @executable
end

#exists?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/chitin/file.rb', line 79

def exists?
  File.exists? path
end

#inspectObject



97
98
99
# File 'lib/chitin/file.rb', line 97

def inspect
  "#<Chitin::FileObject #{path.inspect}>"
end

#open(permissions, &block) ⇒ Object



83
84
85
86
87
# File 'lib/chitin/file.rb', line 83

def open(permissions, &block)
  File.open path, permissions do |f|
    block.call f
  end
end

#readable?(force = false) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/chitin/file.rb', line 71

def readable?(force=false)
  @readable = force ? File.readable(path) : @readable
end

#writeable?(force = false) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/chitin/file.rb', line 75

def writeable?(force=false)
  @writeable = force ? File.writeable?(path) : @writeable
end