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

Instance Method Summary collapse

Methods inherited from FSObject

#initialize, #lstat, #to_s, #unknown_type?

Constructor Details

This class inherits a constructor from Chitin::FSObject

Instance Method Details

#deleteObject



46
47
48
# File 'lib/chitin/file.rb', line 46

def delete
  File.safe_unlink @path
end

#executable?(force = false) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/chitin/file.rb', line 50

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

#exists?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/chitin/file.rb', line 36

def exists?
  File.exists? path
end

#inspectObject



54
55
56
# File 'lib/chitin/file.rb', line 54

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

#open(permissions, &block) ⇒ Object



40
41
42
43
44
# File 'lib/chitin/file.rb', line 40

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

#readable?(force = false) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/chitin/file.rb', line 28

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

#symlink?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/chitin/file.rb', line 58

def symlink?
  false
end

#writeable?(force = false) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/chitin/file.rb', line 32

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