class Numeric |
Parent: Object |
|
Methods:cm, degrees, feet, inch, km, m, mile, mm, radians, to_cm, to_feet, to_inch, to_km, to_l, to_m, to_mile, to_mm, to_yard, yard |
|
Sample Code:numerictests.rb |
|
Instance Methods |
cm |
The cm method is used to convert from centimeters to inches. |
Syntax: |
inches = value.cm |
Arguments: |
|
Return Value: |
inches - a value in inches if successful |
Comments: |
|
Example: |
cm = 10 inches = cm.cm |
degrees |
The degrees method is used to convert from degrees to radians. |
Syntax: |
radians = angle.degrees |
Arguments: |
|
Return Value: |
radians - a value in radians if successful |
Comments: |
For example 90.degrees would return 1.5707963267949 |
Example: |
degrees = 90 radians = degrees.degrees |
feet |
The feet method is used to convert from feet to inches. |
Syntax: |
inches = value.feet |
Arguments: |
|
Return Value: |
inches - a value in inches if successful |
Comments: |
|
Example: |
feet = 1 inches = feet.feet |
inch |
The inch method converts a number to a length. |
Syntax: |
length = value.inch |
Arguments: |
|
Return Value: |
length - a Length object if successful |
Comments: |
|
Example: |
number = 100 length = number.inch |
km |
The km method is used to convert from kilometers to inches. |
Syntax: |
inches = value.km |
Arguments: |
|
Return Value: |
inches - a value in inches if successful |
Comments: |
|
Example: |
km = 1 inches = km.km |
m |
The m method is used to convert meters to inches. |
Syntax: |
inches = value.m |
Arguments: |
|
Return Value: |
inches - a value in inches if successful |
Comments: |
|
Example: |
meters = 1 inches = meters.m |
mile |
The mile method is used to convert from miles to inches. |
Syntax: |
inches = value.mile |
Arguments: |
|
Return Value: |
inches - a value in inches if successful |
Comments: |
|
Example: |
miles = 1 inches = miles.mile |
mm |
The mm method is used to convert a number to millimeters. |
Syntax: |
mm = value.mm |
Arguments: |
|
Return Value: |
mm - a value in millimeters if successful |
Comments: |
It returns a Length value which is the same length as the given value. For example: len = 25.4.mm returns 1 inch. |
Example: |
mm = 10 length = mm.mm |
radians |
The radians method is used to convert from radians to degrees. |
Syntax: |
degrees = value.radians |
Arguments: |
|
Return Value: |
degrees - a value in degrees if successful |
Comments: |
For example, 1.5707963267949.radians would return 90.0 |
Example: |
radians = 1.5707963267949 degrees = radians.radians |
to_cm |
The to_cm method is used to convert from inches to centimeters. |
Syntax: |
cm = length.to_cm |
Arguments: |
|
Return Value: |
cm - a value in centimeters if successful |
Comments: |
|
Example: |
inches = 1 cm = inches.to_cm |
to_feet |
The to_feet method is used to convert from inches to feet. |
Syntax: |
feet = length.to_feet |
Arguments: |
|
Return Value: |
feet - a value in feet if successful |
Comments: |
|
Example: |
inches = 12 feet = inches.to_feet |
to_inch |
The to_inch method converts from inches to inches. |
Syntax: |
inches = length.to_inch |
Arguments: |
|
Return Value: |
inches - a value in inches if successful |
Comments: |
This does not change the value. |
Example: |
inches = 12 inches = inches.to_inch |
to_km |
The to_km method is used to convert from inches to kilometers. |
Syntax: |
kilometers = length.to_km |
Arguments: |
|
Return Value: |
kilometers - a value in kilometers if successful |
Comments: |
|
Example: |
inches = 1 km = inches.to_km |
to_l |
The to_l is used to convert from a number to a length. |
Syntax: |
length = value.to_l |
Arguments: |
|
Return Value: |
length - a Length object if successful |
Comments: |
|
Example: |
number = 12 length = number.to_l |
to_m |
The to_m method is used to convert from inches to meters. |
Syntax: |
meters = length.to_m |
Arguments: |
|
Return Value: |
meters - a value in meters if successful |
Comments: |
|
Example: |
inches = 12 meters = inches.to_m |
to_mile |
The to_mile method is used to convert from inches to miles. |
Syntax: |
miles = length.to_mile |
Arguments: |
|
Return Value: |
miles - a value in miles if successful |
Comments: |
|
Example: |
inches = 10000 miles = inches.to_mile |
to_mm |
The to_mm method is used to convert from inches to millimeters. |
Syntax: |
millimeters = length.to_mm |
Arguments: |
|
Return Value: |
millimeters - a value in millimeters if successful |
Comments: |
|
Example: |
inches = 1 mm = inches.to_mm |
to_yard |
The to_yard method is used to convert from inches to yards. |
Syntax: |
yards = length.to_yard |
Arguments: |
|
Return Value: |
yards - a value in yards if successful |
Comments: |
|
Example: |
inches = 10000 yards = inches.to_y |
yard |
The yard method is used to convert from yards to inches. |
Syntax: |
inches = value.yard |
Arguments: |
|
Return Value: |
inches - a value in inches if successful |
Comments: |
|
Example: |
yards = 1 inches = yards.yard |