diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-19 09:31:52 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 12:48:13 +0100 |
commit | 518b206287318006f9b57382a747b1474b6795a4 (patch) | |
tree | 010b3b7f59798770288b574cfce3a285dbc0b93e /lib/gitlab | |
parent | 80a71576ba27d84b3406a8b929328359e2edc9da (diff) | |
download | gitlab-ce-518b206287318006f9b57382a747b1474b6795a4.tar.gz |
Add `parent` iteration implementation to `StringPath`
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/string_path.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/gitlab/string_path.rb b/lib/gitlab/string_path.rb index 3aa6200b572..3add56d2213 100644 --- a/lib/gitlab/string_path.rb +++ b/lib/gitlab/string_path.rb @@ -35,11 +35,12 @@ module Gitlab end def has_parent? - raise NotImplementedError + @universe.include?(@path.sub(basename, '')) end def parent - raise NotImplementedError + return nil unless has_parent? + new(@path.sub(basename, '')) end def directories @@ -58,5 +59,11 @@ module Gitlab def ==(other) @path == other.path && @universe == other.universe end + + private + + def new(path) + self.class.new(path, @universe) + end end end |