# introduction

Maintenant que j'étudie le rubis sur rails, je vais écrire la syntaxe de base pour que je puisse la comprendre.

# Qu'est-ce que le rubis

Qu'est-ce que le rubis?

• Langage d'interprétation (<-> langage du compilateur) --Langage typé dynamique (<-> langage typé statiquement)
• Orienté objet (<->)

Une langue caractérisée par. (Je pense qu'il y en a beaucoup d'autres)

# Syntaxe de base

## production

``````
count = 10
hello = "Hello"

puts count #42
puts hello #"Hello"

puts "#{hello} #{42}tokyo"  #Hello 42tokyo
``````

## Hash et tableau

``````#Tableau

colors = [red, blue, green, pink, white]

#hacher

#Les trois lignes ci-dessous sont identiques
exam1 = {"subject" => "math", "score" => 100}
exam1 = {:subject=> "math", :score => 100}
exam1 = {subject: "math", score: 100}

exams = [
{subject: "math", score: 100},
{subject: "english", score: 40},
{subject: "japanese", score: 60},
{subject: "science", score: 90}
]

``````

for, while

``````for i in [0,1,2,3] do
puts i
end

index = 0
while index <= 10 do
puts index
end
``````

each

``````colors = [red, blue, green, pink, white]

colors.each do |color|
puts color
end
``````

## Méthode (fonction)

``````def hello
puts "Hello World"
end

def hello(num, name)
puts "Hello #{num}#{name}"
end

#hello(42, tokyo) -> Hello 42tokyo
``````

# Système de commande de nourriture

``````

puts "=== this is menu ==="
index = 0
index += 1
end
puts "===================="

order = gets.chomp.to_i

puts "how many?"

count = gets.chomp.to_i

``````
``````class Menu
attr_accessor :name
attr_accessor :price

def initialize(name:, price:) #Voici la variable de l'instance
self.name = name
self.price = price
end

def info
return "#{self.name} #{self.price}Cercle"
end

def get_total_price(count)
total_price = self.price * count
if count >= 3
total_price -= 100
end
end
end

``````
``````=== this is menu ===
0 :sushi 1000 yens
1 :pomme 120 yens
2 :banane 100 yens
3 :citron 80 yens
====================