Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds Money#floor

  • Loading branch information...
commit bfcfd0710194402598154416c561c441689192df 1 parent 1085d35
@jstorimer jstorimer authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.