Method: Quantify::Unit::Base.prefix_and_load
- Defined in:
- lib/quantify/unit/base_unit.rb
.prefix_and_load(prefixes, units) ⇒ Object
Mass load prefixed units. First argument is a single or array of units. Second argument is a single or array of prefixes. All specfied units will be loaded with all specified prefixes.
33 34 35 36 37 38 39 40 41 |
# File 'lib/quantify/unit/base_unit.rb', line 33 def self.prefix_and_load(prefixes,units) [units].flatten.each do |unit| unit = Unit.for(unit) [prefixes].flatten.each do |prefix| prefixed_unit = unit.with_prefix(prefix) rescue unit prefixed_unit.load unless prefixed_unit.loaded? end end end |