Class: UOM::UnitFactory
- Inherits:
-
Object
- Object
- UOM::UnitFactory
- Defined in:
- lib/uom/unit_factory.rb
Overview
A UnitFactory creates Unit instances.
Constant Summary collapse
- LABEL_EXPONENT_HASH =
{:square=>2, :sq=>2, :cubic=>3, :cu=>3}
Instance Method Summary collapse
-
#create(label) ⇒ Object
Returns the unit with the given label.
Instance Method Details
#create(label) ⇒ Object
Returns the unit with the given label. Creates a new unit if necessary.
Raises MeasurementError if the unit could not be created.
14 15 16 |
# File 'lib/uom/unit_factory.rb', line 14 def create(label) create_atomic(label.to_s) or create_composite(label.to_s) or raise MeasurementError.new("Unit '#{label}' not found") end |