lib/code/object/decimal.rb in code-ruby-0.12.0 vs lib/code/object/decimal.rb in code-ruby-0.13.0

- old
+ new

@@ -7,19 +7,14 @@ decimal = args.first || "0" exponent = args.second || "0" decimal = decimal.raw if decimal.is_an?(Object) exponent = exponent.raw if exponent.is_an?(Object) @raw = decimal.to_d * 10**exponent.to_d - super rescue FloatDomainError => e raise Error, "#{decimal.inspect} * 10**#{exponent.inspect} is invalid" end - def self.name - "Decimal" - end - def call(**args) operator = args.fetch(:operator, nil) arguments = args.fetch(:arguments, []) value = arguments.first&.value @@ -298,27 +293,19 @@ def code_zero? Boolean.new(raw.zero?) end - def inspect - to_s - end - def whole? whole == raw end def whole raw.round end - def to_s - whole? ? raw.to_i.to_s : raw.to_s("F") - end - def as_json(...) - whole? ? whole.as_json(...) : raw.as_json(...) + whole? ? whole.as_json(...) : super end end end end