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 "colored" | |
# Mensagem de boas vindas | |
puts "-" * 50 | |
puts "Bem vindo ao supermercado Tabajara!".green | |
puts "-" * 50 | |
# Mostrar a lista de produtos com o respectivo preço | |
products = { | |
"kiwi" => {price: 1.25, stock: 5}, |
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 supermercado Tabajara!" | |
puts "-" * 50 | |
# Mostrar a lista de produtos com o respectivo preço | |
products = { | |
"kiwi" => 1.25, |
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 supermercado Tabajara!" | |
puts "-" * 50 | |
# Mostrar a lista de produtos com o respectivo preço | |
products = { | |
"kiwi" => 1.25, |
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
# Mostra uma mensagem de boas vindas | |
puts "Bem-vindo a nossa corrida de cavalo Tabajara" | |
horses = ["Pé de Pano", "Pegasus", "Alazão"] | |
balance = 100 # Saldo inicial | |
# INÍCIO DO LOOP | |
loop do |
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(first, second, operator) | |
result = case operator | |
when "+" then first + second | |
when "-" then first - second | |
when "*" then first * second | |
when "/" | |
if second == 0 | |
"Você não pode dividir por zero." | |
else | |
first / second |
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 |
NewerOlder