Class: FakeFS::FakeDir
- Inherits:
-
Hash
- Object
- Hash
- FakeFS::FakeDir
- Defined in:
- lib/fakefs/fake/dir.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #clone(parent = nil) ⇒ Object
- #delete(node = self) ⇒ Object
- #entry ⇒ Object
-
#initialize(name = nil, parent = nil) ⇒ FakeDir
constructor
A new instance of FakeDir.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name = nil, parent = nil) ⇒ FakeDir
Returns a new instance of FakeDir.
5 6 7 8 |
# File 'lib/fakefs/fake/dir.rb', line 5 def initialize(name = nil, parent = nil) @name = name @parent = parent end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/fakefs/fake/dir.rb', line 3 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
3 4 5 |
# File 'lib/fakefs/fake/dir.rb', line 3 def parent @parent end |
Instance Method Details
#clone(parent = nil) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/fakefs/fake/dir.rb', line 18 def clone(parent = nil) clone = Marshal.load(Marshal.dump(self)) clone.each do |key, value| value.parent = clone end clone.parent = parent if parent clone end |
#delete(node = self) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/fakefs/fake/dir.rb', line 37 def delete(node = self) if node == self parent.delete(self) else super(node.name) end end |
#entry ⇒ Object
10 11 12 |
# File 'lib/fakefs/fake/dir.rb', line 10 def entry self end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/fakefs/fake/dir.rb', line 14 def inspect "(FakeDir name:#{name.inspect} parent:#{parent.to_s.inspect} size:#{size})" end |
#to_s ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/fakefs/fake/dir.rb', line 27 def to_s if parent && parent.to_s != '.' File.join(parent.to_s, name) elsif parent && parent.to_s == '.' "#{File::PATH_SEPARATOR}#{name}" else name end end |