Class: Omnizip::LinkHandler::SymbolicLink
- Inherits:
-
Object
- Object
- Omnizip::LinkHandler::SymbolicLink
- Defined in:
- lib/omnizip/link_handler/symbolic_link.rb
Overview
Model for symbolic links
Constant Summary collapse
- SYMLINK_PERMISSIONS =
Unix permissions for symbolic links (0120777)
0o120777
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
-
.deserialize(target_data, path: nil) ⇒ Object
Deserialize from archive storage.
Instance Method Summary collapse
-
#create(link_path) ⇒ Object
Create the symbolic link on the filesystem.
-
#hardlink? ⇒ Boolean
Check if this is a hard link.
-
#initialize(target:, path: nil) ⇒ SymbolicLink
constructor
A new instance of SymbolicLink.
-
#inspect ⇒ Object
Inspect representation.
-
#link_type ⇒ Object
Get the link type as string.
-
#permissions ⇒ Object
Get Unix permissions for symbolic links.
-
#serialize ⇒ Object
Serialize for archive storage (returns the target path).
-
#symlink? ⇒ Boolean
Check if this is a symbolic link.
-
#to_h ⇒ Object
Convert to hash representation.
-
#to_s ⇒ Object
String representation.
Constructor Details
#initialize(target:, path: nil) ⇒ SymbolicLink
Returns a new instance of SymbolicLink.
12 13 14 15 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 12 def initialize(target:, path: nil) @target = target @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 7 def path @path end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
7 8 9 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 7 def target @target end |
Class Method Details
.deserialize(target_data, path: nil) ⇒ Object
Deserialize from archive storage
33 34 35 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 33 def self.deserialize(target_data, path: nil) new(target: target_data, path: path) end |
Instance Method Details
#create(link_path) ⇒ Object
Create the symbolic link on the filesystem
18 19 20 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 18 def create(link_path) LinkHandler.create_symlink(@target, link_path) end |
#hardlink? ⇒ Boolean
Check if this is a hard link
43 44 45 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 43 def hardlink? false end |
#inspect ⇒ Object
Inspect representation
68 69 70 71 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 68 def inspect "#<Omnizip::LinkHandler::SymbolicLink target=#{@target.inspect} " \ "path=#{@path.inspect}>" end |
#link_type ⇒ Object
Get the link type as string
48 49 50 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 48 def link_type "symlink" end |
#permissions ⇒ Object
Get Unix permissions for symbolic links
23 24 25 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 23 def SYMLINK_PERMISSIONS end |
#serialize ⇒ Object
Serialize for archive storage (returns the target path)
28 29 30 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 28 def serialize @target end |
#symlink? ⇒ Boolean
Check if this is a symbolic link
38 39 40 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 38 def symlink? true end |
#to_h ⇒ Object
Convert to hash representation
53 54 55 56 57 58 59 60 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 53 def to_h { type: :symlink, target: @target, path: @path, permissions: , } end |
#to_s ⇒ Object
String representation
63 64 65 |
# File 'lib/omnizip/link_handler/symbolic_link.rb', line 63 def to_s "#{@path} -> #{@target} (symlink)" end |