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

#cmLength

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

Examples:

cm = 10
inches = cm.cm

Returns:

  • (Length)

    a value in inches if successful

Version:

  • SketchUp 6.0

#degreesFloat

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:

  • (Float)

    a value in radians if successful

Version:

  • SketchUp 6.0

#feetLength

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

Examples:

feet = 1
inches = feet.feet

Returns:

  • (Length)

    a value in inches if successful

Version:

  • SketchUp 6.0

#inchLength

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

#kmLength

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

Examples:

value = 1
inches = value.km

Returns:

  • (Length)

    a value in inches if successful

Version:

  • SketchUp 6.0

#mLength

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

Examples:

meters = 1
inches = meters.m

Returns:

  • (Length)

    a value in inches if successful

Version:

  • SketchUp 6.0

#mileLength

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

Examples:

miles = 1
inches = miles.mile

Returns:

  • (Length)

    a value in inches if successful

Version:

  • SketchUp 6.0

#mmLength

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

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:

  • (Length)

    a value in millimeters if successful

Version:

  • SketchUp 6.0

#radiansFloat

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:

  • (Float)

    a value in degrees if successful

Version:

  • SketchUp 6.0

#to_cmFloat

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

Examples:

inches = 1
cm = inches.to_cm

Returns:

  • (Float)

    a value in centimeters if successful

Version:

  • SketchUp 6.0

#to_feetFloat

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

Examples:

inches = 12
feet = inches.to_feet

Returns:

  • (Float)

    a value in feet if successful

Version:

  • SketchUp 6.0

#to_inchFloat

The to_inch method converts from inches to inches.

This does not change the value.

Examples:

inches = 12
inches = inches.to_inch

Returns:

  • (Float)

    a value in inches if successful

Version:

  • SketchUp 6.0

#to_kmFloat

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

Examples:

inches = 1
km = inches.to_km

Returns:

  • (Float)

    a value in kilometers if successful

Version:

  • SketchUp 6.0

#to_lLength

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_mFloat

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

Examples:

inches = 12
meters = inches.to_m

Returns:

  • (Float)

    a value in meters if successful

Version:

  • SketchUp 6.0

#to_mileFloat

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

Examples:

inches = 10000
miles = inches.to_mile

Returns:

  • (Float)

    a value in miles if successful

Version:

  • SketchUp 6.0

#to_mmFloat

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

Examples:

inches = 1
mm = inches.to_mm

Returns:

  • (Float)

    a value in millimeters if successful

Version:

  • SketchUp 6.0

#to_yardFloat

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

Examples:

inches = 10000
yards = inches.to_yard

Returns:

  • (Float)

    a value in yards if successful

Version:

  • SketchUp 6.0

#yardLength

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

Examples:

yards = 1.to_l
inches = yards.yard

Returns:

  • (Length)

    a value in inches if successful

Version:

  • SketchUp 6.0