Package org.jruby

Examples of org.jruby.Ruby.newArray()


        if (args.length > 0 && !args[args.length - 1].isNil() && args[args.length - 1].checkStringType19().isNil() &&
                RubyNumeric.num2long(args[args.length - 1]) == 0) {
            throw runtime.newArgumentError("invalid limit: 0 for each_line");
        }

        RubyArray ary = runtime.newArray();
        IRubyObject line;

        checkReadable();

        while (!(line = getline(context, args)).isNil()) {
View Full Code Here


                            IRubyObject indexDefinition = indexDefinitionClass.callMethod(context, "new",
                                    new IRubyObject[] {
                                RubyString.newUnicodeString(runtime, tableName),
                                RubyString.newUnicodeString(runtime, indexName),
                                runtime.newBoolean(!nonUnique),
                                runtime.newArray()
                            });

                            // empty list for column names, we'll add to that in just a bit
                            indexes.add(indexDefinition);
                        }
View Full Code Here

                        if (lastIndex != null) {
                            lastIndex.callMethod(context, "columns").callMethod(context, "<<", columnName);
                        }
                    }

                    return runtime.newArray(indexes);
                } finally {
                    close(resultSet);
                }
            }
        });
View Full Code Here

                }
                if (pkeyNames.contains(colName)) {
                    column.callMethod(context, "primary=", runtime.getTrue());
                }
            }
            return runtime.newArray(columns);
        } finally {
            close(rs);
        }
    }
View Full Code Here

            populateFromResultSet(context, runtime, results, resultSet, columns);
        } finally {
            close(resultSet);
        }

        return runtime.newArray(results);
    }

    protected Object withConnectionAndRetry(ThreadContext context, SQLBlock block) {
        int tries = 1;
        int i = 0;
View Full Code Here

            if(ready <= 0)
                return context.nil;

            RubyArray array = null;
            if(!block.isGiven()) {
                array = runtime.newArray(this.selector.selectedKeys().size());
            }

            Iterator selectedKeys = this.selector.selectedKeys().iterator();
            while(selectedKeys.hasNext()) {
                SelectionKey key = (SelectionKey)selectedKeys.next();
View Full Code Here

    public static IRubyObject modules(final ThreadContext context, final IRubyObject self) {
        final Ruby runtime = context.getRuntime();
        final RubyModule arJdbc = (RubyModule) self;

        final Collection<String> constants = arJdbc.getConstantNames();
        final RubyArray modules = runtime.newArray( constants.size() );

        for ( final String name : constants ) {
           IRubyObject value = arJdbc.getConstant(name, false);
           // isModule: return false for Ruby Classes
           if ( value != null && value.isModule() ) {
View Full Code Here

                    query.append(jdbcSchemaName).append(".");
                }
                query.append(jdbcTableName);
                query.append(" WHERE key_name != 'PRIMARY'");

                final RubyArray indexes = runtime.newArray(8);
                PreparedStatement statement = null;
                ResultSet keySet = null;

                try {
                    statement = connection.prepareStatement(query.toString());
View Full Code Here

                            IRubyObject[] args = new IRubyObject[] {
                                rubyTableName, // table_name
                                RubyString.newUnicodeString(runtime, keyName), // index_name
                                runtime.newBoolean( ! nonUnique ), // unique
                                runtime.newArray(), // [] for column names, we'll add to that in just a bit
                                runtime.newArray() // lengths
                            };

                            indexes.append( indexDefinition.callMethod(context, "new", args) ); // IndexDefinition.new
                        }
View Full Code Here

                            IRubyObject[] args = new IRubyObject[] {
                                rubyTableName, // table_name
                                RubyString.newUnicodeString(runtime, keyName), // index_name
                                runtime.newBoolean( ! nonUnique ), // unique
                                runtime.newArray(), // [] for column names, we'll add to that in just a bit
                                runtime.newArray() // lengths
                            };

                            indexes.append( indexDefinition.callMethod(context, "new", args) ); // IndexDefinition.new
                        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.