Created
August 21, 2015 02:24
-
-
Save eternal44/f267d1c3d197768a0fc5 to your computer and use it in GitHub Desktop.
Design pattern example for temperature conversions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def kelvin_to_rankine(value) | |
value * 1.8 | |
end | |
def rankine_to_kelvin(value) | |
value / 1.8 | |
end | |
def rankine_to_celcius(value) | |
value_holder = rankine_to_kelvin(value) | |
kelvin_to_celcius(value_holder) | |
end | |
def rankine_to_fahrenheit(value) | |
value_holder = rankine_to_kelvin(value) | |
kelvin_to_fahrenheit(value_holder) | |
end | |
def celcius_to_rankine(value) | |
value_holder = celcius_to_kelvin(value) | |
kelvin_to_rankine(value_holder) | |
end | |
def fahrenheit_to_rankine(value) | |
value_holder = fahrenheit_to_kelvin(value) | |
kelvin_to_rankine(value_holder) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using kelvins as a medium for conversions instead of writing individual conversions.