Simon Kitching
11/5/2003 4:27:00 AM
On Wed, 2003-11-05 at 17:09, Austin Ziegler wrote:
>
> class StockItem
> attr_accessor :name # Defaults to String
> attr_reader :cost # Returns cost
> def cost=(x)
> @cost = x.to_f
> end
Hi Austin,
Thanks for your reply.
One of the goals of xmldigester is to be able to instantiate and
initialise objects from some input xml without making any changes to the
classes themselves.
Thus if you already have a library of warehouse management classes, I
can write some rules that can take an xml description of the contents of
that warehouse and build appropriately configured objects without
changing that library. And once the parsing is complete, the resulting
tree of objects should look no different than one created using normal
calls to the library API.
In addition, the approach you suggest is quite labour-intensive;
for every attribute, a "wrapper" method needs to be written.
I feel Ryan's MetaTags approach is easier to use; a simple string format
can be used to document the types to which strings from the xml input
should be converted before assignment to various attributes.
Regards,
Simon