Method: Quantify::Unit::Base#load

Defined in:
lib/quantify/unit/base_unit.rb

#load(&block) ⇒ Object

Load an initialized Unit into the system of known units.

If a block is given, the unit can be configured prior to loading, in a similar to way to the #configure method.



225
226
227
228
229
230
# File 'lib/quantify/unit/base_unit.rb', line 225

def load(&block)
  block.call(self) if block_given?
  raise Exceptions::InvalidArgumentError, "A unit with the same label: #{self.name}) already exists" if loaded?
  Quantify::Unit.units << self if valid?
  return self
end