Module: CompositeUnitMeasurements
- Defined in:
- lib/composite_unit_measurements/version.rb,
lib/composite_unit_measurements/base.rb,
lib/composite_unit_measurements/time.rb,
lib/composite_unit_measurements/length.rb,
lib/composite_unit_measurements/volume.rb,
lib/composite_unit_measurements/weight.rb
Overview
Note:
This module provides parsers and utilities for handling composite unit measurements. It allows parsing and manipulation of various composite measurements for units of length
, weight
, time
etc.
Defined Under Namespace
Classes: Length, Time, Volume, Weight
Constant Summary collapse
- REAL_NUMBER =
Matches real numbers in the form of 31, +72, or -12.
/ (?: # Start of non-capturing group [+-]? # Optional plus (+) or minus (-) sign \d+ # One or more digits ) # End of non-capturing group /x.freeze
- RATIONAL_NUMBER =
Matches a rational number in the form of a/b (fractional) or a b/c (mixed fractional).
/ (?: # Start of optional non-capturing group [+-]? # Optional plus (+) or minus (-) sign \d+ # One or more digits \s+ # One or more whitespace )? # End of optional non-capturing group ( # Start of capturing group for the fraction (\d+) # Capture the numerator (one or more digits) \/ # Match the forward slash, indicating division (\d+) # Capture the denominator (one or more digits) ) # End of capturing group for the fraction /x.freeze
- SCIENTIFIC_NUMBER =
Matches a scientific number in various formats like 1.23E+4 or -5.67e-8.
/ (?: # Start of non-capturing group [+-]? # Optional plus (+) or minus (-) sign \d* # Zero or more digits (integer part) \.? # Optional decimal point \d+ # One or more digits (fractional part) (?: # Start of non-capturing group for exponent part [Ee] # Match 'E' or 'e' for exponentiation [+-]? # Optional plus (+) or minus (-) sign for exponent \d+ # One or more digits (exponent value) )? # End of non-capturing group of exponent part (optional) ) # End of non-capturing group /x.freeze
- COMPLEX_NUMBER =
Matches complex numbers in the form of a+bi, where both ‘a’ and ‘b’ can be in scientific notation. It captures the real and imaginary parts.
/ #{SCIENTIFIC_NUMBER} # Pattern for scientific number #{SCIENTIFIC_NUMBER} # Pattern for scientific number i # Match the letter 'i' (the imaginary unit) /x.freeze
- ANY_NUMBER =
Matches any number, including scientific, complex, rational, and real numbers.
/(?<number>#{SCIENTIFIC_NUMBER}|#{COMPLEX_NUMBER}|#{RATIONAL_NUMBER}|#{REAL_NUMBER})/.freeze
- VERSION =
Current stable version
"0.5.0"