Class: Electric::Ohm
- Inherits:
-
Object
- Object
- Electric::Ohm
- Defined in:
- lib/electric/ohm.rb
Instance Attribute Summary collapse
-
#amps ⇒ Object
Returns the value of attribute amps.
-
#ohms ⇒ Object
Returns the value of attribute ohms.
-
#volts ⇒ Object
Returns the value of attribute volts.
-
#watts ⇒ Object
Returns the value of attribute watts.
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(options = {}) ⇒ Ohm
constructor
A new instance of Ohm.
- #power ⇒ Object
- #resistance ⇒ Object
- #voltage ⇒ Object
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(={}) @ohms = [:ohms].to_f if [:ohms] @volts = [:volts].to_f if [:volts] @amps = [:amps].to_f if [:amps] @watts = [:watts].to_f if [:watts] end |
Instance Attribute Details
#amps ⇒ Object
Returns the value of attribute amps.
4 5 6 |
# File 'lib/electric/ohm.rb', line 4 def amps @amps end |
#ohms ⇒ Object
Returns the value of attribute ohms.
4 5 6 |
# File 'lib/electric/ohm.rb', line 4 def ohms @ohms end |
#volts ⇒ Object
Returns the value of attribute volts.
4 5 6 |
# File 'lib/electric/ohm.rb', line 4 def volts @volts end |
#watts ⇒ Object
Returns the value of attribute watts.
4 5 6 |
# File 'lib/electric/ohm.rb', line 4 def watts @watts end |
Instance Method Details
#current ⇒ Object
21 22 23 |
# File 'lib/electric/ohm.rb', line 21 def current amps ? amps : get_current end |
#power ⇒ Object
25 26 27 |
# File 'lib/electric/ohm.rb', line 25 def power watts ? watts : get_power end |
#resistance ⇒ Object
13 14 15 |
# File 'lib/electric/ohm.rb', line 13 def resistance ohms ? ohms : get_resistance end |
#voltage ⇒ Object
17 18 19 |
# File 'lib/electric/ohm.rb', line 17 def voltage volts ? volts : get_voltage end |