Method: Joules.current_v1

Defined in:
lib/joules/electricity.rb

.current_v1(charge, time) ⇒ Float

Note:

There is one other method for calculating current.

Calculates the current given charge and time.

Examples:

Joules.current_v1(325, 5) #=> 65.0

Parameters:

  • charge (Int, Float)

    charge is in coulombs

  • time (Int, Float)

    time > 0; time is in seconds

Returns:

  • (Float)

    return value is in amperes

Raises:

  • (ZeroDivisionError)

    if time = 0



27
28
29
30
31
32
33
# File 'lib/joules/electricity.rb', line 27

def current_v1(charge, time)
  if time.zero?
    raise ZeroDivisionError.new('divided by 0')
  else
    return charge / time.to_f
  end
end