Skip to content

Instantly share code, notes, and snippets.

@berkes
Created May 3, 2022 15:49
Show Gist options
  • Save berkes/86637d49fec6e3173b0d31f5558bd21b to your computer and use it in GitHub Desktop.
Save berkes/86637d49fec6e3173b0d31f5558bd21b to your computer and use it in GitHub Desktop.
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