Exemplo n.º 1
0
  // RHO_COMMENT
  public boolean equals(Object o, boolean bConvToAry) {
    if (this == o) {
      return true;
    }

    if (o instanceof RubyArray) {
      RubyArray that = (RubyArray) o;
      int size = array_.size();
      if (size != that.size()) {
        return false;
      }

      for (int i = 0; i < size; ++i) {
        if (!this.get(i).equals(that.get(i))) {
          return false;
        }
      }

      return true;
    } else if (o instanceof RubyValue && bConvToAry) {
      RubyValue v = (RubyValue) o;
      if (!v.respondTo(RubyID.toAryID)) {
        return false;
      } else {
        return v.equals(this);
      }
    } else {
      return false;
    }
  }
Exemplo n.º 2
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;
    }
  }