Class: FakeFS::FakeDir
- Inherits:
-
Hash
- Object
- Hash
- FakeFS::FakeDir
- Defined in:
- lib/fakefs/fake/dir.rb
Instance Attribute Summary collapse
-
#ctime ⇒ Object
readonly
Returns the value of attribute ctime.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#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.
6 7 8 9 10 11 |
# File 'lib/fakefs/fake/dir.rb', line 6 def initialize(name = nil, parent = nil) @name = name @parent = parent @ctime = Time.now @mtime = @ctime end |
Instance Attribute Details
#ctime ⇒ Object (readonly)
Returns the value of attribute ctime.
4 5 6 |
# File 'lib/fakefs/fake/dir.rb', line 4 def ctime @ctime end |
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
4 5 6 |
# File 'lib/fakefs/fake/dir.rb', line 4 def mtime @mtime end |
#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
21 22 23 24 25 26 27 28 |
# File 'lib/fakefs/fake/dir.rb', line 21 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
40 41 42 43 44 45 46 |
# File 'lib/fakefs/fake/dir.rb', line 40 def delete(node = self) if node == self parent.delete(self) else super(node.name) end end |
#entry ⇒ Object
13 14 15 |
# File 'lib/fakefs/fake/dir.rb', line 13 def entry self end |
#inspect ⇒ Object
17 18 19 |
# File 'lib/fakefs/fake/dir.rb', line 17 def inspect "(FakeDir name:#{name.inspect} parent:#{parent.to_s.inspect} size:#{size})" end |
#to_s ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/fakefs/fake/dir.rb', line 30 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 |