Skip to content

Getting Started With IRB

muh182 edited this page Oct 2, 2014 · 9 revisions

This page provides information on how to get started with using irb in the OpenStudio API.

Getting Started with IRB

Since there is no plugin for the existing text editors for OpenStudio, in addition to the OpenStudio's repository on the NREL's github and doxygen documentation, irb is one of the best way to test different methods. Here, is an example of using irb in the command line to create the OpenStudio model and get the RunPeriod object:

irb
require 'openstudio'
model=OpenStudio::Model::Model.new
model.getRunPeriod

The other example is using irb to find the exiting fields in the OS:Building object: Image of IRB

The results show that getBuilding has different fields such as Name and, Building Sector Type. For example, to get the name of the building, building.setName("This is a test to set the building name").

Using IRB Completion to Facilitate Using the API

One of the best way to identify existing methods in the API is to benefit from the irb/completion in the command line. When user type require 'irb/completion' in the command line, user can use tab key to auto complete the command or provide suggestions. Here is an example of benefiting from the irb/completion:

Image of IRB Completion

The results show that there are three methods starting with setN for the building object.

Call a Specific Version of the IRB

If you have a specific OpenStudio building that need to call, you need to use irb -I build-make/OpenStudioCode-prefix/src/OpenStudioCore-build/ruby to call this specific version.

Clone this wiki locally