Class: ChemistryParadise::CelsiusToKelvin

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

Overview

ChemistryParadise::CelsiusToKelvin

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) ⇒ CelsiusToKelvin

#

initialize

#


38
39
40
41
42
43
44
45
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 38

def initialize(
    celsius     = 0,
    run_already = true
  )
  reset
  set_celsius(celsius)
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

CelsiusToKelvin[]

#


115
116
117
118
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 115

def self.[](i = ARGV)
  _ = new(i)
  _.report
end

Instance Method Details

#celsius?Boolean Also known as: n_celsius

#

input?

#

Returns:

  • (Boolean)


77
78
79
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 77

def celsius?
  @celsius
end

#do_the_calculationObject

#

do_the_calculation

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

#


70
71
72
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 70

def do_the_calculation
  @kelvin = @celsius + 273.15
end

#opnnObject

#

opnn

#


101
102
103
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 101

def opnn
  Opn.opn(use_this_as_namespace: NAMESPACE)
end

#report_resultObject Also known as: report

#

report_result

#


84
85
86
87
88
89
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 84

def report_result
  opnn if use_opn?
  e rev+
    n_celsius.to_s+'° '+simp('Celsius')+' are '+@kelvin.to_s+
    ' '+simp('Kelvin')+'.'
end

#resetObject

#

reset (reset tag)

#


50
51
52
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 50

def reset
  set_celsius
end

#runObject

#

run (run tag)

#


108
109
110
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 108

def run
  do_the_calculation
end

#set_celsius(i = 0) ⇒ Object

#

set_celsius

#


57
58
59
60
61
62
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 57

def set_celsius(i = 0)
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  i = i.to_f # Store as a Float.
  @celsius = i
end

#use_opn?Boolean

#

use_opn?

#

Returns:

  • (Boolean)


94
95
96
# File 'lib/chemistry_paradise/converters/celsius_to_kelvin.rb', line 94

def use_opn?
  false
end