Ejercicio 1:
Mandar un mensaje "Hola Mundo"
class HolaMundo
| def initialize()
| end
| def saluda()
| . puts "Hola Mundo" #imprimimos el mensaje
| end
end

Ejercicio 2:
Sentencia If : Realizar una aplicación que nos permita saludar dependiendo de la hora.
class Ejercicio
| def initialize()
| end
| def hora()
| . puts "¿Ingrese la hora?"
| . STDOUT.flush #toda entrada de números en Ruby es considerado texto
| . hora=gets.chomp #por lo que acá se realiza una conversión de texto a entero
| . hora=hora.to_i
| . if hora < 12
| . . puts "Buenos días"
| . . puts "Ten un excelente día"
| . else
| . . puts "Buenas tardes"
| . end
| end
end
CARRERA DE CABALLOS:
class Pro
def initialize()
end
def apuesta()
puts"Por cual caballo escogerias"
puts"1.Rocinante"
puts"2.trueno"
puts"3.comanche"
puts"4.gitana"
puts"5.sombra"
puts"6.salvaje"
print "===> "
a=gets.to_i
x=Random.new.rand(1..6)
print"El caballo ganador es:"
puts x
if(a==x) then
print "GANASTE !!"
else
print"PERDISTE :("
end
end
end
objeto=Pro.new
objeto.apuesta
gets()
end
end
objeto=H.new
objeto.operaciones
gets()
CONVERTIR A NÚMEROS ROMANOS:
class H
def initialize()
end
def numerosromanos()
print "Ingrese un numero (1 al 19) para convertir: "
numero=gets.to_i
unidades=numero%10
numero=numero/10
decenas=numero%10
numero=numero/10
puts "------------en romano------------"
case decenas
when 1 then print"X"
end
case unidades
when 1 then print"I"
when 2 then print"II"
when 3 then print"III"
when 4 then print"IV"
when 5 then print"V"
when 6 then print"VI"
when 7 then print"VII"
when 8 then print"VIII"
when 9 then print"IX"
end
end
end
objeto = H.new()
objeto.numerosromanos
gets()