title: Ruby: How to calculate a path relative to another one?
body: <p>Let's say I know the absolute path that I am starting from and the absolute path that I am trying to get to:</p>
  
  <pre><code>first = '/first/path'
  second = '/second/path'
  </code></pre>
  
  <p>Now I want to figure out how to construct a path that is relative to the first. For example:</p>
  
  <pre><code># answer should be /first/path/../../second/path
  path = second.get_path_relative_to(first)
  </code></pre>
  
  <p>How can I do this sort of thing in Ruby?</p>