org.jruby
Class RubyNumeric

java.lang.Object
  extended byorg.jruby.RubyObject
      extended byorg.jruby.RubyNumeric
All Implemented Interfaces:
java.lang.Cloneable, IRubyObject
Direct Known Subclasses:
RubyFloat, RubyInteger

public abstract class RubyNumeric
extends RubyObject

Version:
$Revision: 1.7 $
Author:
jpetersen

Field Summary
 
Fields inherited from class org.jruby.RubyObject
runtime
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyNumeric(Ruby ruby, RubyClass rubyClass)
           
 
Method Summary
 RubyNumeric abs()
          num_abs
 RubyInteger ceil()
          num_ceil
 RubyNumeric cmp(RubyNumeric other)
           
 RubyArray coerce(RubyNumeric other)
          num_coerce
protected  int compareValue(RubyNumeric other)
           
static RubyClass createNumericClass(Ruby ruby)
           
 RubyArray divmod(RubyNumeric other)
          num_divmod
 RubyBoolean eql(IRubyObject other)
          num_eql
 RubyBoolean equal(IRubyObject other)
          num_equal
static int fix2int(IRubyObject arg)
           
static long fix2long(IRubyObject arg)
           
 RubyInteger floor()
          num_floor
 RubyNumeric[] getCoerce(RubyNumeric other)
          !!!
abstract  double getDoubleValue()
           
abstract  long getLongValue()
           
 long getTruncatedLongValue()
           
 RubyBoolean int_p()
          num_int_p
 RubyNumeric modulo(RubyNumeric other)
          num_modulo
abstract  RubyNumeric multiplyWith(RubyBignum value)
           
 RubyNumeric multiplyWith(RubyFixnum value)
           
abstract  RubyNumeric multiplyWith(RubyFloat value)
           
abstract  RubyNumeric multiplyWith(RubyInteger value)
           
 IRubyObject nonzero_p()
          num_nonzero_p
static long num2long(IRubyObject arg)
           
static RubyNumeric numericValue(IRubyObject arg)
           
 RubyNumeric op_uminus()
          num_uminus
 RubyNumeric op_uplus()
          num_uplus
 IRubyObject rbClone()
          num_clone
 RubyNumeric remainder(RubyNumeric other)
          num_remainder
 RubyInteger round()
          num_round
static RubyFloat str2fnum(Ruby ruby, RubyString arg)
          Converts a string representation of a floating-point number to the numeric value.
static RubyInteger str2inum(Ruby ruby, RubyString str, int base)
          Converts a string representation of an integer to the integer value.
 RubyInteger truncate()
          num_truncate
 RubyBoolean veryEqual(IRubyObject other)
          num_equal
 RubyBoolean zero_p()
          num_zero_p
 
Methods inherited from class org.jruby.RubyObject
argCount, asSymbol, callbackFactory, callInit, callMethod, callMethod, callMethod, checkSafeString, convertToString, convertToType, convertType, createObjectClass, defineSingletonMethod, display, dup, equals, eval, eval, evalUnder, extend, extendObject, freeze, frozen, getInstanceVariable, getInstanceVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClass, getType, hash, hashCode, hasInstanceVariable, id, infectBy, inspect, instance_eval, instance_of, instance_variables, instanceVariableNames, isFalse, isFrozen, isKindOf, isNil, isTaint, isTrue, kind_of, makeMetaClass, marshalTo, method_missing, method, methods, nilObject, private_methods, protected_methods, removeInstanceVariable, respond_to, respondsTo, send, setFrozen, setInstanceVariable, setInstanceVariable, setInstanceVariables, setMetaClass, setTaint, setupClone, singleton_methods, singletonMethodsAllowed, specificEval, taint, tainted, to_a, to_s, toString, type, untaint
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RubyNumeric

public RubyNumeric(Ruby ruby,
                   RubyClass rubyClass)
Method Detail

getDoubleValue

public abstract double getDoubleValue()

getLongValue

public abstract long getLongValue()

getTruncatedLongValue

public long getTruncatedLongValue()

createNumericClass

public static RubyClass createNumericClass(Ruby ruby)

num2long

public static long num2long(IRubyObject arg)

fix2long

public static long fix2long(IRubyObject arg)

fix2int

public static int fix2int(IRubyObject arg)

numericValue

public static final RubyNumeric numericValue(IRubyObject arg)

str2inum

public static RubyInteger str2inum(Ruby ruby,
                                   RubyString str,
                                   int base)
Converts a string representation of an integer to the integer value. Parsing starts at the beginning of the string (after leading and trailing whitespace have been removed), and stops at the end or at the first character that can't be part of an integer. Leading signs are allowed. If base is zero, strings that begin with '0[xX]', '0[bB]', or '0' (optionally preceded by a sign) will be treated as hex, binary, or octal numbers, respectively. If a non-zero base is given, only the prefix (if any) that is appropriate to that base will be parsed correctly. For example, if the base is zero or 16, the string "0xff" will be converted to 256, but if the base is 10, it will come out as zero, since 'x' is not a valid decimal digit. If the string fails to parse as a number, zero is returned.

Parameters:
ruby - the ruby runtime
str - the string to be converted
base - the expected base of the number (2, 8, 10 or 16), or 0 if the method should determine the base automatically (defaults to 10).
Returns:
a RubyFixnum or (if necessary) a RubyBignum representing the result of the conversion, which will be zero if the conversion failed.

str2fnum

public static RubyFloat str2fnum(Ruby ruby,
                                 RubyString arg)
Converts a string representation of a floating-point number to the numeric value. Parsing starts at the beginning of the string (after leading and trailing whitespace have been removed), and stops at the end or at the first character that can't be part of a number. If the string fails to parse as a number, 0.0 is returned.

Parameters:
ruby - the ruby runtime
arg - the string to be converted
Returns:
a RubyFloat representing the result of the conversion, which will be 0.0 if the conversion failed.

coerce

public RubyArray coerce(RubyNumeric other)
num_coerce


getCoerce

public RubyNumeric[] getCoerce(RubyNumeric other)
!!!


rbClone

public IRubyObject rbClone()
num_clone

Specified by:
rbClone in interface IRubyObject
Overrides:
rbClone in class RubyObject

op_uplus

public RubyNumeric op_uplus()
num_uplus


op_uminus

public RubyNumeric op_uminus()
num_uminus


cmp

public RubyNumeric cmp(RubyNumeric other)

divmod

public RubyArray divmod(RubyNumeric other)
num_divmod


modulo

public RubyNumeric modulo(RubyNumeric other)
num_modulo


remainder

public RubyNumeric remainder(RubyNumeric other)
num_remainder


compareValue

protected int compareValue(RubyNumeric other)

veryEqual

public RubyBoolean veryEqual(IRubyObject other)
num_equal


equal

public RubyBoolean equal(IRubyObject other)
num_equal

Overrides:
equal in class RubyObject

eql

public RubyBoolean eql(IRubyObject other)
num_eql


abs

public RubyNumeric abs()
num_abs


int_p

public RubyBoolean int_p()
num_int_p


zero_p

public RubyBoolean zero_p()
num_zero_p


nonzero_p

public IRubyObject nonzero_p()
num_nonzero_p


floor

public RubyInteger floor()
num_floor


ceil

public RubyInteger ceil()
num_ceil


round

public RubyInteger round()
num_round


truncate

public RubyInteger truncate()
num_truncate


multiplyWith

public RubyNumeric multiplyWith(RubyFixnum value)

multiplyWith

public abstract RubyNumeric multiplyWith(RubyInteger value)

multiplyWith

public abstract RubyNumeric multiplyWith(RubyFloat value)

multiplyWith

public abstract RubyNumeric multiplyWith(RubyBignum value)


Copyright © 2002 Jan Arne Petersen. All Rights Reserved.