Class: Electric::Ohm

Inherits:
Object
  • Object
show all
Defined in:
lib/electric/ohm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Ohm

Returns a new instance of Ohm.



6
7
8
9
10
11
# File 'lib/electric/ohm.rb', line 6

def initialize(options={})
  @ohms = options[:ohms].to_f if options[:ohms]
  @volts = options[:volts].to_f if options[:volts]
  @amps = options[:amps].to_f if options[:amps]
  @watts = options[:watts].to_f if options[:watts]
end

Instance Attribute Details

#ampsObject

Returns the value of attribute amps.



4
5
6
# File 'lib/electric/ohm.rb', line 4

def amps
  @amps
end

#ohmsObject

Returns the value of attribute ohms.



4
5
6
# File 'lib/electric/ohm.rb', line 4

def ohms
  @ohms
end

#voltsObject

Returns the value of attribute volts.



4
5
6
# File 'lib/electric/ohm.rb', line 4

def volts
  @volts
end

#wattsObject

Returns the value of attribute watts.



4
5
6
# File 'lib/electric/ohm.rb', line 4

def watts
  @watts
end

Instance Method Details

#currentObject



21
22
23
# File 'lib/electric/ohm.rb', line 21

def current
  amps ? amps : get_current
end

#powerObject



25
26
27
# File 'lib/electric/ohm.rb', line 25

def power
  watts ? watts : get_power
end

#resistanceObject



13
14
15
# File 'lib/electric/ohm.rb', line 13

def resistance
  ohms ? ohms : get_resistance
end

#voltageObject



17
18
19
# File 'lib/electric/ohm.rb', line 17

def voltage
  volts ? volts : get_voltage
end