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.



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

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)

rubocop:disable Style/MethodMissingSuper



32
33
34
# File 'lib/fakefs/fake/symlink.rb', line 32

def method_missing(*args, &block) # rubocop:disable Style/MethodMissingSuper
  entry.send(*args, &block)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/fakefs/fake/symlink.rb', line 4

def name
  @name
end

#parentObject

Returns the value of attribute parent.



4
5
6
# File 'lib/fakefs/fake/symlink.rb', line 4

def parent
  @parent
end

#targetObject

Returns the value of attribute target.



4
5
6
# File 'lib/fakefs/fake/symlink.rb', line 4

def target
  @target
end

Instance Method Details

#deleteObject



18
19
20
# File 'lib/fakefs/fake/symlink.rb', line 18

def delete
  parent.delete(self)
end

#entryObject



14
15
16
# File 'lib/fakefs/fake/symlink.rb', line 14

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

#inspectObject



10
11
12
# File 'lib/fakefs/fake/symlink.rb', line 10

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

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/fakefs/fake/symlink.rb', line 26

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

#to_sObject



22
23
24
# File 'lib/fakefs/fake/symlink.rb', line 22

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