org.jruby.Ruby.getFloat()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.jruby.Ruby.getFloat方法的一些代码示例,展示了Ruby.getFloat的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getFloat方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getFloat

Ruby.getFloat介绍

[英]Retrieve the invalidator for Float reopening
[中]检索失效器以重新打开浮动

代码示例

代码示例来源:origin: org.jruby/jruby-complete

public RubyFloat(Ruby runtime, double value) {
  super(runtime.getFloat());
  this.value = value;
  this.flags |= FROZEN_F;
}

代码示例来源:origin: org.jruby/jruby-core

public RubyFloat(Ruby runtime, double value) {
  super(runtime.getFloat());
  this.value = value;
  this.flags |= FROZEN_F;
}

代码示例来源:origin: org.jruby/jruby-core

public static RubyFloat convertToFloat(IRubyObject self) {
  return (RubyFloat) TypeConverter.convertToType(self, getRuntime(self).getFloat(), "to_f");
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static IRubyObject checkFloatType(Ruby runtime, IRubyObject obj) {
  if (obj instanceof RubyFloat) return obj;
  if (!(obj instanceof RubyNumeric)) return runtime.getNil();
  return TypeConverter.convertToTypeWithCheck(obj, runtime.getFloat(), "to_f");
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Tries to convert this object to a Ruby Float using the "to_f"
 * method.
 */
public RubyFloat convertToFloat() {
  return (RubyFloat) TypeConverter.convertToType(this, getRuntime().getFloat(), "to_f");
}

代码示例来源:origin: org.jruby/jruby-complete

public static IRubyObject checkFloatType(Ruby runtime, IRubyObject obj) {
  if (obj instanceof RubyFloat) return obj;
  ThreadContext context = runtime.getCurrentContext();
  TypeConverterSites sites = sites(context);
  return TypeConverter.convertToTypeWithCheck(context, obj, runtime.getFloat(), sites.to_f_checked);
}

代码示例来源:origin: org.jruby/jruby-core

public static IRubyObject checkFloatType(Ruby runtime, IRubyObject obj) {
  if (obj instanceof RubyFloat) return obj;
  ThreadContext context = runtime.getCurrentContext();
  TypeConverterSites sites = sites(context);
  return TypeConverter.convertToTypeWithCheck(context, obj, runtime.getFloat(), sites.to_f_checked);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@JRubyMethod
  public static IRubyObject prec_f(ThreadContext context, IRubyObject receiver, Block block) {
    return receiver.getRuntime().getFloat().callMethod(context, "induced_from", receiver);
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@JRubyMethod
  public static IRubyObject prec_f(ThreadContext context, IRubyObject receiver, Block block) {
    return receiver.getRuntime().getFloat().callMethod(context, "induced_from", receiver);
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private static RubyFloat needFloat(IRubyObject x) {
  if (x instanceof RubyFloat) {
    return (RubyFloat)x;
  }
  if (!x.getRuntime().getNumeric().isInstance(x)) {
    TypeConverter.handleUncoercibleObject(true, x, x.getRuntime().getFloat());
  }
  return (RubyFloat) TypeConverter.convertToType19(x, x.getRuntime().getFloat(), "to_f", true);
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyFloat toFloat(Ruby runtime, IRubyObject obj) {
  if (obj instanceof RubyNumeric) {
    return ((RubyNumeric) obj).convertToFloat();
  }
  if (obj instanceof RubyString || obj.isNil()) {
    throw runtime.newTypeError(obj, "Float");
  }
  return (RubyFloat) TypeConverter.convertToType(obj, runtime.getFloat(), "to_f", true);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Tries to convert this object to a Ruby Float using the "to_f" method.
 * @return float representation of this
 */
@Override
public RubyFloat convertToFloat() {
  Ruby runtime = getRuntime();
  ThreadContext context = runtime.getCurrentContext();
  BasicObjectSites sites = sites(context);
  return (RubyFloat) TypeConverter.convertToType(context, this, runtime.getFloat(), sites.to_f_checked);
}

代码示例来源:origin: org.jruby/jruby-core

public static RubyFloat toFloat(Ruby runtime, IRubyObject obj) {
  if (obj instanceof RubyNumeric) {
    return ((RubyNumeric) obj).convertToFloat();
  }
  if (obj instanceof RubyString || obj.isNil()) {
    throw runtime.newTypeError(obj, "Float");
  }
  return (RubyFloat) TypeConverter.convertToType(obj, runtime.getFloat(), "to_f", true);
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Tries to convert this object to a Ruby Float using the "to_f" method.
 * @return float representation of this
 */
@Override
public RubyFloat convertToFloat() {
  Ruby runtime = getRuntime();
  ThreadContext context = runtime.getCurrentContext();
  BasicObjectSites sites = sites(context);
  return (RubyFloat) TypeConverter.convertToType(context, this, runtime.getFloat(), sites.to_f_checked);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static RubyNumeric toFloat(Ruby runtime, IRubyObject obj) {
  RubyClass floatClass = runtime.getFloat();
  
  if (floatClass.isInstance(obj)) return (RubyNumeric) obj;
  if (!runtime.getNumeric().isInstance(obj)) throw runtime.newTypeError(obj, "Float");
  return (RubyNumeric) convertToType19(obj, floatClass, "to_f", true);
}
/**

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static RubyNumeric toFloat(Ruby runtime, IRubyObject obj) {
  RubyClass floatClass = runtime.getFloat();
  
  if (floatClass.isInstance(obj)) return (RubyNumeric) obj;
  if (!runtime.getNumeric().isInstance(obj)) throw runtime.newTypeError(obj, "Float");
  return (RubyNumeric) convertToType19(obj, floatClass, "to_f", true);
}
/**

代码示例来源:origin: org.jruby/jruby-complete

protected void invalidateCoreClasses() {
  if (!getRuntime().isBootingCore()) {
    if (this == getRuntime().getFixnum()) {
      getRuntime().reopenFixnum();
    } else if (this == getRuntime().getFloat()) {
      getRuntime().reopenFloat();
    }
  }
}

代码示例来源:origin: org.jruby/jruby-core

protected void invalidateCoreClasses() {
  if (!getRuntime().isBootingCore()) {
    if (this == getRuntime().getFixnum()) {
      getRuntime().reopenFixnum();
    } else if (this == getRuntime().getFloat()) {
      getRuntime().reopenFloat();
    }
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected void invalidateCoreClasses() {
  if (!getRuntime().isBooting()) {
    if (this == getRuntime().getFixnum()) {
      getRuntime().reopenFixnum();
    } else if (this == getRuntime().getFloat()) {
      getRuntime().reopenFloat();
    }
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@JRubyMethod(name = "initialize", visibility = PRIVATE, compat = RUBY2_0)
public IRubyObject initialize20(ThreadContext context, IRubyObject object, Block block) {
  Ruby runtime = context.runtime;
  RubySymbol each = runtime.newSymbol("each");
  
  // check for size
  if ((object.isNil() || runtime.getProc().isInstance(object)) ||
      runtime.getFloat().isInstance(object) && ((RubyFloat)object).getDoubleValue() == Float.POSITIVE_INFINITY) {
    // object is nil, a proc, or infinity; use it for size
    IRubyObject gen = context.runtime.getModule("JRuby").getClass("Generator").callMethod(context, "new", new IRubyObject[0], block);
    return initialize20(gen, each, NULL_ARRAY, object);
  }
  return initialize(object, each, NULL_ARRAY);
}

相关文章

Ruby类方法