rubyinheritancevirtual-attribute

Virtual attributes and inheritance super with Ruby


I'm taking a ruby fundamentals counse in pluralsight but some of the code from the instructor isn't working. Could someone please explain what's missing & why whatever is missing is needed? Thank you so much

class Probe
  def deploy(deploy_time, return_time)
    puts "Deploying"
  end
end

class MineralProbe < Probe
  def deploy(deploy_time)
    puts "Preparing sample chamber"
    super(deploy_time, Time.now + 2 * 60)
  end
end

Mineralprobe.new.deploy(Time.now)

The error I'm getting is this: C:\Ruby26-x64\bin\ruby.exe C:/Users/-/RubymineProjects/test1/probe.rb Traceback (most recent call last): C:/Users/-/RubymineProjects/test1/probe.rb:14:in `': uninitialized constant Mineralprobe (NameError) Did you mean? MineralProbe

Process finished with exit code 1


Solution

  • There is a simple type the class is called

    class MineralProbe < Probe
                 ^
    

    but you try to initialize an instance of

    Mineralprobe.new.deploy(Time.now)
           ^