Exemplo n.º 1
0
 // @RubyLevelMethod(name="push")
 public RubyArray multiPush(RubyArray args) {
   //    	for (RubyValue v : args) {
   for (Iterator iter = args.iterator(); iter.hasNext(); ) {
     RubyValue v = (RubyValue) iter.next();
     this.array_.add(v);
   }
   return this;
 }
Exemplo n.º 2
0
 private RubyArray minus(RubyArray other) {
   RubyArray a = this.copy();
   //        for (RubyValue v : other) {
   for (Iterator iter = other.iterator(); iter.hasNext(); ) {
     RubyValue v = (RubyValue) iter.next();
     a.remove(v);
   }
   return a;
 }
Exemplo n.º 3
0
  // @RubyLevelMethod(name="count")
  public RubyValue count(RubyArray args) {
    if (null == args) {
      throw new RubyException(RubyRuntime.ArgumentErrorClass, "wrong number of arguments");
    }

    // TODO incomplete
    int n = 0;
    //        for (RubyValue v : args) {
    for (Iterator iter = args.iterator(); iter.hasNext(); ) {
      RubyValue v = (RubyValue) iter.next();
      RubyString other_str = (RubyString) v;
      n += count(other_str.toString());
    }
    return ObjectFactory.createFixnum(n);
  }
Exemplo n.º 4
0
 // @RubyLevelMethod(name="|")
 public RubyArray or(RubyValue value) {
   RubyArray other = value.toAry();
   RubyArray a = new RubyArray();
   //        for (RubyValue v : array_) {
   for (Iterator iter = array_.iterator(); iter.hasNext(); ) {
     RubyValue v = (RubyValue) iter.next();
     if (a.include(v) == RubyConstant.QFALSE) {
       a.add(v);
     }
   }
   //        for (RubyValue v : other) {
   for (Iterator iter = other.iterator(); iter.hasNext(); ) {
     RubyValue v = (RubyValue) iter.next();
     if (a.include(v) == RubyConstant.QFALSE) {
       a.add(v);
     }
   }
   return a;
 }