Calculate the percentage of sum of hash values
Ruby Hash

Rather than using a verbose case statement:


 case index
      when 0
        0.2
      when 1
        0.25
      when 2
        0.3



You could use a Hash:

rates = {0 =&gt; 0.2, 1 =&gt; 0.25, 2 =&gt; 0.3}


And the case can be replaced with:

rates[index]




Rubocop Report

Use symbols as procs when possible.


covers = covers.map { |x| x.to_sym }



This is a compact alternative:

covers = covers.map(&amp;:to_sym)




Identify unused block arguments.


@quotes.select { |k,v| covers.include?(k) }



Use an underscore to identify unused block arguments:

@quotes.select { |k, _v| covers.include?(k) }




Numeric predicates should use predicate methods instead of comparison operators if possible


premium == 0 ? nil : premium



Use the predicate method zero instead:

premium.zero? ? nil : premium