ruby in 100 minutes good_morning method issue

Posted by user2525947 on Stack Overflow See other posts from Stack Overflow or by user2525947
Published on 2013-06-26T22:10:19Z Indexed on 2013/06/26 22:21 UTC
Read the original article Hit count: 283

Filed under:
|
|
|

I have been doing the Ruby in 100 minutes on the JumpStart labs website, and encountered a problem during part 5.

I was asked to create a good_morning method that would print out a greeting such as 'Happy Monday, it's the 130 day of 2013'. Here is my current program:

class PersonalChef

    def good_morning

        today = Date.today.strftime("%A")
        day_of_year = Date.today.yday
        puts "Happy#{today}! It is the #{day_of_year} day of year."
        return self
            end

    def make_toast(color)
        puts " Making your toast #{color}!"
        return self
       end
    def make_milkshake(flavor)
        puts " Making a #{flavor} milkshake!"
        return self
       end

    def make_eggs(quantity)
        puts " Making you #{quantity} eggs!"
        return self
            end 
            end

when I try to run the program load on irb( 'personal_chef.rb', frank = PersonalChef.new, frank.make_milkshake('chocolate'), etc, everything works fine until I try to type frank.good_morning into irb, which gives the following error message:

NameError: uninitialized constant PersonalChef :: Date from personal_chef.rb:5: in good_morning from (irb):3 from /bin/irb:12:in '' Any help or information to help me solve this issue would be greatly appreciated. Thanks for your time!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about constants