Evolve Eevee with Ruby

Hello. That's right. I started programming on April 27, just two months ago. Currently, I am studying Go exclusively, but on the first day I started programming, I did a Ruby course at Progate, so I entered from Ruby. The reason I chose Ruby first was because it was a famous language that I knew two months ago, so I chose it because I wanted to wrap it in a long one without thinking deeply. I took two laps of the Ruby course over about two days. I still remember clearly that I couldn't understand at all from the second half. Lol After that, the first original application that I made immediately to fix it came out when I was organizing the folders, so I will keep it as a record.

code

Its name is also "Eevee". That's right, that Eevee. It's an app that lets you choose whether to use water stones or flame stones for Eevee, 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.#{@name}That's right.\n my gender is#{@sex}That's right.\n Special Moves#{skill}That's right."
    end
    
end

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

puts eevee.who



class Evolution < Pokemon
    attr_accessor :new_name

    def name_change
        @new_name = "hanako"
    end

    def who_e
        "Congrats! Eevee#{name}Has evolved into!\n new#{skill}I remembered!"
    end
    
end

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

showers = Evolution.new(
    name:'Vaporeon',
    sex:nil,
    skill:'Reito Beam'
)

puts "Which stone do you use?\n Please 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


#=================================@The name entered in name could not be assigned to display.==================

# puts "Do you want to give a nickname?\n Please select.\n\n1.Put on\n2.Do not attach"
# nickname_answer = gets.chomp.to_i

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

Impressions

I tried to give it a nickname like an actual Pokemon, but I couldn't give it a comment. Lol At this time, I was confused and felt that I was able to do it for some reason, so I feel that I have grown up compared to two months ago. Since I made a Twitter-like app with Rails in early May, I've been doing Go since I switched to Go, but I also want to touch Ruby before I completely forget it.

reference

-Introduction to Ruby for professionals From language specifications to test-driven development / debugging techniques (Software Design plus series)

I only bought the Kindle version of this Ruby book. I couldn't read much because I changed immediately, but it was just right for me who just finished Progate.

Recommended Posts

Evolve Eevee with Ruby
Install Ruby 3.0.0 with asdf
11th, Classification with Ruby
Ruby version switching with rbenv
Solve Google problems with Ruby
I tried DI with Ruby
GraphQL Client starting with Ruby
Leap year judgment with Ruby
Format Ruby with VS Code
Integer check method with ruby
Ruby Learning # 8 Working With String
[Ruby] problem with if statement
Studying with CodeWar (ruby) ⑤ proc
Getting Started with Ruby Modules
[ruby] Method call with argument
Ruby Scraping-Move Selenium Headless with VPS.
Learning Ruby with AtCoder 6 [Contest 168 Therefore]
Let's use Amazon Textract with Ruby
Programming with ruby (on the way)
Studying with CodeWar (ruby) ④ case ~ when
Handle DatePicker with Ruby / gtk3 + glade3
Impressions of making BlackJack-cli with Ruby
Install ruby on Ubuntu 20.04 with rbenv
Make a typing game with ruby
With ruby ● × Game and Othello (basic review)
Solve with Ruby AtCoder ABC177 D UnionFind
Handle application/pdf response as File with ruby
Send an email from gmail with Ruby
Getting Started with Ruby for Java Engineers
Introduction to Ruby basic grammar with yakiniku
Learning Ruby with AtCoder 7 [Contest 168 Triple Dots]
Let's make draw poker with ruby ~ Preparation ~
Ruby / Rust linkage (3) Numerical calculation with FFI
Notes on using FCM with Ruby on Rails
[Ruby on Rails] Controller test with RSpec
Let's make a smart home with Ruby!
I made a risky die with Ruby
Authenticate child accounts with Stripe Connect | Ruby
[Ruby on Rails] Model test with RSpec
Ruby / Rust linkage (4) Numerical calculation with Rutie
[At Coder] Introducing Competitive Pro with Ruby
Convert JSON to TSV and TSV to JSON with Ruby