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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_hash ⇒ Object
readonly
Returns the value of attribute name_hash.
Class Method Summary collapse
-
.from(path) ⇒ Object
Returns an instance of the appropriate FileSystemObject subclass to represent path.
Instance Method Summary collapse
- #==(fs_object) ⇒ Object
-
#initialize(name) ⇒ Object
– Public Instance Methods ++.
- #remove ⇒ Object
- #restore(path) ⇒ Object
- #to_s ⇒ Object
- #update ⇒ Object
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/crackup/fs_object.rb', line 7 def name @name end |
#name_hash ⇒ Object (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.
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 |
#remove ⇒ Object
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_s ⇒ Object
36 37 38 |
# File 'lib/crackup/fs_object.rb', line 36 def to_s return @name end |
#update ⇒ Object
40 |
# File 'lib/crackup/fs_object.rb', line 40 def update; end |