title: Require Method in Ruby
body: <p>I have been searching around but I cant seem to find any answers for this problem.</p>
  
  <p>I am required to write a program that will use the reflection methods built into ruby to tell me information about a class a user will specify.</p>
  
  <p>I have this method:</p>
  
  <pre><code>def validFile(input)  
    filename = String.new()  
    filename = Dir.getwd + "/" + input  
    require(filename)  
  end  
  </code></pre>
  
  <p>however I get this error:  </p>
  
  <pre><code>internal:lib/rubygems/customrequire:29:in 'require' no such file to load --         C:\Users\David\Ruby Projects\MyTestClass.rb
  </code></pre>
  
  <p>I am not sure why this doesn't work but this does:</p>
  
  <pre><code>def validFile(input)
    filename = Dir.getwd + "/MyTestClass.rb"
    require(filename)
  end
  </code></pre>
  
  <p>This code doesn't help me because I have to have the user specify the file. I am using the gets method to get user input and that is being passed as a parameter to this method.</p>
  
  <p>Are they not both strings? What am I doing wrong here? Additional note, I'm running the latest version of ruby on Windows 7. Thanks for the help.</p>