# File lib/eymiha/units/units.rb, line 218 def Units.rank(unit_choices = {},samples = [],&numeric_ranker) # :yields: n if block_given? scores = {} samples.each {|s| unit_choices.each {|uc,w| scores[uc] = (scores[uc] || 0) + w*(yield s.convert(uc).numeric) } } scores.sort {|e1,e2| -(e1[1] <=> e2[1])}.collect {|s| s[0]} else rank(unit_choices,samples) { |n| e = ((((n.abs)-5.5).abs-4.5).at_least(0)) (e == 0) ? 0 : (e == 1)? 0 : -(e + 1/(1-e)) } end end