Skip to content

Instantly share code, notes, and snippets.

@noam87
Created June 8, 2015 18:16
Show Gist options
  • Select an option

  • Save noam87/6b1103bbda9edce07641 to your computer and use it in GitHub Desktop.

Select an option

Save noam87/6b1103bbda9edce07641 to your computer and use it in GitHub Desktop.
obj = {}
Football::Event.all.each { |e|
obj[e.id] = { summaries: e.box_score.score_summaries.map { |s|
{ home: s.home_score, away: s.away_score } unless s.home_score == 0 and s.away_score == 0 }
} if e.box_score
}
obj.delete_if { |k,v| v[:summaries].compact.empty? == true }
obj.delete_if { |k,v|
val = true
v[:summaries].each_with_index { |s, i|
[:home, :away].each { |k2|
if i != 0
val = false if s[k2] < v[:summaries][i - 1][k2]
end
}
}
val
}
obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment