diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-18 12:32:21 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 12:48:12 +0100 |
commit | 73d2c7a553ca239cdce04af793992fd579ad3e4b (patch) | |
tree | a679c1366a4b01e12da0579916082e1bb7853f07 /lib | |
parent | f5d530865875440d69217cf249715bffaa3d11b8 (diff) | |
download | gitlab-ce-73d2c7a553ca239cdce04af793992fd579ad3e4b.tar.gz |
Add new methods to StringPath
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/string_path.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/gitlab/string_path.rb b/lib/gitlab/string_path.rb index be65b41dff5..9ccf54bd62f 100644 --- a/lib/gitlab/string_path.rb +++ b/lib/gitlab/string_path.rb @@ -7,11 +7,17 @@ module Gitlab # # class StringPath + attr_reader :path, :universe + def initialize(path, universe) @path = path @universe = universe end + def to_s + @path + end + def absolute? @path.start_with?('/') end @@ -28,8 +34,17 @@ module Gitlab !directory? end - def to_s - @path + def files + raise NotImplementedError + end + + def basename + name = @path.split(::File::SEPARATOR).last + directory? ? name + ::File::SEPARATOR : name + end + + def ==(other) + @path == other.path && @universe == other.universe end end end |