Class: Variable
- Inherits:
-
Struct
- Object
- Struct
- Variable
- Defined in:
- lib/strom/variable.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value
1 2 3 |
# File 'lib/strom/variable.rb', line 1 def value @value end |
Instance Method Details
#and(other) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/strom/variable.rb', line 2 def and(other) current = resistance = voltage = nil [self, other].each do |element| case element when Ampere current = element.value when Ohm resistance = element.value when Volt voltage = element.value end end if current.nil? Ampere.new(voltage / resistance) elsif resistance.nil? Ohm.new(voltage / current) elsif voltage.nil? Volt.new(current * resistance) end end |