if (rubyObject instanceof RubyBignum) {
return ((RubyBignum)rubyObject).getValue();
} else if (rubyObject instanceof RubyNumeric) {
return BigInteger.valueOf (((RubyNumeric)rubyObject).getLongValue());
} else if (rubyObject.respondsTo("to_i")) {
RubyNumeric rubyNumeric = ((RubyNumeric)rubyObject.callMethod(context, "to_f"));
return BigInteger.valueOf (rubyNumeric.getLongValue());
}
} else if (javaClass == BigDecimal.class && !(rubyObject instanceof JavaObject)) {
if (rubyObject.respondsTo("to_f")) {
double double_value = ((RubyNumeric)rubyObject.callMethod(context, "to_f")).getDoubleValue();
return new BigDecimal(double_value);