Skip to content

Commit

Permalink
round method takes an argument in ruby 1.9 but not in 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Olbrich committed Sep 26, 2012
1 parent 9bc0638 commit 0beab2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
16 changes: 12 additions & 4 deletions lib/ruby_units/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 0beab2a

Please sign in to comment.