A função to_int em Ruby converte o valor do número em int. Se o próprio número for um int, ele retorna apenas self. É um alias da função to_i. 

Sintaxe : number.to_int

Parâmetro : a função pega o número que deve ser convertido em int.

Valor de retorno : a função retorna o valor int.

Exemplo 1:  

# Ruby program for to_int function
  
# Initializing the number
num1 = 51
num2 = 10.78
num3 = 1690.89
num4 = 183
  
# Prints the number as int
puts num1.to_int
puts num2.to_int
puts num3.to_int
puts num4.to_int

Produto

51
10
1690
183

Exemplo # 2: 

# Ruby program for to_int function
  
# Initializing the number
num1 = 312
num2 = 98.09
num3 = 190.23
num4 = 1312
   
# Prints the number as int
puts num1.to_int
puts num2.to_int
puts num3.to_int
puts num4.to_int

Produto

312
98
190
1312