lib/zold/amount.rb in zold-0.20.1 vs lib/zold/amount.rb in zold-0.20.2
- old
+ new
@@ -48,15 +48,18 @@
end
raise "The amount is too big: #{@zents}" if @zents > MAX
raise "The amount is too small: #{@zents}" if @zents < -MAX
end
+ # Just zero, for convenience.
ZERO = Amount.new(zents: 0)
+ # Convert it to zents and return as an integer.
def to_i
@zents
end
+ # Convert to ZLD and return as a string. If you need float, you should use <tt>to_f()</tt> later.
def to_zld(digits = 2)
format("%0.#{digits}f", @zents.to_f / 2**FRACTION)
end
def to_s