This file contains 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 um método chamado 'days_to_xmas'. | |
# Ela tem um parâmetro chamado 'today' que recebe o dia ao qual se deve calcular. | |
def days_to_xmas(today) | |
year = today.year | |
xmas_date = Date.new(year, 12, 25) | |
days = (xmas_date - today).to_i |
We can't make this file beautiful and searchable because it's too large.
This file contains 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
Criteria ID,Name,Canonical Name,Parent ID,Country Code,Target Type,Status | |
"1000002","Kabul","Kabul,Kabul,Afghanistan","9075393","AF","City",Active | |
"1000003","Luanda","Luanda,Luanda Province,Angola","9070431","AO","City",Active | |
"1000004","The Valley","The Valley,Anguilla","2660","AI","City",Active | |
"1000007","Kralendijk","Kralendijk,Bonaire,Caribbean Netherlands","9075436","BQ","City",Active | |
"1000008","Philipsburg","Philipsburg,Sint Maarten","2534","SX","City",Active | |
"1000009","Willemstad","Willemstad,Curacao","2531","CW","City",Active | |
"1000010","Abu Dhabi","Abu Dhabi,Abu Dhabi,United Arab Emirates","9041082","AE","City",Active | |
"1000011","Ajman","Ajman,Ajman,United Arab Emirates","9047096","AE","City",Active | |
"1000012","Al Ain","Al Ain,Abu Dhabi,United Arab Emirates","9041082","AE","City",Active |
This file contains 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' | |
require 'csv' | |
require 'open-uri' | |
require 'nokogiri' | |
FILEPATH = 'gifts.csv' | |
# Os gifts estão em um array de hash como: | |
# [ | |
# { name: 'Meia', bought: true, price: 200 }, |
This file contains 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' | |
require 'csv' | |
FILEPATH = 'gifts.csv' | |
# Os gifts estão em um array de hash como: | |
# [ | |
# { name: 'Meia', bought: true }, | |
# { name: 'iPhone', bought: false } | |
#] |
This file contains 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' | |
require 'csv' | |
FILEPATH = 'gifts.csv' | |
def list(gifts) | |
gifts.each_with_index do |gift, index| | |
puts "#{index + 1} - #{gift}" | |
end | |
end |
This file contains 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 ao Mercado Tabajara" | |
puts '-' * 30 | |
products = { | |
"kiwi" => { stock: 5, price: 1.25 }, | |
"banana" => { stock: 10, price: 0.50 }, | |
"mango" => { stock: 3, price: 4 }, | |
"apple" => { stock: 25, price: 3 } |
This file contains 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 ao Mercado Tabajara" | |
puts "-" * 30 | |
products= { | |
"kiwi" => 1.25, | |
"banana" => 0.50, | |
"mango" => 4, | |
"apple" => 3 | |
} |
This file contains 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 ao Mercado Tabajara" | |
puts "-" * 30 | |
products= { | |
"kiwi" => 1.25, | |
"banana" => 0.50, | |
"mango" => 4, | |
"apple" => 3 | |
} |
This file contains 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
account = 100 | |
# 1. Boas vindas à corrida | |
puts "Bem vindo a corrida de cavalos Tabajara!" | |
horses = %w[preto malhado branco pe-de-pano pegasus] | |
loop do | |
puts "Seu saldo é de #{account}" |
This file contains 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) | |
case operator | |
when "+" then number1 + number2 | |
when "-" then number1 - number2 | |
when "/" then number2 == 0 ? "Inválido" : number1 / number2 | |
when "*" then number1 * number2 | |
else | |
"Inválido" | |
end | |
end |
NewerOlder