Skip to content

Understanding the CodeRunner Framework

edmundhighcock edited this page Apr 1, 2016 · 1 revision

Introduction

This page is for people who want to get under the hood of CodeRunner, either for writing scripts, or for developing code or system modules or for developing CodeRunner itself. If you just want to run CodeRunner from the command line have a look at the [CodeRunner Tutorial](CodeRunner Tutorial "wikilink").

Classes and Objects

This article assumes that the reader is familiar with the basics of object oriented programming and with the Ruby scripting language.

Everything in Ruby is an object, instantiated from a class. For example, 0.02 is an object of the class Float. Classes can inherit from each other, and all classes eventually descend from the parent class Object.

At its heart, CodeRunner consists of two very different classes, the CodeRunner class and the Run class. An object of the CodeRunner class is known as a runner, and an object of the Run class is known as a run. Thus far, thus easy.

The CodeRunner Class

The CodeRunner class Is a rather simple, standard class. An object of this class is known as a runner. The purpose of the runner is to manage a set of runs, or simulations within a given folder. It indexes them, keeps track of them, can submit new stimulations within that folder and delete old ones. All of these tasks are carried out via instance methods of the runner.

As well as the instance methods of the runner, there are also class methods of the CodeRunner class itself. These class methods are used to implement this standard tasks, which usually consist of instantiating a runner, and then calling one or more instance methods of the runner. It is these class methods which implement the command line interface commands. If you are not familiar with the distinction between instance methods and class methods it is recommended that you consult some of the extensive online documentation available for Ruby.

In