I like the idea of using inspect, will this also allow me to assign
money = Money.new
money = 5
Also do I need to add a method for + and -, is there not a module like
Comparable that I can mixin to get this functionality?
Are there any other typical methods I should be adding? Excluding the
money specific stuff I have to_s.
Many thanks for all the replies they have been really helpful.
Gordon T. wrote:
If I have a class how do I get it to return a value without specifying a
method or attribute:
You want to overload the inspect method:
@value = value
irb(main):001:0> require ‘money’
irb(main):002:0> money = Money.new(5)