[Ruby] Evolution of Eevee with Ruby

2 minute read

Hello. That’s right. I started 4/27 programming just two months ago. Currently I am studying Go exclusively, but since I did a Progate Ruby course on the first day of programming, I joined from Ruby. The reason I chose Ruby first was that it was a famous language that I hadn’t experienced two months ago, and I knew it, so I chose it because it seemed like a long one. I went through two Ruby courses over two days. I still remember clearly that I couldn’t understand at all from the second half. Lol After that, the first original app I made immediately to fix it came out when the folders were organized, so I will leave it as a record.

code

Its name is “Eevee”. That’s right, that eve. It’s just an app that lets you choose whether to use water stones or fire stones for Eevee and evolve it, and at the same time learn new techniques. Here is the code.

eevee.rb


class Pokemon

    attr_accessor :name, :sex, :skill

    def initialize(name:, sex:, skill:)
        @name = name
        @sex = sex
        @skill = skill
    end

    def who
        "Nice to meet you, it's #{@name}.\n My gender is #{@sex}.\n My special move is #{skill}."
    end
    
end

eevee = Pokemon.new(
    name:'Eevee',
    sex:'male',
    skill:'Tail the tail'
)

puts eevee.who



class Evolution <Pokemon
    attr_accessor :new_name

    def name_change
        @new_name = "hanako"
    end

    def who_e
        "Congratulations! Eevee has evolved into #{name}!\nI learned a new #{skill}!"
    end
    
end

fires = Evolution.new(
    name:'Fires',
    sex: nil,
    skill:'Kaenhousha'
)

showers = Evolution.new(
    name:'Showers',
    sex:nil,
    skill:'Rei Ubimu'
)

puts "Which stone do you want to use?\nPlease select.\n\n1. Flame stone \n2. Water stone"

answer = gets.chomp.to_i

if answer == 1
    puts fires.who_e

elsif answer == 2
    puts showers.who_e
end


#[email protected] The display name could not be assigned to the name entered in @name. ==================

# puts "Do you want to give a nickname?\nPlease select.\n\n1.Enable\n2.Not apply"
# nickname_answer = gets.chomp.to_i

# if nickname_answer == 1 && answer ==1
# puts "Please enter a new name."
# fires.name_change
# puts "The name has changed to #{@new_name}!"
# elsif nickname_answer == 1 && answer ==2
# puts "Please enter a new name."
# showers.name_change
# puts "The name has changed to #{@new_name}!"
# else
# puts "It's done."
# end

Impression

Even though I tried to give a nickname like an actual Pokemon, I was unable to attach it, and even commented that it was difficult. Lol At this time, I felt like I was confused and why I was able to do it, so I feel that I have grown up compared to two months ago. Since I made a Twitter-like app with Rails in May, I’ve been switching to Go and playing Go all the time, but I also want to touch Ruby before I completely forget it.

reference

I only bought the Kindle version of the Ruby book. I didn’t read much because I changed trains immediately, but it was just good for me who just finished Progate.

Tags:

Updated: