Class: Length
- Inherits:
- 
      Float
      
        - Object
- Float
- Length
 
- Defined in:
- lib/sketchup-api-stubs/stubs/length.rb
Overview
Prior to SketchUp 2015, Length used to be derived from Float. This is no longer the case.
Because length units are used so often in SketchUp, a special class has been added to make it easier to work with length values. You can use a Length object any place that you would use a Float.
Internally, all lengths in SketchUp are stored in inches. The Length class stores values in inches as well. A number of methods have been added to the Ruby Numeric class to do units conversions.
The setting for the Length Format and Length Unit can be retrieved from the Sketchup::Model#options by querying the “UnitsOptions” Sketchup::OptionsProvider for “LengthFormat” and “LengthUnit” respectively.
Constants:
- Length Format
- 
Length::Decimal
- 
Length::Architectural
- 
Length::Engineering
- 
Length::Fractional
 
- 
- Length Unit
- 
Length::Inches
- 
Length::Feet
- 
Length::Millimeter
- 
Length::Centimeter
- 
Length::Meter
 
- 
- Area Unit
- 
(Added in SketchUp 2019.1) - 
Length::SquareInches
- 
Length::SquareFeet
- 
Length::SquareMillimeter
- 
Length::SquareCentimeter
- 
Length::SquareMeter
 
- 
- Volume Unit
- 
(Added in SketchUp 2019.1) - 
Length::CubicInches
- 
Length::CubicFeet
- 
Length::CubicMillimeter
- 
Length::CubicCentimeter
- 
Length::CubicMeter
 
- 
Constant Summary collapse
- Architectural =
          Constants 
- nil
- Centimeter =
          Stub value. 
- nil
- CubicCentimeter =
          Stub value. 
- nil
- CubicFeet =
          Stub value. 
- nil
- CubicInches =
          Stub value. 
- nil
- CubicMeter =
          Stub value. 
- nil
- CubicMillimeter =
          Stub value. 
- nil
- Decimal =
          Stub value. 
- nil
- Engineering =
          Stub value. 
- nil
- Fractional =
          Stub value. 
- nil
- Feet =
          Stub value. 
- nil
- Inches =
          Stub value. 
- nil
- Millimeter =
          Stub value. 
- nil
- Meter =
          Stub value. 
- nil
- SquareCentimeter =
          Stub value. 
- nil
- SquareFeet =
          Stub value. 
- nil
- SquareInches =
          Stub value. 
- nil
- SquareMeter =
          Stub value. 
- nil
- SquareMillimeter =
          Stub value. 
- nil
Instance Method Summary collapse
- 
  
    
      #<(length2)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    The < method is used to see if one length is less than another length. 
- 
  
    
      #<=(length2)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    The <= method is used to see if one length is less than or equal to another length. 
- 
  
    
      #<=>(length2)  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    The <=> method is used to see if one length is less than equal or greater than another length. 
- 
  
    
      #==(length2)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    The == method is used to see if one length is equal to another length. 
- 
  
    
      #>(length2)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    The > method is used to see if one length is greater than another length. 
- 
  
    
      #>=(length2)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    The >= method is used to see if one length is greater than or equal to another length. 
- 
  
    
      #inspect  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    The inspect method is used to retrieve an unformatted string for the length, which is the length in inches, regardless of the user’s model unit settings. 
- 
  
    
      #to_f  ⇒ Float 
    
    
  
  
  
  
  
  
  
  
  
    The to_f method is used to convert a length to a normal float. 
- 
  
    
      #to_s  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Format a length as a String using the current units formatting settings for the model. 
Instance Method Details
#<(length2) ⇒ Boolean
The < method is used to see if one length is less than another length.
For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 < l2 should return false.
| 109 110 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 109 def <(length2) end | 
#<=(length2) ⇒ Boolean
The <= method is used to see if one length is less than or equal to another length.
| 131 132 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 131 def <=(length2) end | 
#<=>(length2) ⇒ Integer
The <=> method is used to see if one length is less than equal or greater than another length. Because we change == for Length to do a test based on a tolerance, we also need to change <=> to also take tolerance into account.
| 149 150 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 149 def <=>(length2) end | 
#==(length2) ⇒ Boolean
The == method is used to see if one length is equal to another length.
The equality comparison on Length values uses the default tolerance that SketchUp uses for comparing lengths.
| 169 170 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 169 def ==(length2) end | 
#>(length2) ⇒ Boolean
The > method is used to see if one length is greater than another length.
For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 > l2 should return false.
| 193 194 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 193 def >(length2) end | 
#>=(length2) ⇒ Boolean
The >= method is used to see if one length is greater than or equal to another length.
For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 >= l2 should return true. Also L1 <= l2 would return true.
| 218 219 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 218 def >=(length2) end | 
#inspect ⇒ String
The inspect method is used to retrieve an unformatted string for the length, which is the length in inches, regardless of the user’s model unit settings. See Length.to_s for a way automatically format your Length to the user’s model units.
| 233 234 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 233 def inspect end | 
#to_f ⇒ Float
The to_f method is used to convert a length to a normal float.
| 245 246 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 245 def to_f end | 
#to_s ⇒ String
Format a length as a String using the current units formatting settings for the model. (So if the user’s model is set to feet, this method will return a nicely formatted length in feet.)
| 259 260 | # File 'lib/sketchup-api-stubs/stubs/length.rb', line 259 def to_s end |