Class methods (ruby)
问题 Newbie here, having a hard time understanding Class methods and why I cannot get an attribute to show up correctly in the instance. class Animal attr_accessor :noise, :color, :legs, :arms def self.create_with_attributes(noise, color) animal = self.new(noise) @noise = noise @color = color return animal end def initialize(noise, legs=4, arms=0) @noise = noise @legs = legs @arms = arms puts "----A new animal has been instantiated.----" end end animal1 = Animal.new("Moo!", 4, 0) puts animal1