Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
meh committed Jan 12, 2014
1 parent bf01576 commit ac2c7c6
Show file tree
Hide file tree
Showing 8 changed files with 786 additions and 448 deletions.
33 changes: 33 additions & 0 deletions opal/corelib/complex.rb
@@ -1,3 +1,36 @@
require 'corelib/numeric'

class Complex < Numeric
attr_reader :real, :imag

def initialize(real, imag)
@real = real
@imag = imag
end

def denominator
@real.denominator.lcm(@imag.denominator)
end

alias imaginary imag

def numerator

end

def real?
false
end
end

module Kernel
def Complex(real, imag = nil)
if imag
Complex.new(real, imag)
elsif Integer === real
Complex.new(real, 0)
else
raise NotImplementedError
end
end
end

0 comments on commit ac2c7c6

Please sign in to comment.