Thanks for the feedback David.

def calculate_tsos(model, datavar)
  teamvar, valvar = [], []
  var = model.compiled_this_week.find(:all, :order => :team_id)
  var.each_with_index do |rows, i|
    teamvar[i] = rows.team.id
    valvar[i] = rows.__send__(datavar)
    puts "#{model} [ Row #{i} | Team ID = #{teamvar[i]} | Team = 
#{rows.team.name} | #{datavar} = #{valvar[i]}"
  end
  return teamvar, valvar
end

I used the same ordering process so my rows are uniform across the 14 
inner rake tasks..

I had to change a bit of your code for the rake task:

update_tsos_offense = TsosOffense.new
to_team_id, to_value = update_tsos_offense.calculate_tsos(TotalOffense, 
"ydspgm")
puts "From Rake to_team_id = #{to_team_id[0]} and to_value = 
#{to_value[0]}"

But it's actually shorter and in a lot of ways cleaner and easier to 
read.  Plus, it's two less variables I need to send with rake.

As to your other question,

I will be doing the following:

On each row within the each loop:

Finding the sum of all rows returned
Finding the mean of all rows returned
Finding the standard deviation between each value on the rows returned
Applying a ratings point modifier to the end value
.. then returning the arrays with the new modified values..

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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