Method: Quantify::Dimensions#initialize

Defined in:
lib/quantify/dimensions.rb

#initialize(options = {}) ⇒ Dimensions

Initialize a new Dimension object.

The options argument is a hash which represents the base dimensions that define the physical quantity. Each key-value pair should consist of a key included in the BASE_QUANTITIES array, and a value which represents the index/power of that base quantity.

In addition, a name or description of the physical quantity can be specified (i.e. ‘acceleration’, ‘electric_current’). This is optional for creating a new Dimensions instance, but required if that object is to be loaded into the @@dimensions class array. e.g.:

Dimensions.new :physical_quantity => :density,
               :mass => 1,
               :length => -3


184
185
186
187
188
189
190
# File 'lib/quantify/dimensions.rb', line 184

def initialize(options={})
  if options.has_key?(:physical_quantity)
    @physical_quantity = options.delete(:physical_quantity).remove_underscores.downcase
  end
  enumerate_base_quantities(options)
  describe
end