S
santogold
Warning: Ruby newbie post
I am trying to create an array of a class to accomplish something like
the following:
Class Loadstocks
#load stock data into an array, crunch numbers and hash it, etc...
end
aapl = Loadstocks("aapl")
msft = Loadstocks("msft")
print aapl['2005-02-01].low
print aapl['2005-02-01].high
print msft['2005-02-01].high
print msft['2005-02-01].close
I generally "get" Ruby but my Pickaxe book, nutshell book and
hours of web searching have left me clueless. I do have a half baked
metaprogramming solution to this but I think there has to be an easier
way than that.
The part I am stuck on is making a hashed array of objects that I can
deal with easily. (loading the data , etc is almost intuitive)
Any code fragments or web links are greatly appreciated.
Thanks,
Tom
I am trying to create an array of a class to accomplish something like
the following:
Class Loadstocks
#load stock data into an array, crunch numbers and hash it, etc...
end
aapl = Loadstocks("aapl")
msft = Loadstocks("msft")
print aapl['2005-02-01].low
print aapl['2005-02-01].high
print msft['2005-02-01].high
print msft['2005-02-01].close
I generally "get" Ruby but my Pickaxe book, nutshell book and
hours of web searching have left me clueless. I do have a half baked
metaprogramming solution to this but I think there has to be an easier
way than that.
The part I am stuck on is making a hashed array of objects that I can
deal with easily. (loading the data , etc is almost intuitive)
Any code fragments or web links are greatly appreciated.
Thanks,
Tom