Browse files

Adds Money#floor

  • Loading branch information...
1 parent 1085d35 commit bfcfd0710194402598154416c561c441689192df @jstorimer jstorimer committed Oct 14, 2011
Showing with 10 additions and 0 deletions.
  1. +4 −0 lib/money/money.rb
  2. +6 −0 spec/money_spec.rb
View
4 lib/money/money.rb
@@ -107,6 +107,10 @@ def abs
Money.new(value.abs)
end
+ def floor
+ Money.new(value.floor)
+ end
+
def fraction(rate)
raise ArgumentError, "rate should be positive" if rate < 0
View
6 spec/money_spec.rb
@@ -141,6 +141,12 @@
it "should be comparable with non-money objects" do
@money.should_not == nil
end
+
+ it "should support floor" do
+ Money.new(15.52).floor.should == Money.new(15.00)
+ Money.new(18.99).floor.should == Money.new(18.00)
+ Money.new(21).floor.should == Money.new(21)
+ end
describe "frozen with amount of $1" do
before(:each) do

0 comments on commit bfcfd07

Please sign in to comment.