to_i

rat.to_i â integer
Instance Public methods

Returns the truncated value as an integer.

Equivalent to

rat.truncate.

Rational(2, 3).to_i   #=> 0
Rational(3).to_i      #=> 3
Rational(300.6).to_i  #=> 300
Rational(98,71).to_i  #=> 1
Rational(-30,2).to_i  #=> -15
doc_ruby_on_rails
2015-05-01 04:31:48
Comments
Leave a Comment

Please login to continue.