title: Ruby get parent dir of current file
body: <p>I have simple script that should read excel and print two cells:</p>
  
  <pre><code>require 'rubygems'
  gem 'ruby-ole','1.2.11.4'
  require 'spreadsheet'
  
  class Filter
      # Gets zipcode range
      def get_zipcode_range
          wb = Spreadsheet.open "../data/zipcode_range.xls"
          sheet = wb.worksheet 0
          [sheet.cell(0, 0), sheet.cell(0, 1)]
      end
  end
  
  f = Filter.new
  puts f.get_zipcode_range
  </code></pre>
  
  <p>File structure is as follows:</p>
  
  <pre><code>FilterExcel
    data
      zipcode_range.xls
    lib
      filter.rb
  </code></pre>
  
  <p>When I open command prompt and go to FilterExcel\lib and run:</p>
  
  <pre><code>ruby filter.rb
  </code></pre>
  
  <p>It gives expected output:</p>
  
  <blockquote>
    <p>3911AW</p>
    
    <p>3911ZZ</p>
  </blockquote>
  
  <p>But when I run script from projects root folder, FilterExcel, then it raises error:</p>
  
  <blockquote>
    <p>C:\Documents and Settings\Erik\FilterExcel>ruby lib\filter.rb
    C:/Ruby193/lib/ruby/gems/1.9.1/gems/spreadsheet-0.7.4/lib/spreadsheet.rb:68:in
    'initialize': No such file or directory - ../data/zipcode_range.xls
    (Errno::ENOENT)
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/spreadsheet-0.7.4/lib/spreadsheet.rb:68:in
    'open'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/spreadsheet-0.7.4/lib/spreadsheet.rb:68:in
    'open'
            from lib/filter.rb:56:in 'get_zipcode_range'
            from lib/filter.rb:63:in ''</p>
  </blockquote>
  
  <p>P.S. I use Windows XP if that matters.</p>