diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-21 10:11:15 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 12:48:13 +0100 |
commit | d382335dcd9285c9355ed04dc12c5314bca3c024 (patch) | |
tree | 598ed4a68aa4b2e349bde636850ab4479e69545b /lib | |
parent | c184eeb8489a389bf9f3528f7fe012d1edf132cb (diff) | |
download | gitlab-ce-d382335dcd9285c9355ed04dc12c5314bca3c024.tar.gz |
Add implementation of remaining methods in `StringPath`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/string_path.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/gitlab/string_path.rb b/lib/gitlab/string_path.rb index 3add56d2213..a2dc63db2f2 100644 --- a/lib/gitlab/string_path.rb +++ b/lib/gitlab/string_path.rb @@ -43,12 +43,24 @@ module Gitlab new(@path.sub(basename, '')) end + def descendants + return [] unless directory? + children = @universe.select { |entry| entry =~ /^#{@path}.+/ } + children.map { |path| new(path) } + end + + def children + descendants.select { |descendant| descendant.parent == self } + end + def directories - raise NotImplementedError + return [] unless directory? + children.select { |child| child.directory? } end def files - raise NotImplementedError + return [] unless directory? + children.select { |child| child.file? } end def basename |