Class: CukeModeler::Directory
- Inherits:
-
Object
- Object
- CukeModeler::Directory
- Includes:
- Containing, Nested
- Defined in:
- lib/cuke_modeler/directory.rb
Overview
A class modeling a directory containing .feature files.
Instance Attribute Summary collapse
-
#directories ⇒ Object
The Directory objects contained by the Directory.
-
#feature_files ⇒ Object
The FeatureFile objects contained by the Directory.
-
#path ⇒ Object
The file path of the Directory.
Attributes included from Nested
Instance Method Summary collapse
-
#contains ⇒ Object
Returns the immediate child elements of the directory (i.e. its Directory and FeatureFile objects).
-
#directory_count ⇒ Object
Returns the number of sub-directories contained in the directory.
-
#feature_file_count ⇒ Object
Returns the number of features files contained in the directory.
-
#initialize(directory_parsed = nil) ⇒ Directory
constructor
Creates a new Directory object and, if directory_parsed is provided, populates the object.
-
#name ⇒ Object
Returns the name of the directory.
-
#to_s ⇒ Object
Returns the path of the directory.
Methods included from Nested
Constructor Details
#initialize(directory_parsed = nil) ⇒ Directory
Creates a new Directory object and, if directory_parsed is provided, populates the object.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cuke_modeler/directory.rb', line 23 def initialize(directory_parsed = nil) @path = directory_parsed @feature_files = [] @directories = [] if directory_parsed raise(ArgumentError, "Unknown directory: #{directory_parsed.inspect}") unless File.exists?(directory_parsed) build_directory end end |
Instance Attribute Details
#directories ⇒ Object
The Directory objects contained by the Directory
15 16 17 |
# File 'lib/cuke_modeler/directory.rb', line 15 def directories @directories end |
#feature_files ⇒ Object
The FeatureFile objects contained by the Directory
12 13 14 |
# File 'lib/cuke_modeler/directory.rb', line 12 def feature_files @feature_files end |
#path ⇒ Object
The file path of the Directory
18 19 20 |
# File 'lib/cuke_modeler/directory.rb', line 18 def path @path end |
Instance Method Details
#contains ⇒ Object
Returns the immediate child elements of the directory (i.e. its Directory and FeatureFile objects).
51 52 53 |
# File 'lib/cuke_modeler/directory.rb', line 51 def contains @feature_files + @directories end |
#directory_count ⇒ Object
Returns the number of sub-directories contained in the directory.
40 41 42 |
# File 'lib/cuke_modeler/directory.rb', line 40 def directory_count @directories.count end |
#feature_file_count ⇒ Object
Returns the number of features files contained in the directory.
45 46 47 |
# File 'lib/cuke_modeler/directory.rb', line 45 def feature_file_count @feature_files.count end |
#name ⇒ Object
Returns the name of the directory.
35 36 37 |
# File 'lib/cuke_modeler/directory.rb', line 35 def name File.basename(@path.gsub('\\', '/')) if @path end |
#to_s ⇒ Object
Returns the path of the directory.
56 57 58 |
# File 'lib/cuke_modeler/directory.rb', line 56 def to_s path.to_s end |