Permalink
Browse files

patch for Rational#div for 1.9

  • Loading branch information...
1 parent 2158520 commit 64dad7ebd6c43fc1024c039741dce1f7c2117901 @semmons99 semmons99 committed Oct 17, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/19/rational.rb
View
@@ -1,5 +1,15 @@
# :enddoc:
+class Rational < Numeric
+ def div(other)
+ if other.is_a?(Float) && other == 0.0
+ raise ZeroDivisionError, "division by zero"
+ end
+
+ (self / other).floor
+ end
+end
+
class Fixnum
alias quof fdiv

0 comments on commit 64dad7e

Please sign in to comment.