母が「動物」のクラスを構築し、子クラスを構築します。子クラスからマザークラスへの継承を行っていますが、コードに何か問題があり、これを修正する必要がありますが、うまくいきません助けてください私は初心者です
class Animal
def initialize
@name = "DigDok"
@age = 20
@sex = "male"
end
end
module Detail
def detail_set
@detail.join(',')
end
class Bird < Animal
def initialize
@detail = {
:wing => 2
:legs => 2
}
end
end
class Mammal < Animal
def initialize
@detail = {
:legs => 4
:babyfood => "Milk"
:special_ability => nil
}
end
end
class Cat < Animal
def initialize
@detail = {
:sharpclaws => "very Sharp"
:special_ability => "Climb a tree"
}
end
end
class Dog < Animal
def initialize
@detail = {
:best_friend => "Human"
:special_ability => "Bark"
}
end
end
end
しかし、irbターミナルで実行すると結果は
SyntaxError: ./learningruby.rb:25: syntax error, unexpected tSYMBEG, expecting '}'
:legs => 2
^
./learningruby.rb:30: class definition in method body
./learningruby.rb:34: syntax error, unexpected tSYMBEG, expecting '}'
:babyfood => "Milk"
^
./learningruby.rb:35: syntax error, unexpected tASSOC, expecting kEND
:special_ability => nil
^
./learningruby.rb:40: class definition in method body
./learningruby.rb:44: syntax error, unexpected tSYMBEG, expecting '}'
:special_ability => "Climb a tree"
^
./learningruby.rb:45: syntax error, unexpected '}', expecting kEND
./learningruby.rb:49: class definition in method body
./learningruby.rb:53: syntax error, unexpected tSYMBEG, expecting '}'
:special_ability => "Bark"
^
./learningruby.rb:54: syntax error, unexpected '}', expecting kEND
from (irb):1:in `require'
from (irb):1
from :0
私の質問が長くなって申し訳ありませんが、ありがとう...