Method: Joules.resistance_in_parallel
- Defined in:
- lib/joules/electricity.rb
.resistance_in_parallel(resistances) ⇒ Float
Calculates the total resistance of resistors in parallel.
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/joules/electricity.rb', line 115 def resistance_in_parallel(resistances) total_resistance = 0 if resistances.empty? return total_resistance.to_f else resistances.each do |resistance| total_resistance += (1.0 / resistance) end return 1 / total_resistance end end |