Class: TestFs::Directory
Overview
Directory
Represents a single directory node.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
A collection of sub-directories or files contained in this directory.
Instance Method Summary collapse
-
#create! ⇒ Object
Create the current directory and any associated nodes (files / directories).
-
#dir(name) {|directory| ... } ⇒ Object
Register a sub-directory under the current directory.
-
#file(name) ⇒ Object
Register a file under the current directory.
-
#initialize(root_path, name) ⇒ Directory
constructor
Create a new directory at the given path with the supplied name.
Methods inherited from Node
Constructor Details
#initialize(root_path, name) ⇒ Directory
Create a new directory at the given path with the supplied name
15 16 17 18 |
# File 'lib/test_fs/directory.rb', line 15 def initialize(root_path, name) @nodes = [] super(root_path, name) end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
A collection of sub-directories or files contained in this directory
11 12 13 |
# File 'lib/test_fs/directory.rb', line 11 def nodes @nodes end |
Instance Method Details
#create! ⇒ Object
Create the current directory and any associated nodes (files / directories)
37 38 39 40 |
# File 'lib/test_fs/directory.rb', line 37 def create! FileUtils.mkdir(self.path) self.nodes.each {|node| node.create! } end |