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 add(gifts_list) | |
| #Perguntar qual item o usuário quer adicionar | |
| puts "Qual o nome do presente você gostaria de adicionar?".green_on_yellow |
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 add(gifts_list) | |
| #Perguntar qual item o usuário quer adicionar | |
| puts "Qual item você gostaria de adicionar?" | |
| #Ler a resposta do usuário | |
| name = gets.chomp | |
| #Armazenar a resposta | |
| gifts_list << { gift: name, marked: false } |
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
| #Criar a variável da lista de presentes | |
| gifts_list = [ "meia", "cueca", "macbook pro" ] | |
| def add(gifts_list) | |
| #Perguntar qual item o usuário quer adicionar | |
| puts "Qual item você gostaria de adicionar?" | |
| #Ler a resposta do usuário | |
| gift = gets.chomp | |
| #Armazenar a resposta | |
| gifts_list << gift |
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
| #Criar a variável da lista de presentes | |
| gifts_list = [] | |
| #Boas-vindas ao usuário | |
| puts "Bem-vind@ à sua lista de presentes de natal!" | |
| #Criar o loop do menu | |
| loop do | |
| #Apresentar o menu |
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
| # 'date' é uma biblioteca padrão no Ruby que nos permite trabalhar com datas. | |
| require 'date' | |
| # Definindo uma função chamada 'days_to_xmas'. Ela tem um parâmetro chamado 'today' que por padrão é a data de hoje. | |
| def days_to_xmas(today = Date.today) | |
| # Pegamos o ano da data 'today' e o atribuímos à variável 'xmas_year'. | |
| xmas_year = today.year | |
| # Criamos um novo objeto de data para o dia de Natal do ano atual. |
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 'date' | |
| def days_to_xmas(current_date) | |
| # pegar o ano da data corrente | |
| current_year = current_date.year | |
| # Pegar a data do natal | |
| xmas = Date.new(current_year, 12, 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 "-" * 30 | |
| puts "Bem vindos a Pé de Pano store" | |
| puts "-" * 30 | |
| # Definir os produtos (nome, preço, stock) disponíveis | |
| products = { | |
| "kiwi" => { price: 1.25, stock: 5 }, | |
| "banana" => { price: 0.5, stock: 6 }, | |
| "manga" => { price: 4.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 "-" * 30 | |
| puts "Bem vindos a Pé de Pano store" | |
| puts "-" * 30 | |
| # Definir os produtos (nome, preço) disponíveis | |
| products = { | |
| "kiwi" => 1.25, | |
| "banana" => 0.5, | |
| "manga" => 4.0, |
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 "-" * 30 | |
| puts "Bem vindos a Pé de Pano store" | |
| puts "-" * 30 | |
| # Definir os produtos (nome, preço) disponíveis | |
| products = { | |
| "kiwi" => 1.25, | |
| "banana" => 0.5, | |
| "manga" => 4.0, |
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
| # 1. Boas vindas a corrida de cavalos | |
| puts "Bem vindo a corrida de cavalos, quer apostar qual vai ganhar?" | |
| # 2. Definir os cavalos da competiçao | |
| horses = ["Malhado", "Pé de Pano", "Pangaré"] | |
| money = 100 # Dinheiro para a aposta | |
| loop do | |
| puts "Seu saldo é de #{money}." |
NewerOlder