Wes Oldenbeuving
7/19/2006 6:50:00 AM
On Wed, 19 Jul 2006 07:26:36 +0200, Brandon Coleman <metrix1978@gmail.com>
wrote:
> I have a thought in my head, but I don't know how to implement it, or
> even if I am thinking about it in the right way.. what I want to do is
> store information in a header detail type way, but I would like to be
> able to use methods directly on my data. I guess the example I have
> pictured in my head is:
> dealership_obj = dealership.new
> and within that If I had data on vehicles it would be:
> dealership.honda.new(data)
> dealership.ford.new(data)
> etc.
>
> Am I thinking about this right? is there a better way but I just don't
> see it?
>
> any ideas or links to web pages would be greatly appreciated!
>
> Brandon
>
For your example, is the following what you were thinking about?
------- Code --------
class Dealership
attr_accessor :honda, :ford
def initialize
@honda=Honda.new
@ford=Ford.new
end
end
class Honda
def to_s
return "Honda"
end
end
class Ford
def to_s
return "Ford's to-string"
end
end
dealership_obj = Dealership.new
puts dealership_obj.honda
puts dealership_obj.ford
------- End Code --------
Wes Oldenbeuving