Class: Folio::Link

Inherits:
FileObject show all
Defined in:
lib/folio/link.rb

Constant Summary

Constants inherited from FileObject

FileObject::Separator

Instance Attribute Summary collapse

Attributes inherited from FileObject

#path

Instance Method Summary collapse

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.

Raises:



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

#targetObject (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

#lstatObject



41
42
43
# File 'lib/folio/link.rb', line 41

def lstat
  ::File.lstat(path)
end


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? ++

Returns:

  • (Boolean)


24
25
26
# File 'lib/folio/link.rb', line 24

def symlink?
  ::File.symlink?(path)
end