Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

constant class inheritance not recognized ruby

I've been going around a bit for a while now, I don't understand why ruby ??doesn't recognize the constant, here is my code if you can help me.

app.rb

require 'bundler'
Bundler.require

require_relative 'lib/user'
require_relative 'lib/event'

binding.pry

and when I type that in my code to declare my event

meeting = WorkEvent.new("2019-01-17 09:00", 70, "réunion de travail", [julie, jean])

who is supposed to activate this part

class Event
    attr_accessor :start_date, :duration, :title, :attendees
    @@attendees = Array.new

    
    def initialize(start_date_register, duration_register, title_register, attendees_register)
        @start_date = Time.parse(start_date_register)
        @duration = duration_register.to_i
        @title = title_register
        @attendees = attendees_register
    end 


    class WorkEvent < Event
        def is_event_acceptable?
      
          if @attendees.length > 3 || @duration > 60
            puts "Cette réunion ne respecte pas nos bonnes pratiques !"
            return false
          else
            puts "Cette réunion est OK."
            return true
          end
        end
  end

and the terminal returns me

[6] pry(main)> meeting = WorkEvent.new("2019-01-17 09:00", 70, "réunion de travail", [julie, jean])
NameError: uninitialized constant WorkEvent
from (pry):6:in `<main>'
question from:https://stackoverflow.com/questions/65911979/constant-class-inheritance-not-recognized-ruby

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...