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.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(file, parent = nil, filesystem = nil) ⇒ Link
constructor
A new instance of Link.
- #save(path) ⇒ Object
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
#filesystem ⇒ Object
Returns the value of attribute filesystem.
23 24 25 |
# File 'lib/fffs/link.rb', line 23 def filesystem @filesystem 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
#content ⇒ Object
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 |