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(name, file, parent = nil, filesystem = nil) ⇒ Link

Returns a new instance of Link.



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

def initialize (name, file, parent=nil, filesystem=nil)
  @parent = parent
  @name   = name
  @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

#nameObject

Returns the value of attribute name.



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

def name
  @name
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

#handleObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fffs/link.rb', line 40

def handle
  handle = self.filesystem

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

    break if !handle
  }

  return handle
end

#save(path) ⇒ Object



60
61
62
63
64
# File 'lib/fffs/link.rb', line 60

def save (path)
  require 'fileutils'

  FileUtils.ln_sf path, to
end