Sha256: 649af49797241ae6a37ecb2f3f65040abde7aed6ac3ed7fd3d7854820ea63265

Contents?: true

Size: 442 Bytes

Versions: 6

Compression:

Stored size: 442 Bytes

Contents

class Complex < Numeric
  def to_unit(other = nil)
    real_unit = self.real.to_unit
    image_unit = self.image.to_unit
    raise ArgumentError, 'Units on real and imaginary parts are incompatible' unless real_unit =~ image_unit 
    final_unit = (real_unit.units.empty? ? image_unit.units : real_unit.units).to_unit
    final_unit * Complex(real_unit.to(final_unit).scalar, image_unit.to(final_unit).scalar)
  end
  alias :unit :to_unit
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-units-1.1.5 lib/ruby_units/complex.rb
ruby-units-1.1.4 lib/ruby_units/complex.rb
ruby-units-1.0.2 lib/ruby_units/complex.rb
ruby-units-1.1.0 lib/ruby_units/complex.rb
ruby-units-1.1.2 lib/ruby_units/complex.rb
ruby-units-1.1.3 lib/ruby_units/complex.rb