allow negating Value objects
This commit is contained in:
parent
6ff11c012f
commit
d72de51977
@ -59,6 +59,11 @@ module Gnucash
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Negate a Value
|
||||||
|
def -@
|
||||||
|
Value.new(-@val, @div)
|
||||||
|
end
|
||||||
|
|
||||||
# Multiply a Value object
|
# Multiply a Value object
|
||||||
# +other+ should be a Numeric
|
# +other+ should be a Numeric
|
||||||
def *(other)
|
def *(other)
|
||||||
|
@ -51,6 +51,12 @@ module Gnucash
|
|||||||
c.should == 1.1
|
c.should == 1.1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows negating a Value object" do
|
||||||
|
a = Value.new("123/100")
|
||||||
|
b = -a
|
||||||
|
b.to_s.should == "-1.23"
|
||||||
|
end
|
||||||
|
|
||||||
it "allows multiplying a Value by a Numeric" do
|
it "allows multiplying a Value by a Numeric" do
|
||||||
a = Value.new("100/100")
|
a = Value.new("100/100")
|
||||||
b = 12
|
b = 12
|
||||||
|
Loading…
x
Reference in New Issue
Block a user