How do you use a class from a different file?

Viewed 93

I'm trying to use a class from a different file.

something.rb

class Something
  def initialize
  end
  def getText
    'Some example text'
  end
end

another.rb

class Another
end

somethingVar = Something.new
puts somethingVar.getText

This gives me the error

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/chris/RubymineProjects/untitled1/another.rb
/home/chris/RubymineProjects/untitled1/another.rb:4:in `<top (required)>': uninitialized constant Something (NameError)
    from -e:1:in `load'
    from -e:1:in `<main>'

What am I doing wrong?

3 Answers
Related