Class: CVEList::Directory
- Inherits:
-
Object
- Object
- CVEList::Directory
- Defined in:
- lib/cvelist/directory.rb
Overview
Represents a directory within the Repository.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
The path to the directory.
Instance Method Summary collapse
-
#directory?(name) ⇒ Boolean
Determines whether the directory has the given directory.
-
#file?(name) ⇒ Boolean
Determines whether the directory has the givne file.
-
#glob(pattern) ⇒ Array<String>
Finds all files and directories matching the pattern.
-
#initialize(path) ⇒ Directory
constructor
Initializes the directory.
-
#join(*names) ⇒ String
Joins the file/directory name(s) with the directory path.
-
#to_s ⇒ String
Converts the directory to a String.
Constructor Details
#initialize(path) ⇒ Directory
Initializes the directory.
18 19 20 |
# File 'lib/cvelist/directory.rb', line 18 def initialize(path) @path = File.(path) end |
Instance Attribute Details
#path ⇒ String (readonly)
The path to the directory.
10 11 12 |
# File 'lib/cvelist/directory.rb', line 10 def path @path end |
Instance Method Details
#directory?(name) ⇒ Boolean
Determines whether the directory has the given directory.
52 53 54 |
# File 'lib/cvelist/directory.rb', line 52 def directory?(name) File.directory?(join(name)) end |
#file?(name) ⇒ Boolean
Determines whether the directory has the givne file.
41 42 43 |
# File 'lib/cvelist/directory.rb', line 41 def file?(name) File.file?(join(name)) end |
#glob(pattern) ⇒ Array<String>
Finds all files and directories matching the pattern.
65 66 67 |
# File 'lib/cvelist/directory.rb', line 65 def glob(pattern) Dir[join(pattern)] end |
#join(*names) ⇒ String
Joins the file/directory name(s) with the directory path.
30 31 32 |
# File 'lib/cvelist/directory.rb', line 30 def join(*names) File.join(@path,*names) end |
#to_s ⇒ String
Converts the directory to a String.
75 76 77 |
# File 'lib/cvelist/directory.rb', line 75 def to_s @path end |