pathname を使って次のように.
require 'pathname'
path = Pathname.new("/home/fumi/test.txt")
from = Pathname.new("/home/fumi/test/1")
relative_path = path.relative_path_from(from)
=> #<Pathname:../../test.txt>
pathname を使って次のように.
require 'pathname'
path = Pathname.new("/home/fumi/test.txt")
from = Pathname.new("/home/fumi/test/1")
relative_path = path.relative_path_from(from)
=> #<Pathname:../../test.txt>