Class: Numeric

Inherits:
Object
  • Object
show all

Overview

A number of methods have been added to the Ruby Numeric class to do units conversions.

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Instance Method Details

#cmObject

The cm method is used to convert from centimeters to inches.

Examples:

cm = 10
inches = cm.cm

Returns:

  • inches - a value in inches if successful

Version:

  • SketchUp 6.0

#degreesObject

The degrees method is used to convert from degrees to radians.

For example 90.degrees would return 1.5707963267949

Examples:

degrees = 90
radians = degrees.degrees

Returns:

  • radians - a value in radians if successful

Version:

  • SketchUp 6.0

#feetObject

The feet method is used to convert from feet to inches.

Examples:

feet = 1
inches = feet.feet

Returns:

  • inches - a value in inches if successful

Version:

  • SketchUp 6.0

#inchObject

The to_l is used to convert from a number to a length.

Examples:

number = 12
length = number.to_l

Returns:

  • length - a Length object if successful

Version:

  • SketchUp 6.0

#kmObject

The km method is used to convert from kilometers to inches.

Examples:

value = 1
inches = value.km

Returns:

  • inches - a value in inches if successful

Version:

  • SketchUp 6.0

#mObject

The m method is used to convert meters to inches.

Examples:

meters = 1
inches = meters.m

Returns:

  • inches - a value in inches if successful

Version:

  • SketchUp 6.0

#mileObject

The mile method is used to convert from miles to inches.

Examples:

miles = 1
inches = miles.mile

Returns:

  • inches - a value in inches if successful

Version:

  • SketchUp 6.0

#mmObject

The mm method is used to convert a number to millimeters.

It returns a Length value which is the same length as the given value. For example len = 25.4.mm returns 1 inch.

Examples:

value = 10
mm = value.mm

Returns:

  • mm - a value in millimeters if successful

Version:

  • SketchUp 6.0

#radiansObject

The radians method is used to convert from radians to degrees.

For example, 1.5707963267949.radians would return 90.0

Examples:

radians = 1.5707963267949
degrees = radians.radians

Returns:

  • degrees - a value in degrees if successful

Version:

  • SketchUp 6.0

#to_cmObject

The to_cm method is used to convert from inches to centimeters.

Examples:

inches = 1
cm = inches.to_cm

Returns:

  • cm - a value in centimeters if successful

Version:

  • SketchUp 6.0

#to_feetObject

The to_feet method is used to convert from inches to feet.

Examples:

inches = 12
feet = inches.to_feet

Returns:

  • feet - a value in feet if successful

Version:

  • SketchUp 6.0

#to_inchObject

The to_inch method converts from inches to inches.

This does not change the value.

Examples:

inches = 12
inches = inches.to_inch

Returns:

  • inches - a value in inches if successful

Version:

  • SketchUp 6.0

#to_kmObject

The to_km method is used to convert from inches to kilometers.

Examples:

inches = 1
km = inches.to_km

Returns:

  • kilometers - a value in kilometers if successful

Version:

  • SketchUp 6.0

#to_lObject

The to_l is used to convert from a number to a length.

Examples:

number = 12
length = number.to_l

Returns:

  • length - a Length object if successful

Version:

  • SketchUp 6.0

#to_mObject

The to_m method is used to convert from inches to meters.

Examples:

inches = 12
meters = inches.to_m

Returns:

  • meters - a value in meters if successful

Version:

  • SketchUp 6.0

#to_mileObject

The to_mile method is used to convert from inches to miles.

Examples:

inches = 10000
miles = inches.to_mile

Returns:

  • miles - a value in miles if successful

Version:

  • SketchUp 6.0

#to_mmObject

The to_mm method is used to convert from inches to millimeters.

Examples:

inches = 1
mm = inches.to_mm

Returns:

  • millimeters - a value in millimeters if successful

Version:

  • SketchUp 6.0

#to_yardObject

The to_yard method is used to convert from inches to yards.

Examples:

inches = 10000
yards = inches.to_yard

Returns:

  • yards - a value in yards if successful

Version:

  • SketchUp 6.0

#yardObject

The yard method is used to convert from yards to inches.

Examples:

yards = 1.to_l
inches = yards.yard

Returns:

  • inches - a value in inches if successful

Version:

  • SketchUp 6.0