Module: Crackup::FileSystemObject

Included in:
DirectoryObject, FileObject, SymlinkObject
Defined in:
lib/crackup/fs_object.rb

Overview

Represents a filesystem object on the local filesystem.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/crackup/fs_object.rb', line 7

def name
  @name
end

#name_hashObject (readonly)

Returns the value of attribute name_hash.



7
8
9
# File 'lib/crackup/fs_object.rb', line 7

def name_hash
  @name_hash
end

Class Method Details

.from(path) ⇒ Object

Returns an instance of the appropriate FileSystemObject subclass to represent path.

Raises:



15
16
17
18
19
20
21
# File 'lib/crackup/fs_object.rb', line 15

def self.from(path)
  return Crackup::SymlinkObject.new(path) if File.symlink?(path)
  return Crackup::DirectoryObject.new(path) if File.directory?(path)
  return Crackup::FileObject.new(path) if File.file?(path)
  
  raise Crackup::Error, "Unsupported filesystem object: #{path}"
end

Instance Method Details

#==(fs_object) ⇒ Object



32
# File 'lib/crackup/fs_object.rb', line 32

def ==(fs_object); end

#initialize(name) ⇒ Object

– Public Instance Methods ++



27
28
29
30
# File 'lib/crackup/fs_object.rb', line 27

def initialize(name)
  @name      = name.chomp('/')
  @name_hash = Digest::SHA256.hexdigest(name)
end

#removeObject



33
# File 'lib/crackup/fs_object.rb', line 33

def remove; end

#restore(path) ⇒ Object



34
# File 'lib/crackup/fs_object.rb', line 34

def restore(path); end

#to_sObject



36
37
38
# File 'lib/crackup/fs_object.rb', line 36

def to_s
  return @name
end

#updateObject



40
# File 'lib/crackup/fs_object.rb', line 40

def update; end