congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
org.jruby
Code IndexAdd Tabnine to your IDE (free)

How to use org.jruby

Best Java code snippets using org.jruby (Showing top 20 results out of 315)

origin: bazelbuild/bazel

public static void createRubyDescriptor(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cDescriptor = protobuf.defineClassUnder("Descriptor", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyDescriptor(runtime, klazz);
    }
  });
  cDescriptor.includeModule(runtime.getEnumerable());
  cDescriptor.defineAnnotatedMethods(RubyDescriptor.class);
}
origin: bazelbuild/bazel

public static void createRubyFileDescriptor(Ruby runtime) {
  RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cFieldDescriptor = mProtobuf.defineClassUnder("FieldDescriptor", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyFieldDescriptor(runtime, klazz);
    }
  });
  cFieldDescriptor.defineAnnotatedMethods(RubyFieldDescriptor.class);
}
origin: bazelbuild/bazel

public static void createRubyDescriptorPool(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cDescriptorPool = protobuf.defineClassUnder("DescriptorPool", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyDescriptorPool(runtime, klazz);
    }
  });
  cDescriptorPool.defineAnnotatedMethods(RubyDescriptorPool.class);
  descriptorPool = (RubyDescriptorPool) cDescriptorPool.newInstance(runtime.getCurrentContext(), Block.NULL_BLOCK);
}
origin: bazelbuild/bazel

public static void createProtobuf(Ruby runtime) {
  RubyModule mGoogle = runtime.getModule("Google");
  RubyModule mProtobuf = mGoogle.defineModuleUnder("Protobuf");
  mProtobuf.defineAnnotatedMethods(RubyProtobuf.class);
}
origin: bazelbuild/bazel

@JRubyMethod
public IRubyObject hash(ThreadContext context) {
  int hashCode = this.storage.hashCode();
  return context.runtime.newFixnum(hashCode);
}
origin: bazelbuild/bazel

public static int num2uint(IRubyObject value) {
  long longVal = RubyNumeric.num2long(value);
  if (longVal > UINT_MAX)
    throw value.getRuntime().newRangeError("Integer " + longVal + " too big to convert to 'unsigned int'");
  long num = longVal;
  if (num > Integer.MAX_VALUE || num < Integer.MIN_VALUE)
    // encode to UINT32
    num = (-longVal ^ (-1l >>> 32) ) + 1;
  RubyNumeric.checkInt(value, num);
  return (int) num;
}
origin: bazelbuild/bazel

public static void checkNameAvailability(ThreadContext context, String name) {
  if (context.runtime.getObject().getConstantAt(name) != null)
    throw context.runtime.newNameError(name + " is already defined", name);
}
origin: bazelbuild/bazel

public static long num2ulong(Ruby runtime, IRubyObject value) {
  if (value instanceof RubyFloat) {
    RubyBignum bignum = RubyBignum.newBignum(runtime, ((RubyFloat) value).getDoubleValue());
    return RubyBignum.big2ulong(bignum);
  } else if (value instanceof RubyBignum) {
    return RubyBignum.big2ulong((RubyBignum) value);
  } else {
    return RubyNumeric.num2long(value);
  }
}
origin: bazelbuild/bazel

private int normalizeArrayIndex(IRubyObject index) {
  int arrIndex = RubyNumeric.num2int(index);
  int arrSize = this.storage.size();
  if (arrIndex < 0 && arrSize > 0) {
    arrIndex = arrSize + arrIndex;
  }
  return arrIndex;
}
origin: bazelbuild/bazel

public RubyRepeatedField(Ruby runtime, RubyClass klazz, Descriptors.FieldDescriptor.Type fieldType, IRubyObject typeClass) {
  this(runtime, klazz);
  this.fieldType = fieldType;
  this.storage = runtime.newArray();
  this.typeClass = typeClass;
}
origin: bazelbuild/bazel

private void checkRepeatedFieldType(ThreadContext context, IRubyObject value,
                  Descriptors.FieldDescriptor fieldDescriptor) {
  Ruby runtime = context.runtime;
  if (!(value instanceof RubyRepeatedField)) {
    throw runtime.newTypeError("Expected repeated field array");
  }
}
origin: bazelbuild/bazel

public RubyBuilder(Ruby runtime, RubyClass metaClass) {
  super(runtime, metaClass);
  this.cDescriptor = (RubyClass) runtime.getClassFromPath("Google::Protobuf::Descriptor");
  this.cEnumDescriptor = (RubyClass) runtime.getClassFromPath("Google::Protobuf::EnumDescriptor");
  this.cMessageBuilderContext = (RubyClass) runtime.getClassFromPath("Google::Protobuf::MessageBuilderContext");
  this.cEnumBuilderContext = (RubyClass) runtime.getClassFromPath("Google::Protobuf::EnumBuilderContext");
}
origin: bazelbuild/bazel

public static void createRubyEnumDescriptor(Ruby runtime) {
  RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cEnumDescriptor = mProtobuf.defineClassUnder("EnumDescriptor", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyEnumDescriptor(runtime, klazz);
    }
  });
  cEnumDescriptor.includeModule(runtime.getEnumerable());
  cEnumDescriptor.defineAnnotatedMethods(RubyEnumDescriptor.class);
}
origin: bazelbuild/bazel

public static void createRubyEnumBuilderContext(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cMessageBuilderContext = protobuf.defineClassUnder("EnumBuilderContext", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyEnumBuilderContext(runtime, klazz);
    }
  });
  cMessageBuilderContext.defineAnnotatedMethods(RubyEnumBuilderContext.class);
}
origin: bazelbuild/bazel

public static void createRubyRepeatedField(Ruby runtime) {
  RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cRepeatedField = mProtobuf.defineClassUnder("RepeatedField", runtime.getObject(),
      new ObjectAllocator() {
        @Override
        public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
          return new RubyRepeatedField(runtime, klazz);
        }
      });
  cRepeatedField.defineAnnotatedMethods(RubyRepeatedField.class);
  cRepeatedField.includeModule(runtime.getEnumerable());
}
origin: bazelbuild/bazel

public static void createRubyMessageBuilderContext(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cMessageBuilderContext = protobuf.defineClassUnder("MessageBuilderContext", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyMessageBuilderContext(runtime, klazz);
    }
  });
  cMessageBuilderContext.defineAnnotatedMethods(RubyMessageBuilderContext.class);
}
origin: bazelbuild/bazel

public static void createRubyMap(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cMap = protobuf.defineClassUnder("Map", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
      return new RubyMap(ruby, rubyClass);
    }
  });
  cMap.includeModule(runtime.getEnumerable());
  cMap.defineAnnotatedMethods(RubyMap.class);
}
origin: bazelbuild/bazel

public static void createRubyOneofBuilderContext(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyModule internal = protobuf.defineModuleUnder("Internal");
  RubyClass cRubyOneofBuidlerContext = internal.defineClassUnder("OneofBuilderContext", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
      return new RubyOneofBuilderContext(ruby, rubyClass);
    }
  });
  cRubyOneofBuidlerContext.defineAnnotatedMethods(RubyOneofBuilderContext.class);
}
origin: bazelbuild/bazel

public static void createRubyOneofDescriptor(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cRubyOneofDescriptor = protobuf.defineClassUnder("OneofDescriptor", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
      return new RubyOneofDescriptor(ruby, rubyClass);
    }
  });
  cRubyOneofDescriptor.defineAnnotatedMethods(RubyOneofDescriptor.class);
  cRubyOneofDescriptor.includeModule(runtime.getEnumerable());
}
origin: bazelbuild/bazel

public static void createRubyBuilder(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cBuilder = protobuf.defineClassUnder("Builder", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyBuilder(runtime, klazz);
    }
  });
  cBuilder.defineAnnotatedMethods(RubyBuilder.class);
}
org.jruby

Most used classes

  • Ruby
    The Ruby object represents the top-level of a JRuby "instance" in a given VM. JRuby supports spawnin
  • ScriptingContainer
    ScriptingContainer provides various methods and resources that are useful for embedding Ruby in Java
  • IRubyObject
    Object is the parent class of all classes in Ruby. Its methods are therefore available to all object
  • RubyHash
    Implementation of the Hash class. Concurrency: no synchronization is required among readers, but all
  • RubyClass
  • RubyArray,
  • JavaEmbedUtils,
  • RubyInstanceConfig,
  • RubyString,
  • Block,
  • JRubyMethod,
  • RaiseException,
  • ByteList,
  • RubyInteger,
  • RubyFixnum,
  • RubySymbol,
  • ThreadContext,
  • RubyBoolean,
  • RubyObjectAdapter
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now