Class: Complex
Overview
Extensions to the Complex class required by the fOOrth language system.
Instance Method Summary collapse
-
#foorth_coerce(arg) ⇒ Object
Coerce the argument to match my type.
-
#foorth_embed ⇒ Object
Convert this complex number to a form suitable for embedding in a source string.
-
#to_foorth_c ⇒ Object
Cannot convert this number to a single character string.
-
#to_foorth_r ⇒ Object
Cannot convert this number to a Rational.
Instance Method Details
#foorth_coerce(arg) ⇒ Object
Coerce the argument to match my type.
15 16 17 18 19 |
# 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 ⇒ Object
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.
8 9 10 |
# File 'lib/fOOrth/monkey_patch/complex.rb', line 8 def "Complex(#{self.real.},#{self.imaginary.})" end |
#to_foorth_c ⇒ Object
Cannot convert this number to a single character string.
22 23 24 |
# 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 ⇒ Object
Cannot convert this number to a Rational.
27 28 29 |
# File 'lib/fOOrth/monkey_patch/complex.rb', line 27 def to_foorth_r nil end |