Unit::Length
Inherits Comparable < Unit::Formatter < Unit::Comparison < Unit::Arithmetic < Unit::Conversion < Reference < Object
Length measurement class with comprehensive unit support
Supports both metric and imperial length units with precise conversions using BigDecimal for accuracy. Meter is used as the base unit for all conversions to maintain consistency and precision.
Examples: Length.new(10.5, Length::Unit::Meter) Length.new(2.5, Length::Unit::Foot) Length.new(500, Length::Unit::Millimeter)
Constants
CONVERSION_FACTORS = {Length::Unit::Meter => BigDecimal.new("1"), Length::Unit::Centimeter => BigDecimal.new("0.01"), Length::Unit::Millimeter => BigDecimal.new("0.001"), Length::Unit::Kilometer => BigDecimal.new("1000"), Length::Unit::Inch => BigDecimal.new("0.0254"), Length::Unit::Foot => BigDecimal.new("0.3048"), Length::Unit::Yard => BigDecimal.new("0.9144"), Length::Unit::Mile => BigDecimal.new("1609.344")}
Conversion factors to meters (base unit)
All values are stored as BigDecimal for maximum precision Values are based on internationally accepted conversion standards