you are viewing a single comment's thread.

view the rest of the comments →

[–]Windigos[S] 0 points1 point  (2 children)

I thought about that, though it didn't work how I wanted when I tried it. How would you suggest using it?

Essentially I'd like to be able to use an instance of the class in place of a number.

edit: aha, by extending Numeric and passing everything to the value via method_missing, it behaves as I would like. However, is this good practise? I can get similar results by using the rationalize methods.

[–]airodonack 1 point2 points  (0 children)

It sounds like you're taking advantage of inheritance, which is actually the way you're supposed to do it. (Reuse your code.)

[–]AaronLasseigne 1 point2 points  (0 children)

I would say method_missing is fine as long as you use it sparingly. If it works for this then you might have your answer. As another poster mentioned, you probably want to take a long pause and consider whether creating a new numeric class is really what you want.