Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/gonzui/util.rb
Class Method Summary collapse
- .any_exist?(path) ⇒ Boolean
-
.relative_path(path, base) ⇒ Object
FIXME: Use pathname.rb ?.
Class Method Details
.any_exist?(path) ⇒ Boolean
217 218 219 |
# File 'lib/gonzui/util.rb', line 217 def self.any_exist?(path) File.exist?(path) or File.symlink?(path) end |
.relative_path(path, base) ⇒ Object
FIXME: Use pathname.rb ?
205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/gonzui/util.rb', line 205 def self.relative_path(path, base) return "" if path == base re_terminated_with_path_separator = /#{File::SEPARATOR}$/ sep = if re_terminated_with_path_separator.match(base) "" else File::SEPARATOR end pattern = sprintf("^%s%s", Regexp.quote(base), sep) path.sub(Regexp.new(pattern), "") end |