Created
May 3, 2022 15:49
-
-
Save berkes/86637d49fec6e3173b0d31f5558bd21b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MoneyAmount | |
def initialize(amount_in_cents) | |
@fractional = fractional | |
end | |
def euro | |
fractional / 100 | |
end | |
def cents | |
fractional | |
end | |
def to_s | |
"€ #{fractional / 100.00}" | |
end | |
def /(other) | |
fractional / other.ceil | |
end | |
def zero? | |
fractional.zero? | |
end | |
private | |
attr_reader :factional | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment