-2

I am working on a small app in Ruby. The file is called "cookbook.rb" and it is saved on my Mac desktop.

At first I type

cd desktop 

which takes me into desktop, and then I try and load the file so that I can check it out in irb. I type this:

load 'cookbook.rb'

and I keep getting this error:

SyntaxError: cookbook.rb:11: syntax error, unexpected keyword_end, expecting end-of-input
from (irb):1:in `load'
from (irb):1
from /usr/bin/irb:12:in `<main>'

Can someone tell me what I'm doing wrong? I followed the same directions that I used to create and work on another .rb file, and it worked just fine before.

Sorry for the confusion...here is the file cookbook.rb

 Cookbook = Class.new

 Recipe = Class.new

 Class Cookbook
     def initialize(title)
         @title = title
     end
 end

Class Recipe
    def initialize(title, ingredients, steps)
        @title = title
        @ingredients = ingredients
        @steps = steps
    end
end
6
  • 1
    The error has nothing to do with Mac, your directory, terminal, or irb. You need to show the content of cookbook.rb.
    – sawa
    Sep 13, 2014 at 0:42
  • The error is in the cookbook.rb file
    – JTG
    Sep 13, 2014 at 0:43
  • sawa....forgive me if my question is silly. I am not sure what you mean exactly...like I mentioned above, it worked before and I am not sure if I "showed" content when it worked on previous occasions Sep 13, 2014 at 0:45
  • so there is an error in my file? Sep 13, 2014 at 0:46
  • What I meant by "show" is that you should write it in this question here.
    – sawa
    Sep 13, 2014 at 0:46

1 Answer 1

1

Change Class to class, i.e., the keyword class should be written in lower case.

class Cookbook
    def initialize(title)
        @title = title
    end
end

class Recipe
    def initialize(title, ingredients, steps)
        @title = title
        @ingredients = ingredients
        @steps = steps
    end
end
1
  • Thanks buddy...very much appreceiated Sep 13, 2014 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.