Module: SdocAll::Paths::ClassMethods

Included in:
SdocAll::Paths
Defined in:
lib/sdoc_all/parts/paths.rb

Instance Method Summary collapse

Instance Method Details

#common_path(paths) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/sdoc_all/parts/paths.rb', line 95

def common_path(paths)
  common = nil
  paths.each do |path|
    if common ||= path
      unless path.to_s.starts_with?(common.to_s)
        path.ascend do |path_part|
          if common.to_s.starts_with?(path_part)
            common = path_part
            break
          end
        end
      end
    end
  end
  common = common.parent if common
end