A Ruby library for handling unit conversions, mathematical operations, and dimensional analysis with scientific accuracy.
Ruby Units is a Ruby library designed to handle unit conversions and dimensional analysis for scientific and technical calculations. It creates Unit objects that manage conversions and manipulations automatically, ensuring accurate results when working with measurements like length, mass, time, and temperature. The library integrates with Ruby's core classes and Math module to provide seamless unit-aware operations.
Ruby developers working on scientific, engineering, or technical applications that require precise unit handling, such as physics simulations, engineering calculations, or data analysis involving measurements.
Developers choose Ruby Units for its comprehensive unit support, accuracy in conversions, and deep integration with Ruby's ecosystem, including Time, Date, and Math operations. It eliminates manual conversion errors and provides a clean, object-oriented API for complex dimensional analysis.
A unit handling library for ruby
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Handles simple units, compound units like 'kg*m^2/s^2', exponent notation, and conversions from strings or objects, as shown in the extensive Usage examples.
Extends Time, Date, and DateTime classes for natural duration arithmetic and enhances the Math module for unit-aware trigonometric and root functions, simplifying scientific workflows.
Differentiates between absolute temperatures (e.g., 'tempC') and temperature differences (e.g., 'degC') with proper scale conversions, preventing common errors in thermal calculations.
Allows customization of output formatting, separators, and precision via a configuration API, and supports defining new units or redefining existing ones through a dedicated block syntax.
The library explicitly prioritizes accuracy over speed, leading to potential slowdowns and increased object allocation in performance-critical applications, as noted in the 'Performance vs. Accuracy' section.
Requires Ruby 3.2 or later, which excludes use in older projects and adds migration overhead for teams on legacy systems.
Defining new units involves managing multiple attributes like scalar, kind, numerator, and denominator through a verbose API, which can be intimidating for casual users or quick prototyping.