Class: ChemistryParadise::CelsiusToFahrenheit
- Inherits:
-
Object
- Object
- ChemistryParadise::CelsiusToFahrenheit
show all
- Includes:
- Converters
- Defined in:
- lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb
Overview
ChemistryParadise::CelsiusToFahrenheit
Constant Summary
collapse
- NAMESPACE =
inspect
Constants included
from Converters
ChemistryParadise::Converters::CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR, ChemistryParadise::Converters::FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === CelsiusToFahrenheit[] ========================================================================= #.
Instance Method Summary
collapse
Constructor Details
#initialize(celsius = 0, run_already = true) ⇒ CelsiusToFahrenheit
50
51
52
53
54
55
56
57
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 50
def initialize(
celsius = 0,
run_already = true
)
reset
set_celsius(celsius)
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
CelsiusToFahrenheit[]
#
133
134
135
136
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 133
def self.[](i = ARGV)
_ = new(i)
_.report
end
|
Instance Method Details
#celsius? ⇒ Boolean
Also known as:
n_celsius
89
90
91
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 89
def celsius?
@celsius
end
|
#do_the_calculation ⇒ Object
#
do_the_calculation
We determine how many Fahrenheit we have here, by using the specific formula.
#
#fahrenheit? ⇒ Boolean
Also known as:
n_fahrenheit
96
97
98
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 96
def fahrenheit?
@fahrenheit
end
|
#opnn ⇒ Object
119
120
121
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 119
def opnn
Opn.opn(use_this_as_namespace: NAMESPACE)
end
|
#report_result ⇒ Object
Also known as:
report
103
104
105
106
107
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 103
def report_result
opnn if use_opn?
e n_celsius.to_s+'° '+simp('Celsius')+' are '+n_fahrenheit.to_s+
'° '+simp('Fahrenheit')+'.'
end
|
#reset ⇒ Object
62
63
64
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 62
def reset
set_celsius
end
|
#run ⇒ Object
126
127
128
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 126
def run
do_the_calculation
end
|
#set_celsius(i = 0) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 69
def set_celsius(i = 0)
i = i.first if i.is_a? Array
i = i.to_s.dup
i = i.to_f
@celsius = i
end
|
#use_opn? ⇒ Boolean
112
113
114
|
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 112
def use_opn?
false
end
|