Class: FFFS::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/fffs/link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, parent = nil, filesystem = nil) ⇒ Link

Returns a new instance of Link.



27
28
29
30
# File 'lib/fffs/link.rb', line 27

def initialize (file, parent=nil, filesystem=nil)
  @parent = parent
  @to     = file
end

Instance Attribute Details

#filesystemObject

Returns the value of attribute filesystem.



23
24
25
# File 'lib/fffs/link.rb', line 23

def filesystem
  @filesystem
end

#parentObject

Returns the value of attribute parent.



23
24
25
# File 'lib/fffs/link.rb', line 23

def parent
  @parent
end

#toObject

Returns the value of attribute to.



25
26
27
# File 'lib/fffs/link.rb', line 25

def to
  @to
end

Instance Method Details

#contentObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fffs/link.rb', line 32

def content
  handle = self.filesystem

  @to.split('/').reject {|s| s.empty?}.each {|path|
    handle = handle[path]

    break if !handle
  }

  if handle
    handle.content rescue ''
  end
end

#save(path) ⇒ Object



46
47
48
49
50
# File 'lib/fffs/link.rb', line 46

def save (path)
  require 'fileutils'

  FileUtils.ln_sf path, to
end