Last active
September 3, 2018 02:01
-
-
Save luizpicolo/4674e27ac305c859d3c1056e98fca036 to your computer and use it in GitHub Desktop.
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 salvar_livro(livro_attrs = {}) | |
File.open('livros', 'a') do |livro| | |
livro_attrs.each {|k, v| livro.puts "#{k}: #{v}" } | |
end | |
end | |
def condicional_para_saida(condicional) | |
return false if condicional == 2 | |
return true | |
end | |
init = true | |
while init | |
livro_attrs = {} | |
puts 'Digite o titulo' | |
livro_attrs["Titulo"] = gets | |
puts 'Digite a categoria' | |
livro_attrs["Categoria"] = gets | |
puts 'Digite o autor' | |
livro_attrs["Autor"] = gets | |
puts 'Digite o isbn' | |
livro_attrs["Isbn"] = gets | |
salvar_livro(livro_attrs) | |
puts 'Deseja cadastrar mais? 2 para não' | |
condicional = gets.to_i | |
init = condicional_para_saida(condicional) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment