Class: File
Class Method Summary collapse
-
.equivalent?(a, b) ⇒ Boolean
gives true if one of the paths is the ending of another path.
Class Method Details
.equivalent?(a, b) ⇒ Boolean
gives true if one of the paths is the ending of another path
File.equivalent?('b/a.rb', 'a.rb') # ==> true File.equivalent?('c/b/a.rb', 'c/a.rb') # ==> false
17 18 19 20 21 22 23 |
# File 'lib/sitefuel/extensions/FileComparison.rb', line 17 def self.equivalent?(a, b) list = [ File.(a, '/').split(File::SEPARATOR)[1 .. -1], File.(b, '/').split(File::SEPARATOR)[1 .. -1] ].sort {|l,r| l.length <=> r.length }.reverse list.first.ends_with? list.last end |