Module: RubyUnits::Array

Included in:
Array
Defined in:
lib/ruby_units/array.rb

Overview

Extra methods for [::Array] to support conversion to [RubyUnits::Unit]

Instance Method Summary collapse

Instance Method Details

#to_unit(other = nil) ⇒ RubyUnits::Unit

Construct a unit from an array

Examples:

[1, ‘mm’].to_unit => RubyUnits::Unit.new(“1 mm”)

Parameters:

Returns:



11
12
13
# File 'lib/ruby_units/array.rb', line 11

def to_unit(other = nil)
  other ? RubyUnits::Unit.new(self).convert_to(other) : RubyUnits::Unit.new(self)
end