Class: ChemistryParadise::CelsiusToFahrenheit

Inherits:
Object
  • Object
show all
Includes:
Converters
Defined in:
lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb

Overview

ChemistryParadise::CelsiusToFahrenheit

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect

Constants included from Converters

ChemistryParadise::Converters::CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR, ChemistryParadise::Converters::FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(celsius = 0, run_already = true) ⇒ CelsiusToFahrenheit

#

initialize

#


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

#

input?

#

Returns:

  • (Boolean)


89
90
91
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 89

def celsius?
  @celsius
end

#do_the_calculationObject

#

do_the_calculation

We determine how many Fahrenheit we have here, by using the specific formula.

#


82
83
84
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 82

def do_the_calculation
  @fahrenheit = (@celsius * CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR)+32.00
end

#fahrenheit?Boolean Also known as: n_fahrenheit

#

fahrenheit?

#

Returns:

  • (Boolean)


96
97
98
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 96

def fahrenheit?
  @fahrenheit
end

#opnnObject

#

opnn

#


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_resultObject Also known as: report

#

report_result

#


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

#resetObject

#

reset (reset tag)

#


62
63
64
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 62

def reset
  set_celsius
end

#runObject

#

run (run tag)

#


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

#

set_celsius

#


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

#

use_opn?

#

Returns:

  • (Boolean)


112
113
114
# File 'lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb', line 112

def use_opn?
  false
end