Class: Roebe::Math::Sphere
Overview
Roebe::Math::Sphere
Instance Method Summary collapse
-
#calculate_the_surface_area(radius) ⇒ Object
(also: #oberfläche)
# === calculate_the_surface_area.
-
#calculate_the_volumen ⇒ Object
# === calculate_the_volumen.
-
#display_formulas_in_german ⇒ Object
# === display_formulas_in_german ========================================================================= #.
-
#initialize(i = ARGV, run_already = true) ⇒ Sphere
constructor
# === initialize ========================================================================= #.
-
#menu(i = @input) ⇒ Object
# === menu (menu tag) ========================================================================= #.
-
#process_the_user_input ⇒ Object
# === process_the_user_input ========================================================================= #.
-
#report_result_for_volumen ⇒ Object
# === report_result_for_volumen ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#set_input(i = nil) ⇒ Object
# === set_input ========================================================================= #.
Constructor Details
Instance Method Details
#calculate_the_surface_area(radius) ⇒ Object Also known as: oberfläche
46 47 48 49 |
# File 'lib/roebe/math/sphere.rb', line 46 def calculate_the_surface_area(radius) radius = radius.to_f return 4 * PI * (radius ** 2) end |
#calculate_the_volumen ⇒ Object
#
calculate_the_volumen
This method will calculate the “Kugelvolumen”.
#
107 108 109 110 111 |
# File 'lib/roebe/math/sphere.rb', line 107 def calculate_the_volumen r = @input.to_f # This we assume to be the Radius. @volumen = 4.0 / 3 * PI * (r ** 3) return @volumen end |
#display_formulas_in_german ⇒ Object
#
display_formulas_in_german
#
62 63 64 65 |
# File 'lib/roebe/math/sphere.rb', line 62 def display_formulas_in_german e ('Kugelvolumen V:').ljust(21)+' 4/3 * PI * (r ** 3)' e 'Oberfläche der Kugel: 4 * PI * (r ** 2)' end |
#menu(i = @input) ⇒ Object
#
menu (menu tag)
#
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/roebe/math/sphere.rb', line 70 def (i = @input) if i.is_a? Array i.each {|entry| (entry) } else case i # case tag # ===================================================================== # # === --german # ===================================================================== # when /^-?-?german/ display_formulas_in_german end end end |
#process_the_user_input ⇒ Object
#
process_the_user_input
#
95 96 97 98 99 100 |
# File 'lib/roebe/math/sphere.rb', line 95 def process_the_user_input unless @input.nil? calculate_the_volumen report_result_for_volumen end end |
#report_result_for_volumen ⇒ Object
#
report_result_for_volumen
#
87 88 89 90 |
# File 'lib/roebe/math/sphere.rb', line 87 def report_result_for_volumen opn; e 'A radius of '+simp(@input)+' equals to a Volumen of '+ sfancy(@volumen.to_f.round(4).to_s)+'.' end |
#reset ⇒ Object
#
reset (reset tag)
#
35 36 |
# File 'lib/roebe/math/sphere.rb', line 35 def reset end |