radian_degree_converter 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/radian_degree_converter.rb +13 -0
- metadata +1 -1
@@ -1,5 +1,13 @@
|
|
1
|
+
# This class converts radians to decimal degrees and decimal degrees to radians.
|
2
|
+
# It will validate the method input to make sure it is float compatible and return
|
3
|
+
# an error message if the input cannot be converted to a float.
|
4
|
+
#
|
5
|
+
# Author :: Kevin LaFave
|
6
|
+
# License :: MIT
|
1
7
|
class RadianDegreeConverter
|
2
8
|
|
9
|
+
# This method validates the input to see if it is float compatible.
|
10
|
+
# * input : The value that needs to be validated.
|
3
11
|
def is_numeric? input
|
4
12
|
begin
|
5
13
|
Float(input)
|
@@ -10,10 +18,13 @@ class RadianDegreeConverter
|
|
10
18
|
end
|
11
19
|
end
|
12
20
|
|
21
|
+
# This method returns an error message when the convert method input was not float compatible.
|
13
22
|
def error_message
|
14
23
|
puts "Invalid input. Must enter an integer or decimal number"
|
15
24
|
end
|
16
25
|
|
26
|
+
# This method converts radians to its decimal degrees equivalent.
|
27
|
+
# * input : The radian value that needs to be converted to decimal degrees.
|
17
28
|
def convert_radians_to_degrees input
|
18
29
|
if is_numeric? input
|
19
30
|
@result = input.to_f * 57.2957795
|
@@ -23,6 +34,8 @@ class RadianDegreeConverter
|
|
23
34
|
end
|
24
35
|
end
|
25
36
|
|
37
|
+
# This method converts decimal degrees to its radians equivalent.
|
38
|
+
# * input : The decimal degree value that needs to be converted to radians.
|
26
39
|
def convert_degrees_to_radians input
|
27
40
|
if is_numeric? input
|
28
41
|
@result = input.to_f * 0.0174532925
|