Пример #1
0
  @RubyLevelMethod(name = ">")
  public RubyValue opGt(RubyValue v) {
    if (v instanceof RubyFixnum) {
      return ObjectFactory.createBoolean(this.value_ > ((RubyFixnum) v).value_);
    } else if (v instanceof RubyFloat) {
      return ObjectFactory.createBoolean(this.value_ > v.toFloat());
    }

    return coerceRelop(RubyID.gtID, v);
  }
 @RubyLevelMethod(name = "===")
 public static RubyValue objEqual(RubyValue receiver, RubyValue arg) {
   if (receiver == arg) {
     return RubyConstant.QTRUE;
   } else {
     boolean result = RubyAPI.callPublicOneArgMethod(receiver, arg, null, RubyID.equalID).isTrue();
     return ObjectFactory.createBoolean(result);
   }
 }
Пример #3
0
  @RubyLevelMethod(name = "==")
  public RubyValue opEqual(RubyValue arg) {
    if (arg == this) {
      return RubyConstant.QTRUE;
    }

    if (arg instanceof RubyFixnum) {
      return ObjectFactory.createBoolean(this.value_ == ((RubyFixnum) arg).value_);
    }

    return RubyAPI.callOneArgMethod(arg, this, null, RubyID.equalID);
  }
  @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));
  }
Пример #5
0
  // @RubyLevelMethod(name="==")
  public RubyValue opEqual(RubyValue v) {
    if (this == v) {
      return RubyConstant.QTRUE;
    }

    if (v instanceof RubyString) {
      RubyString str = ((RubyString) v);
      if ((this.sb_.length() == str.sb_.length() && this.cmp(str) == 0)) {
        return RubyConstant.QTRUE;
      } else {
        return RubyConstant.QFALSE;
      }
    }

    if (v.respondTo(RubyID.toStrID)) {
      return ObjectFactory.createBoolean(v.equals(this));
    } else {
      return RubyConstant.QFALSE;
    }
  }
Пример #6
0
 // @RubyLevelMethod(name="eql?")
 public RubyValue opEql(RubyValue v) {
   return ObjectFactory.createBoolean(equals(v, false));
 }
Пример #7
0
 // @RubyLevelMethod(name="empty?")
 public RubyValue empty_p() {
   return ObjectFactory.createBoolean(this.array_.isEmpty());
 }
 @RubyLevelMethod(name = "tainted?")
 public static RubyValue tainted(RubyValue receiver) {
   return ObjectFactory.createBoolean(receiver.tainted());
 }
 @RubyLevelMethod(name = "frozen?")
 public static RubyValue frozen(RubyValue receiver) {
   return ObjectFactory.createBoolean(receiver.frozen());
 }
 @RubyLevelMethod(name = "block_given?", alias = "iterator?", module = true)
 public static RubyValue blockGivenP(RubyValue receiver, RubyBlock block) {
   return ObjectFactory.createBoolean(null != block);
 }
 @RubyLevelMethod(
     name = "==",
     alias = {"equal?", "eql?"})
 public static RubyValue opEqual(RubyValue receiver, RubyValue arg) {
   return ObjectFactory.createBoolean(receiver == arg);
 }
 @RubyLevelMethod(name = "instance_of?")
 public static RubyValue instanceOf(RubyValue receiver, RubyValue arg) {
   return ObjectFactory.createBoolean(receiver.getRubyClass().getRealClass() == arg);
 }
 @RubyLevelMethod(name = "kind_of?", alias = "is_a?")
 public static RubyValue kindOf(RubyValue receiver, RubyValue arg) {
   return ObjectFactory.createBoolean(RubyAPI.isKindOf(arg, receiver));
 }
Пример #14
0
 // RHO_MOBILE
 // @RubyLevelMethod(name = "include?")
 public RubyValue include_p(RubyValue arg) {
   int nIndex = sb_.toString().indexOf(arg.toStr());
   return ObjectFactory.createBoolean(nIndex >= 0);
 }