class Object
Public Instance Methods
average(numbers, si)
click to toggle source
# File lib/nominate/dw_nominate.rb, line 371 def average(numbers, si) if numbers.length == 0 puts 'No legislator names matched those of the previous session.' puts 'You will not be able to run DW-NOMINATE on these two sessions.' puts 'Put names from both sessions in the same format to correct the issue.' puts "Sessions #{si.to_s} and #{(si+1).to_s}." exit end sum = 0 numbers.each { |n| sum = sum + n.to_f } sum / numbers.length end
dw_format(num)
click to toggle source
# File lib/nominate/dw_nominate.rb, line 361 def dw_format(num) if num[0] == '-' return " " + num.to_f.round(3).to_s + "0"*(6-num.to_f.round(3).to_s.length) elsif num == 'NA' return dw_format('0') else return " " + num.to_f.round(3).to_s + "0"*(5-num.to_f.round(3).to_s.length) end end