Module: Unitwise
- Defined in:
- lib/unitwise/parse.rb
Overview
Unitwise is a library for performing mathematical operations and conversions on all units defined by the [Unified Code for Units of Measure(UCUM).
Class Method Summary collapse
-
.parse(value) ⇒ Unitwise::Measurement
Parse a string into a unitwise value.
Class Method Details
.parse(value) ⇒ Unitwise::Measurement
Parse a string into a unitwise value
11 12 13 14 15 16 17 |
# File 'lib/unitwise/parse.rb', line 11 def self.parse(value) return nil if value.nil? values = value.split(' ') return nil if values.length != 2 return nil unless valid? values[1] Unitwise::Measurement.new(values[0].to_f, values[1]) end |