Example #1
0
  // @RubyLevelMethod(name="intern", alias="to_sym")
  public RubySymbol intern() {
    if (this.sb_.length() <= 0) {
      throw new RubyException(RubyRuntime.ArgumentErrorClass, "interning empty string");
    }

    RubyID id = RubyID.intern(this.sb_.toString());
    return id.toSymbol();
  }
Example #2
0
 // @RubyLevelMethod(name="collect!")
 public RubyValue collect_danger(RubyBlock block) {
   RubyArray a = (RubyArray) RubyAPI.callPublicNoArgMethod(this, block, RubyID.intern("collect"));
   clear();
   for (int i = 0; i < a.size(); i++) {
     add(a.get(i));
   }
   return this;
 }
  @RubyLevelMethod(name = "respond_to?")
  public static RubyValue respond_to(RubyValue receiver, RubyArray args) {
    if (null == args || args.size() < 1) {
      int actual_argc = (null == args) ? 0 : args.size();
      throw new RubyException(
          RubyRuntime.ArgumentErrorClass,
          "in `respond_to': wrong number of arguments (" + actual_argc + " for 1)");
    }

    boolean include_private = (RubyConstant.QTRUE == args.get(1));
    RubyID mid = RubyID.intern(args.get(0).toStr());
    return ObjectFactory.createBoolean(hasMethod(receiver, mid, include_private));
  }
 @RubyLevelMethod(name = "method")
 public static RubyValue objMethod(RubyValue receiver, RubyValue arg) {
   String method_name = arg.toStr();
   RubyID mid = RubyID.intern(method_name);
   RubyMethod m = receiver.findMethod(mid);
   if (null == m) {
     throw new RubyException(
         RubyRuntime.NameErrorClass,
         "public method '"
             + method_name
             + "' can not be found in '"
             + receiver.getRubyClass().getName()
             + "'");
   }
   return ObjectFactory.createMethod(receiver, method_name, m);
 }
 @RubyLevelMethod(name = "send", alias = "__send__")
 public static RubyValue send(RubyValue receiver, RubyArray args, RubyBlock block) {
   RubyValue method_name = args.delete_at(0);
   RubyID mid = RubyID.intern(method_name.toStr());
   return RubyAPI.callMethod(receiver, args, block, mid);
 }
 @RubyLevelMethod(name = "send", alias = "__send__")
 public static RubyValue send(
     RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block) {
   RubyID mid = RubyID.intern(arg0.toStr());
   return RubyAPI.callOneArgMethod(receiver, arg1, block, mid);
 }
Example #7
0
 public RubyID toID() {
   return RubyID.intern(this.sb_.toString());
 }