Module: Delfos::FileSystem::CommonPath
- Defined in:
- lib/delfos/file_system/common_path.rb
Constant Summary collapse
- SEPARATOR =
"/"
Class Method Summary collapse
Class Method Details
.common_parent(path_a, path_b) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/delfos/file_system/common_path.rb', line 17 def common_parent(path_a, path_b) dirs = [ File.(path_a.to_s), File.(path_b.to_s), ] dir1, dir2 = dirs.minmax.map { |dir| dir.split(SEPARATOR) } path_from(dir1, dir2, path_a, path_b) end |
.included_in?(p1, paths) ⇒ Boolean
10 11 12 13 14 15 |
# File 'lib/delfos/file_system/common_path.rb', line 10 def included_in?(p1, paths) paths.any? do |p2| common = common_parent(p1, p2) common.to_s.length >= p2.to_s.length end end |