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

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

本文整理了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

  1. public RubyBigDecimal(Ruby runtime, BigDecimal value) {
  2. super(runtime, runtime.getClass("BigDecimal"));
  3. this.isNaN = false;
  4. this.infinitySign = 0;
  5. this.zeroSign = 0;
  6. this.value = value;
  7. }

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

  1. public RubyBigDecimal(Ruby runtime, BigDecimal value, boolean isNan) {
  2. super(runtime, runtime.getClass("BigDecimal"));
  3. this.isNaN = isNan;
  4. this.infinitySign = 0;
  5. this.zeroSign = 0;
  6. this.value = value;
  7. }

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

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

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

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

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

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

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

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

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

  1. private static boolean isOverflowExceptionMode(Ruby runtime) {
  2. RubyFixnum currentExceptionMode = (RubyFixnum)runtime.getClass("BigDecimal")
  3. .searchInternalModuleVariable("vpExceptionMode");
  4. RubyFixnum EXCEPTION_OVERFLOW = (RubyFixnum)runtime.getClass("BigDecimal")
  5. .getConstant("EXCEPTION_OVERFLOW");
  6. return (currentExceptionMode.getLongValue() & EXCEPTION_OVERFLOW.getLongValue()) != 0;
  7. }

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

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

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

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

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

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

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

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

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

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

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

  1. public static void createOption(Ruby runtime) {
  2. RubyClass addrinfo = runtime.getClass("Socket").defineClassUnder(
  3. "Option",
  4. runtime.getObject(),
  5. new ObjectAllocator() {
  6. public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
  7. return new Option(runtime, klazz);
  8. }
  9. });
  10. addrinfo.defineAnnotatedMethods(Option.class);
  11. }

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

  1. public static void createOption(Ruby runtime) {
  2. RubyClass addrinfo = runtime.getClass("Socket").defineClassUnder(
  3. "Option",
  4. runtime.getObject(),
  5. new ObjectAllocator() {
  6. public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
  7. return new Option(runtime, klazz);
  8. }
  9. });
  10. addrinfo.defineAnnotatedMethods(Option.class);
  11. }

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

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

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

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

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

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

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

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

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

  1. @JRubyMethod
  2. public IRubyObject local_address(ThreadContext context) {
  3. Ruby runtime = context.runtime;
  4. InetSocketAddress address = getInetSocketAddress();
  5. if (address != null) {
  6. SocketType socketType = SocketType.forChannel(getChannel());
  7. return new Addrinfo(runtime, runtime.getClass("Addrinfo"), address, socketType.getSocketType(), socketType);
  8. }
  9. UnixSocketAddress unix = getUnixSocketAddress();
  10. return Addrinfo.unix(context, runtime.getClass("Addrinfo"), runtime.newString(unix.path()));
  11. }

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

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

相关文章

Ruby类方法