Skip to content

Instantly share code, notes, and snippets.

View toreriklinnerud's full-sized avatar

Tor Erik Linnerud toreriklinnerud

  • Decibel
  • New York
View GitHub Profile
@toreriklinnerud
toreriklinnerud / ZippyHash.rb
Created October 21, 2009 19:53 — forked from jcf/ZippyHash.rb
using graph, common method and present in our app, but not standard in ruby/rails
def build_message
message = PORTFOLIO_FIELDS.graph{|field, _| [field, send(field)] }
self.message = message.delete_if { |_, value| value.nil? }
end
count = 90
total = 100
%w(red amber green).map.with_index do |color, index|
color if ((index + 1)/ 3.0) > (count.to_f / total.to_f)
end.compact.first