Skip to content

Instantly share code, notes, and snippets.

@FerPerales
Last active December 11, 2015 18:19
Show Gist options
  • Save FerPerales/4640937 to your computer and use it in GitHub Desktop.
Save FerPerales/4640937 to your computer and use it in GitHub Desktop.
Ejercicios RoRBootcamp día 1
def factorial(valor = 1)
acum = 1
(1..valor).each {|x| acum = acum * x}
return acum
end
class Person
def initialize values
@values = values
end
def method_missing method
if @values.has_key? method
return @values[method]
else
super method
end
end
end
preguntas = [
"Cual es tu nombre?",
"Cuando es tu graduacion?",
"Donde vives?",
"De donde eres?",
"A que horas sales por el pan?",
"A que te dedicas?",
"Eres soltero?",
"Usas Linux?",
"Que musica escuchas?",
"Te gusta el futbol?"
]
respuesta = :empty
while (respuesta.to_sym != :bye)
puts preguntas.sample
respuesta = gets.chomp
puts "Gracias por tu respuesta" unless respuesta.to_sym == :bye
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment