On Sat, May 25, 2013 at 11:21 PM, oliver bee <
li...@ruby-forum.com> wrote:
> Thanks for the Response Norm, That isn't necessary in this instance
> though (all trucks will have 4 wheels). Should I just keep with what I
> have?
I agree with Norm that this feels inauthentic - objects are typically
used to 'model' real world things and relationships, and I can see
lots of exceptions on your horizon :-)
In any case, I would probably do something like:
class Vehicle
attr_accessor :wheel_count
end
class Truck < Vehicle
def initialize(wheel_count = 4)
@wheel_count = wheel_count
end
end
... and so on.
I'd also recommend 'Practical Object-Oriented Design in Ruby'
(
http://www.poodr.info/ ) for some good thoughts on this.
FWIW,
--
Hassan Schroeder ------------------------
hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan