Package org.jruby

Examples of org.jruby.RubyArray$RubyArrayConversionIterator


            case RubiniusInstructions.ADD_METHOD: {
                int val = getInt(bytecodes, ip);
                ip += 4;
                String name = literals[val].toString();
                RubyModule clzz = (RubyModule)stack[stackTop--];
                RubyArray method = (RubyArray)stack[stackTop--];
               
                Visibility visibility = context.getCurrentVisibility();
                if (name == "initialize" || visibility == Visibility.MODULE_FUNCTION) {
                    visibility = Visibility.PRIVATE;
                }
View Full Code Here


        }
        return vals;
    }

    private final RubiniusCMethod unmarshalCMethod(InputStream in) throws IOException {
        RubyArray obj = (RubyArray)unmarshal(in);
        if(obj == null) {
            return null;
        }
        return new RubiniusCMethod(obj);
    }
View Full Code Here

        return EMPTY_LIST;
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        RubyArray args = (RubyArray) firstNode.interpret(runtime, context, self, aBlock).dup();
       
        return args.append(secondNode.interpret(runtime, context, self, aBlock));       
    }
View Full Code Here

        IRubyObject receiver = getReceiverNode().interpret(runtime, context, self, aBlock);
        IRubyObject arg = getArgsNode().interpret(runtime, context, self, aBlock);
        Block block = getBlock(context, self);

        if (arg instanceof RubyArray) {
            RubyArray nodes = (RubyArray) arg;

            switch (nodes.size()) {
                case 0:
                    return callAdapter.call(context, self, receiver, block);
                case 1:
                    return callAdapter.call(context, self, receiver, nodes.eltInternal(0), block);
                case 2:
                    return callAdapter.call(context, self, receiver, nodes.eltInternal(0), nodes.eltInternal(1), block);
                case 3:
                    return callAdapter.call(context, self, receiver, nodes.eltInternal(0), nodes.eltInternal(1), nodes.eltInternal(2), block);
                default:
                    return callAdapter.call(context, self, receiver, nodes.toJavaArrayMaybeUnsafe(), block);
            }
        }

        return callAdapter.call(context, self, receiver, arg, block);
    }
View Full Code Here

    }

    // Ruby grammar has nested whens in a case body because of productions case_body and when_args.
    @Override
    public IRubyObject when(WhenNode whenNode, IRubyObject value, ThreadContext context, Ruby runtime, IRubyObject self, Block aBlock) {
        RubyArray expressions = RuntimeHelpers.splatValue(expressionNodes.interpret(runtime, context, self, aBlock));

        for (int j = 0,k = expressions.getLength(); j < k; j++) {
            IRubyObject test = expressions.eltInternal(j);

            if ((value != null && eqq.call(context, self, test, value).isTrue())
                    || (value == null && test.isTrue())) {
                return whenNode.interpret(runtime, context, self, aBlock);
            }
View Full Code Here

            throw runtime.newIOErrorFromException(e);
        }
    }

    private static void addEntries(ThreadContext context, ZipOutputStream zip, RubyHash entries) throws IOException {
        RubyArray keys = entries.keys().sort(context, Block.NULL_BLOCK);
        for (int i = 0; i < keys.getLength(); i++) {
            IRubyObject key = keys.entry(i);
            IRubyObject value = entries.op_aref(context, key);
            addEntry(context, zip, key.convertToString().getUnicodeValue(), value);
        }
    }
View Full Code Here

          String marshalled = getMarshal().callMethod(data.runtime.getCurrentContext(), "dump", rubyVal).toString();
          javaValue = new RubyStepMarshalledObject(marshalled);
          break;
        case ValueMeta.TYPE_BINARY:
          // TODO: provide meaningful error message if this fails
          RubyArray arr = rubyVal.convertToArray();

          byte[] bytes = new byte[arr.size()];
          for (int i = 0; i < bytes.length; i++) {
            Object rItem = arr.get(i);
            if (rItem instanceof Number) {
              bytes[i] = ((Number) rItem).byteValue();
            } else {
              throw new KettleException("Found a non-number in Binary field " + outField.getName() + ": " + rItem.toString());
            }
View Full Code Here

      return;
    }

    // arrays are handled recursively:
    if (rubyObject instanceof RubyArray) {
      RubyArray rubyArray = (RubyArray) rubyObject;
      int length = rubyArray.getLength();
      for (int i = 0; i < length; i++) {
        fetchRowsFromScriptOutput(rubyArray.entry(i), inRow, r, rowList, forFields, forRow);
      }
      return;
    }

    // at this point the returned object is not nil, not a hash and not an array, let's ignore the output but warn in the log
View Full Code Here

      StepStreamReader reader = new StepStreamReader(this, stream.getStepname());

      // if there's direct input connected as well as info streams present, the info streams *must* be prefetched as per 4.0 API
      if (data.hasDirectInput) {
        RubyArray allRows = reader.readAll();
        BufferStreamReader bReader = new BufferStreamReader(this, allRows);
        infoSteps.put(meta.getInfoSteps().get(i).getRoleName(), bReader);
      } else {
        infoSteps.put(meta.getInfoSteps().get(i).getRoleName(), reader);
      }
View Full Code Here

  public IRubyObject read(long upTo) throws KettleException{
   
    // request to read <0 rows
    if (upTo < 0) return data.runtime.getNil();
   
    RubyArray arr = data.runtime.newArray();
    int read = 0;
    while(read < upTo){
      IRubyObject o = read();
      if (o.isNil()) break;
      arr.append(o);
      read++;
    }
   
    // request to read from empty stream
    if (arr.size() == 0 && upTo > 0) return data.runtime.getNil();
   
    return arr;
 
  }
View Full Code Here

TOP

Related Classes of org.jruby.RubyArray$RubyArrayConversionIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.