Class: FFFS::Link
- Inherits:
-
Object
- Object
- FFFS::Link
- Defined in:
- lib/fffs/link.rb
Instance Attribute Summary collapse
-
#filesystem ⇒ Object
Returns the value of attribute filesystem.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(name, file, parent = nil, filesystem = nil) ⇒ Link
constructor
A new instance of Link.
- #save(path) ⇒ Object
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
#filesystem ⇒ Object
Returns the value of attribute filesystem.
23 24 25 |
# File 'lib/fffs/link.rb', line 23 def filesystem @filesystem end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/fffs/link.rb', line 26 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
23 24 25 |
# File 'lib/fffs/link.rb', line 23 def parent @parent end |
#to ⇒ Object
Returns the value of attribute to.
25 26 27 |
# File 'lib/fffs/link.rb', line 25 def to @to end |
Instance Method Details
#handle ⇒ Object
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 |