From: Joel Pearson Date: 2013-03-10T00:31:00+09:00 Subject: Re: RubyExcel class. Useful? Thanks for your input, Robert. I did wonder whether I should convert the underlying dataset into an Array rather than using a Hash, since spreadsheets are "structured" and I find the easiest way to manipulate the structure is with Array methods. Enumerable seems to be Array-based as well, and I'm still rather hazy on when to override methods like "map", or when to rely on the methods already available through "each". Still, I've learned a lot about Hashes while writing this code, so even if I do abandon their use for the main data storage I'll still find good use for them elsewhere. My reasoning behind the prevalence of headers is simply that if you wanted data without headers you'd just use arrays rather than this class. One of the big things I find helpful with this is that code is much more readable if I can reference a header rather than an index. I'm not sure what a test class or wrapper class is. I'll look them up. I see your point about to_s. I suppose I should differentiate between using interpolation for multiple variables and to_s for single cases. The +, -, and << methods are recent additions; mostly because I only just learned that you can define these. I'm sure there are multiple ways to write these; my first attempt was very poor in performance... and my thinking was to avoid re-inventing the wheel by using the Array methods written by someone much smarter than me :) I hadn't realised that I was evaluating "empty?" twice in "[]=". That was a performance-increasing experiment I'd tried to avoid recalculating the dimensions after every write operation. It made quite a difference at the time and I hadn't looked into simplifying it yet. All in all, this still needs a lot of work to make it useful; but now that I have a better feel of what the weaknesses and strengths are, I hope to improve on this starting point and eventually build something genuinely useful to others as well as myself. I'd be particularly interested on the question of Array vs Hash for the internals. Hash is great because of the simplicity of addresses and its efficient way of coping with blank space, but Arrays can keep their "form" much more effectively and already support things like sorting, rows, and columns. -- Posted via http://www.ruby-forum.com/.