This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "csv" | |
require "open-uri" | |
require "nokogiri" | |
require "colored" | |
FILEPATH = "gifts.csv" | |
def list(gifts) | |
puts "Aqui está sua lista:" | |
# gift é um hash do tipo: {name: "Meia", bought: true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "csv" | |
FILEPATH = "gifts.csv" | |
def list(gifts) | |
puts "Aqui está sua lista:" | |
# gift é um hash do tipo: {name: "Meia", bought: true} | |
gifts.each_with_index do |gift, index| | |
bought = gift[:bought] ? "[X]" : "[ ]" | |
puts "#{index + 1} - #{bought} - #{gift[:name]}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gifts = [] | |
def list(gifts) | |
puts "Aqui está sua lista:" | |
gifts.each_with_index do |gift, index| | |
puts "#{index + 1} - #{gift}" | |
end | |
end | |
def add(gifts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mensagem de Boas Vindas | |
puts "Seja Bem vindo a sua lista" | |
# LOOP | |
loop do | |
# Informar e perguntar qual opção | |
puts "Which action [list|add|delete|quit]?" | |
action = gets.chomp.downcase | |
#Executar (fake) a opção selecionada |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mensagem de boas vindas | |
puts '-' * 50 | |
puts "Bem-vindo ao nosso mercado" | |
products = { "kiwi" => {price: 1.25, stock: 5}, | |
"banana" => {price: 0.5, stock: 10}, | |
"mango" => {price: 4.0, stock: 6}, | |
"asparagus" => {price: 9.0, stock: 3} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mensagem de boas vindas | |
puts '-' * 50 | |
puts "Bem-vindo ao nosso mercado" | |
puts '-' * 50 | |
# Exibir produtos com o respectivo preço | |
products = { "kiwi" => 1.25, | |
"banana" => 0.5, | |
"mango" => 4, | |
"asparagus" => 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mensagem de boas vindas | |
puts '-' * 50 | |
puts "Bem-vindo ao nosso mercado" | |
puts '-' * 50 | |
# Exibir produtos com o respectivo preço | |
products = { "kiwi" => 1.25, | |
"banana" => 0.5, | |
"mango" => 4, | |
"asparagus" => 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mensagem de boas vindas | |
puts "Bem vinda a nossa Bet" | |
horses = ["Pangare", "pé de pano", "Faisca"] | |
wallet = 100 | |
loop do # INICIO DO LOOP | |
puts "-" * 50 | |
puts "você tem #{wallet}" | |
# Mostrar os cavalos no páreo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculator(number1, number2, operator) | |
# Executar a operação com o 2 números e armazenar o resultado | |
result = case operator | |
when "+" then number1 + number2 | |
when "-" then number1 - number2 | |
when "*" then number1 * number2 | |
when "/" then number1 / number2 | |
end | |
return result |
NewerOlder