Hi,
I have several models in my app which contain several numerical attribute.
Ex.:  stock model; attributes: bid, ask, value,..
todays_values_of_Google = [ [#Stock: id=1, bid = 1.5, ask = 1.5, value =
1.5, time=..., ...], [#Stock: id=2, bid = 1.45, ask = 1.5, value =
1.45,..],... ]

Now I would like to have some statistics. I saw the possibility of open the
array class and add some functions like:

Class Array
  def mean; blabla ; end;
  ...
end

But I would like to have the option of telling the *attribute* on which to
calculate the mean.

So what would be the best practice for this as I need this on several model?
1.) A module? How?
     Maybe this
     def mean(*array,attr*); #calculate over all items of *array*s attribute
*attr*.... ; end
2.) Modify Classes? Where to do it so all model can access the "new" methods
of Array (for example)
3.) Somethink else?


Thanks for any help

Chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to