Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_units/array.rb

Instance Method Summary collapse

Instance Method Details

#to_unit(other = nil) ⇒ Unit

Construct a unit from an array

Examples:

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

Parameters:

  • other (Object) (defaults to: nil)

    convert to same units as passed

Returns:



6
7
8
# File 'lib/ruby_units/array.rb', line 6

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