mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-22 14:49:38 +02:00
* Update hard-coded currency UI with currency specific params * Rename extension methods to match currency option names; Move cents extension to numeric class extension * Use currency's precision to show the cents part in accounts show page --------- Co-authored-by: Sriram Krishnan <sriram@seafoodsouq.com>
11 lines
264 B
Ruby
11 lines
264 B
Ruby
class Numeric
|
|
def cents(precision: 2)
|
|
return "" unless precision.positive?
|
|
|
|
cents = self.to_s.split(".")[1]
|
|
cents = "" unless cents.to_i.positive?
|
|
|
|
zero_padded_cents = cents.ljust(precision, "0")
|
|
zero_padded_cents[0..precision - 1]
|
|
end
|
|
end
|