Class: FakeFS::FakeSymlink

Inherits:
Object
  • Object
show all
Defined in:
lib/fakefs/fake/symlink.rb

Overview

Fake symlink class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ FakeSymlink

Returns a new instance of FakeSymlink.



8
9
10
# File 'lib/fakefs/fake/symlink.rb', line 8

def initialize(target)
  @target = target
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object (private)



34
35
36
# File 'lib/fakefs/fake/symlink.rb', line 34

def method_missing(*args, &block)
  entry.send(*args, &block)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/fakefs/fake/symlink.rb', line 6

def name
  @name
end

#parentObject

Returns the value of attribute parent.



6
7
8
# File 'lib/fakefs/fake/symlink.rb', line 6

def parent
  @parent
end

#targetObject

Returns the value of attribute target.



6
7
8
# File 'lib/fakefs/fake/symlink.rb', line 6

def target
  @target
end

Instance Method Details

#deleteObject



20
21
22
# File 'lib/fakefs/fake/symlink.rb', line 20

def delete
  parent.delete(self)
end

#entryObject



16
17
18
# File 'lib/fakefs/fake/symlink.rb', line 16

def entry
  FileSystem.find(File.expand_path(target.to_s, parent.to_s))
end

#inspectObject



12
13
14
# File 'lib/fakefs/fake/symlink.rb', line 12

def inspect
  "symlink(#{name} -> #{target.split('/').last})"
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/fakefs/fake/symlink.rb', line 28

def respond_to_missing?(method, include_private = false)
  entry.respond_to?(method, include_private)
end

#to_sObject



24
25
26
# File 'lib/fakefs/fake/symlink.rb', line 24

def to_s
  File.join(parent.to_s, name)
end