I'm trying to learn how to program with Ruby and I want to create separate files for separate classes, but when I do I get the following message:
NameError: uninitialized constant Book
const_missing at org/jruby/RubyModule.java:2677(root) at /Users/Friso/Documents/Projects/RubyApplication1/lib/main.rb:1
However, it works if I put the class directly into the main file. How can I solve this?
Main code:
book1 = Book.new("1234", "Hello", "Ruby")
book2 = Book.new("4321", "World", "Rails")
book1.to_string
book2.to_string
Class code:
class Book
def initialize(isbn,title,author)
@book_isbn=isbn
@book_title=title
@book_author=author
end
def to_string
puts "Title: #@book_title"
puts "Author: #@book_author"
puts "ISBN: #@book_isbn"
end
end
require_relative
?