Method: Illustration#to_rel

Defined in:
lib/illustration.rb

#to_rel(base, target) ⇒ Object

絶対パスから相対パスを作成blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/36985



93
94
95
96
97
98
99
100
101
# File 'lib/illustration.rb', line 93

def to_rel(base, target)
  sep = /#{File::SEPARATOR}+/o
  base = base.split(sep)
  base.pop
  target = target.split(sep)
  while base.shift == target.shift
  end
  File.join([".."]*base.size+target)
end