Permalink
Browse files

round method takes an argument in ruby 1.9 but not in 1.8

  • Loading branch information...
Kevin Olbrich
Kevin Olbrich committed Sep 26, 2012
1 parent 9bc0638 commit 0beab2a3af1a9076df7f4b4ba5a694f93ccf4cdf
Showing with 13 additions and 4 deletions.
  1. +1 −0 README.md
  2. +12 −4 lib/ruby_units/unit.rb
View
@@ -1,6 +1,7 @@
# Ruby Units
[![Dependency Status](https://gemnasium.com/olbrich/ruby-units.png)](https://gemnasium.com/olbrich/ruby-units)
+[![Build Status](https://secure.travis-ci.org/olbrich/ruby-units.png)](http://travis-ci.org/olbrich/ruby-units)
Kevin C. Olbrich, Ph.D.
View
@@ -1102,10 +1102,18 @@ def floor
return Unit.new(@scalar.floor, @numerator, @denominator)
end
- # @return [Numeric,Unit]
- def round(ndigits = 0)
- return @scalar.round(ndigits) if self.unitless?
- return Unit.new(@scalar.round(ndigits), @numerator, @denominator)
+ if RUBY_VERSION < '1.9'
+ # @return [Numeric,Unit]
+ def round
+ return @scalar.round if self.unitless?
+ return Unit.new(@scalar.round, @numerator, @denominator)
+ end
+ else
+ # @return [Numeric,Unit]
+ def round(ndigits = 0)
+ return @scalar.round(ndigits) if self.unitless?
+ return Unit.new(@scalar.round(ndigits), @numerator, @denominator)
+ end
end
# @return [Numeric, Unit]

0 comments on commit 0beab2a

Please sign in to comment.