spook_and_puff_money 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/spook_and_puff/money.rb +3 -4
- metadata +1 -1
data/lib/spook_and_puff/money.rb
CHANGED
@@ -14,17 +14,16 @@ module SpookAndPuff
|
|
14
14
|
|
15
15
|
# Initializes the money class from a BigDecimal instance.
|
16
16
|
#
|
17
|
-
# @param [BigDecimal, String] value
|
17
|
+
# @param [BigDecimal, String, SpookAndPuff::Money] value
|
18
18
|
#
|
19
19
|
# @return self
|
20
20
|
#
|
21
21
|
# @raise TypeError
|
22
|
-
#
|
23
|
-
# @todo This potentially should only handle BigDecimal, Money and String
|
24
22
|
def initialize(value)
|
25
23
|
@raw = case value
|
24
|
+
when SpookAndPuff::Money then value.raw
|
26
25
|
when BigDecimal then value.round(7)
|
27
|
-
when String then BigDecimal.new(value).round(7)
|
26
|
+
when String then BigDecimal.new(value.gsub(/\$/, '')).round(7)
|
28
27
|
else raise TypeError.new("Money can only be initalized with a BigDecimal or String not #{value.class}.")
|
29
28
|
end
|
30
29
|
end
|