Ice for Ruby

The popularity of the Ruby programming language is growing rapidly, thanks in large part to its clean, expressive syntax, robust class libraries, and time-saving frameworks such as Ruby on Rails. Ruby and Ice share many of the same design goals, including an emphasis on simplicity, ease of use, and reliability. Together, Ice and Ruby are a powerful combination that enables Ruby applications to participate in distributed object computing using ZeroC's proven technology.

Client Support

Ice for Ruby offers an intuitive language mapping and a full-featured run time for quickly building client applications in Ruby. Ice for Ruby does not provide server-side capabilities at this time. If you have a need for this feature and would like to sponsor its development, please contact us.

Sample Code

To illustrate how Ice is used with Ruby, consider the following Slice interface definitions:

module Biz {
    struct Item {
        string sku;
        int qty;
    };
    sequence<Item> ItemSeq;
     
    interface Invoice {
        void addItems(ItemSeq items);
        void submit();
    };
    interface InvoiceFactory {
        Invoice* create();
    };
};

Ruby code that creates an invoice using the factory is shown below:

# Create a proxy for the invoice factory object.
proxy = communicator.stringToProxy("InvoiceFactory:tcp -p 9000")

# Narrow the proxy to the proper type.
factory = Biz::InvoiceFactoryPrx::checkedCast(proxy)

# Use the factory to obtain a proxy for a new invoice object.
invoice = factory.create()

# Add items to the invoice.
item = Biz::Item.new()
item.sku = "10-6139"
item.qty = 3
items = [item]
invoice.addItems(items)

# Submit the invoice.
invoice.submit()
Terms of Use | Privacy © 2011 ZeroC, Inc.