Last active
December 11, 2015 18:19
-
-
Save FerPerales/4640937 to your computer and use it in GitHub Desktop.
Ejercicios RoRBootcamp día 1
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 factorial(valor = 1) | |
acum = 1 | |
(1..valor).each {|x| acum = acum * x} | |
return acum | |
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
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 |
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
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