Class: Numeric
Overview
Extensions to the Numeric class required by the fOOrth language system.
Instance Method Summary collapse
-
#foorth_embed ⇒ Object
Convert this number to a form suitable for embedding in a source string.
-
#to_foorth_c ⇒ Object
Convert this number to a single character string.
-
#to_foorth_n ⇒ Object
Convert this numeric to a numeric.
-
#to_foorth_r ⇒ Object
Convert this numeric to a rational.
Instance Method Details
#foorth_embed ⇒ Object
Convert this number to a form suitable for embedding in a source string.
Returns
-
An embeddable form of this number as a string.
8 9 10 |
# File 'lib/fOOrth/monkey_patch/numeric.rb', line 8 def self.to_s end |
#to_foorth_c ⇒ Object
Convert this number to a single character string.
13 14 15 16 17 18 19 20 21 |
# File 'lib/fOOrth/monkey_patch/numeric.rb', line 13 def to_foorth_c as_int = Integer.foorth_coerce(self) if as_int < 0 || as_int > 1_114_111 error "F40: Can't convert #{self} to a character." else [as_int].pack('U') end end |
#to_foorth_n ⇒ Object
Convert this numeric to a numeric. Return self.
24 25 26 |
# File 'lib/fOOrth/monkey_patch/numeric.rb', line 24 def to_foorth_n self end |
#to_foorth_r ⇒ Object
Convert this numeric to a rational.
29 30 31 |
# File 'lib/fOOrth/monkey_patch/numeric.rb', line 29 def to_foorth_r self.rationalize end |