Class: Folio::Link
- Inherits:
-
FileObject
- Object
- FileObject
- Folio::Link
- Defined in:
- lib/folio/link.rb
Constant Summary
Constants inherited from FileObject
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Attributes inherited from FileObject
Instance Method Summary collapse
-
#initialize(path) ⇒ Link
constructor
A new instance of Link.
- #lchmod(mode) ⇒ Object
- #lchown(own, grp) ⇒ Object
- #lstat ⇒ Object
- #method_missing(s, *a, &b) ⇒ Object
- #readlink ⇒ Object
-
#symlink? ⇒ Boolean
(also: #link?)
– Am I write to think any file object can be linked? ++.
Methods inherited from FileObject
#<=>, #==, [], #atime, #basename, #blockdev?, #chardev?, #chmod, #chown, #cp, #ctime, #directory?, #dirname, #document?, #exist?, #extname, #fnmatch, #grpowned?, #identical?, #inspect, #install, #link, #link_force, #mtime, #owned?, #parent, #pipe?, #readable?, #readable_real?, #relative, #rename, #restat, #setgid?, #setuid?, #size, #size?, #socket?, #split, #stat, #sticky?, #symlink, #symlink_force, #to_s, #touch, #unlink, #unlink_force, #utime, #writable?, #writable_real?, #zero?
Constructor Details
#initialize(path) ⇒ Link
Returns a new instance of Link.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/folio/link.rb', line 7 def initialize(path) super raise LinkNotFound, "#{path}" unless ::File.symlink?(@path) dir = ::File.dirname(@path) name = ::File.readlink(@path) file = File.join(dir, name) @target = Folio.file(file) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(s, *a, &b) ⇒ Object
46 47 48 |
# File 'lib/folio/link.rb', line 46 def method_missing(s, *a, &b) @target.send(s, *a, &b) end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
18 19 20 |
# File 'lib/folio/link.rb', line 18 def target @target end |
Instance Method Details
#lchmod(mode) ⇒ Object
33 34 35 |
# File 'lib/folio/link.rb', line 33 def lchmod(mode) ::File.lchmod(mode, path) end |
#lchown(own, grp) ⇒ Object
37 38 39 |
# File 'lib/folio/link.rb', line 37 def lchown(own, grp) ::File.lchown(own, grp, path) end |
#lstat ⇒ Object
41 42 43 |
# File 'lib/folio/link.rb', line 41 def lstat ::File.lstat(path) end |
#readlink ⇒ Object
29 30 31 |
# File 'lib/folio/link.rb', line 29 def readlink ::File.readlink(path) end |
#symlink? ⇒ Boolean Also known as: link?
– Am I write to think any file object can be linked? ++
24 25 26 |
# File 'lib/folio/link.rb', line 24 def symlink? ::File.symlink?(path) end |