class Complex

Extensions to the Complex class required by the fOOrth language system.

Public Instance Methods

foorth_coerce(arg) click to toggle source

Coerce the argument to match my type.

# File lib/fOOrth/monkey_patch/complex.rb, line 15
def foorth_coerce(arg)
  Complex(arg)
rescue
  error "F40: Cannot coerce a #{arg.foorth_name} to a Complex"
end
foorth_embed() click to toggle source

Convert this complex number to a form suitable for embedding in a source string.
Returns

  • An embeddable form of this complex number as a string.

# File lib/fOOrth/monkey_patch/complex.rb, line 8
def foorth_embed
  "Complex(#{self.real.foorth_embed},#{self.imaginary.foorth_embed})"
end
to_foorth_c() click to toggle source

Cannot convert this number to a single character string.

# File lib/fOOrth/monkey_patch/complex.rb, line 22
def to_foorth_c
  error "F40: Cannot convert a Complex instance to a character"
end
to_foorth_r() click to toggle source

Cannot convert this number to a Rational.

# File lib/fOOrth/monkey_patch/complex.rb, line 27
def to_foorth_r
  nil
end