A Ruby library for encapsulating measurements with their units, providing precise conversion and Rails integration.
Measured is a Ruby library that encapsulates measurements with their units, allowing developers to work with quantities like weight, length, and volume in a type-safe and precise manner. It solves the problem of handling unit conversions accurately by using Rational numbers to avoid floating-point errors and provides seamless integration with Ruby on Rails for database persistence.
Ruby and Ruby on Rails developers who need to handle measurements and unit conversions in their applications, such as e-commerce platforms, scientific tools, or inventory management systems.
Developers choose Measured for its precision, lightweight design, and native Rails integration without monkey-patching core Ruby classes. It offers a clean, extensible API and avoids the complexity and maintenance issues found in alternative gems.
Encapsulate measurements and their units in Ruby and Ruby on Rails.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses Rational and BigDecimal for all calculations to avoid floating-point errors, as emphasized in the README for accurate unit conversions.
Includes an Active Record adapter for database persistence and built-in validations, making it straightforward to store and validate measurements in Rails models without external gems.
Offers a simple DSL to define custom units and conversion rates, allowing easy extension for domain-specific needs, as shown in the 'Adding new units' section.
Can parse measurements directly from strings like '123 grams' with automatic whitespace handling and alias support, simplifying user input processing.
Only bundles units for weight, length, and volume by default, requiring manual definition for other measurement types, which can be tedious for complex applications.
Does not support multiplication or division of measurements by other measurements, only scaling by scalars, restricting advanced scientific or engineering calculations.
While usable standalone, the gem is optimized for Rails with ActiveRecord, so non-Rails projects might find the API bloated or difficult to adapt without the Rails ecosystem.