Method: Quantify::Unit::Base#configure

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

#configure(&block) ⇒ Object

Permits a block to be used, operating on self. This is useful for modifying the attributes of an already instantiated unit, especially when defining units on the basis of operation on existing units for adding specific (rather than derived) names or symbols, e.g.

(Unit.pound_force/(Unit.in**2)).configure do |unit|
  unit.symbol = 'psi'
  unit.label = 'psi'
  unit.name = 'pound per square inch'
end


206
207
208
209
# File 'lib/quantify/unit/base_unit.rb', line 206

def configure(&block)
  block.call(self) if block_given?
  return self if valid?
end