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

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

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

Ruby.getClass介绍

[英]Retrieve the class with the given name from the Object namespace.
[中]从对象命名空间中检索具有给定名称的类。

代码示例

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

public RubyBigDecimal(Ruby runtime, BigDecimal value) {
  super(runtime, runtime.getClass("BigDecimal"));
  this.isNaN = false;
  this.infinitySign = 0;
  this.zeroSign = 0;
  this.value = value;
}

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

public RubyBigDecimal(Ruby runtime, BigDecimal value, boolean isNan) {
  super(runtime, runtime.getClass("BigDecimal"));
  this.isNaN = isNan;
  this.infinitySign = 0;
  this.zeroSign = 0;
  this.value = value;
}

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

public RubyClass getArrayJavaProxyCreatorClass() {
  RubyClass clazz;
  if ((clazz = arrayJavaProxyCreatorClass) != null) return clazz;
  return arrayJavaProxyCreatorClass = runtime.getClass("ArrayJavaProxyCreator");
}

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

public static RuntimeException sockerr_with_trace(Ruby runtime, String msg, StackTraceElement[] trace) {
  String eol = System.getProperty("line.separator");
  StringBuilder sb = new StringBuilder();
  sb.append(msg);
  for (int i = 0, il = trace.length; i < il; i++) {
    sb.append(eol).append(trace[i].toString());
  }
  return RaiseException.from(runtime, runtime.getClass("SocketError"), sb.toString());
}

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

@Override
protected IRubyObject addrFor(ThreadContext context, InetSocketAddress addr, boolean reverse) {
  final Ruby runtime = context.runtime;
  return new Addrinfo(runtime, runtime.getClass("Addrinfo"), addr.getAddress(), addr.getPort(), Sock.SOCK_DGRAM);
}

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

@Deprecated
public RaiseException newIllegalSequence(String message) {
  return newRaiseException(getClass("Iconv").getClass("IllegalSequence"), message);
}

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

private static boolean isOverflowExceptionMode(Ruby runtime) {
  RubyFixnum currentExceptionMode = (RubyFixnum)runtime.getClass("BigDecimal")
      .searchInternalModuleVariable("vpExceptionMode");
  RubyFixnum EXCEPTION_OVERFLOW = (RubyFixnum)runtime.getClass("BigDecimal")
      .getConstant("EXCEPTION_OVERFLOW");
  return (currentExceptionMode.getLongValue() & EXCEPTION_OVERFLOW.getLongValue()) != 0;
}

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

public static RubyClass createNameErrorMessageClass(Ruby runtime, RubyClass nameErrorClass) {
  RubyClass messageClass = nameErrorClass.defineClassUnder("Message", runtime.getClass("Data"), RubyNameErrorMessage.NAMEERRORMESSAGE_ALLOCATOR);
  messageClass.defineAnnotatedMethods(RubyNameErrorMessage.class);
  return messageClass;
}

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

public void load(Ruby runtime, boolean wrap) {
  assert !runtime.is1_8() : "the native delegator extension is not compatible with 1.8";
  
  RubyClass delegateClass = runtime.getClass("Delegator");
  delegateClass.defineAnnotatedMethods(NativeDelegateLibrary.class);
}

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

@JRubyMethod(name = "BigDecimal", module = true, visibility = Visibility.PRIVATE) // required = 1, optional = 1
public static IRubyObject newBigDecimal(ThreadContext context, IRubyObject recv, IRubyObject arg) {
  return newInstance(context, context.runtime.getClass("BigDecimal"), arg);
}

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

@JRubyMethod(name = "BigDecimal", module = true, visibility = Visibility.PRIVATE) // required = 1, optional = 1
  public static IRubyObject newBigDecimal(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) {
    return newInstance(context, context.runtime.getClass("BigDecimal"), arg0, arg1);
  }
}

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

static RubyClass define(Ruby runtime, RubyClass NameError) {
  RubyClass Message = NameError.defineClassUnder("Message", runtime.getClass("Data"), ALLOCATOR);
  NameError.setConstantVisibility(runtime, "Message", true);
  Message.defineAnnotatedMethods(RubyNameErrorMessage.class);
  return Message;
}

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

public static void createOption(Ruby runtime) {
  RubyClass addrinfo = runtime.getClass("Socket").defineClassUnder(
      "Option",
      runtime.getObject(),
      new ObjectAllocator() {
        public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
          return new Option(runtime, klazz);
        }
      });
  addrinfo.defineAnnotatedMethods(Option.class);
}

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

public static void createOption(Ruby runtime) {
  RubyClass addrinfo = runtime.getClass("Socket").defineClassUnder(
      "Option",
      runtime.getObject(),
      new ObjectAllocator() {
        public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
          return new Option(runtime, klazz);
        }
      });
  addrinfo.defineAnnotatedMethods(Option.class);
}

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

@Override
public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
  StaticScope staticScope = scope.getStaticScope();
  return staticScope != null ? staticScope.getModule() : context.runtime.getClass(scope.getName());
}

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

static void createTCPSocket(Ruby runtime) {
  RubyClass rb_cTCPSocket = runtime.defineClass("TCPSocket", runtime.getClass("IPSocket"), TCPSOCKET_ALLOCATOR);
  rb_cTCPSocket.defineAnnotatedMethods(RubyTCPSocket.class);
  runtime.getObject().setConstant("TCPsocket",rb_cTCPSocket);
}

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

static void createUNIXSocket(Ruby runtime) {
  RubyClass rb_cUNIXSocket = runtime.defineClass("UNIXSocket", runtime.getClass("BasicSocket"), UNIXSOCKET_ALLOCATOR);
  runtime.getObject().setConstant("UNIXsocket", rb_cUNIXSocket);
  
  rb_cUNIXSocket.defineAnnotatedMethods(RubyUNIXSocket.class);
}

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

@JRubyMethod(name = "puts", rest = true)
public IRubyObject puts(ThreadContext context, IRubyObject[] args) {
  final RubyClass StringIO = context.runtime.getClass("StringIO");
  StringIO sio = (StringIO) StringIO.newInstance(context, IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
  
  sio.puts(context, args);
  write(sio.string(context));
  return context.nil;
}

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

@JRubyMethod
public IRubyObject local_address(ThreadContext context) {
  Ruby runtime = context.runtime;
  InetSocketAddress address = getInetSocketAddress();
  if (address != null) {
    SocketType socketType = SocketType.forChannel(getChannel());
    return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType);
  }
  UnixSocketAddress unix = getUnixSocketAddress();
  return Addrinfo.unix(context, runtime.getClass("Addrinfo"), runtime.newString(unix.path()));
}

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

@JRubyMethod(name = "ruby", meta = true)
public static IRubyObject ruby(ThreadContext context, IRubyObject recv) {
  Ruby runtime = context.runtime;
  RubyHash configHash = (RubyHash) runtime.getModule("RbConfig").getConstant("CONFIG");
  IRubyObject bindir            = configHash.op_aref(context, runtime.newString("bindir"));
  IRubyObject ruby_install_name = configHash.op_aref(context, runtime.newString("ruby_install_name"));
  IRubyObject exeext            = configHash.op_aref(context, runtime.newString("EXEEXT"));
  return Helpers.invoke(context, runtime.getClass("File"), "join", bindir, ruby_install_name.callMethod(context, "+", exeext));
}

相关文章

微信公众号

最新文章

更多

Ruby类方法