class Modelling::Rule

Rule class

Attributes

equation[RW]

the equation of the rule (equation object)

output[RW]

output (Species or Parameter)

type[RW]

type: ‘scalar’ or ‘rate’

Public Class Methods

new(out, eqn, type = 'scalar') click to toggle source
# File lib/modelling/rule.rb, line 13
def initialize(out, eqn, type = 'scalar')
    raise "Rules must assign to species or parameters" unless (out.kind_of? Species) || (out.kind_of? Parameter)
    raise "Rules must involve an equation" unless (eqn.kind_of? Equation)
    @output = out
    @equation = eqn
    @type = type || 'scalar' 
    raise 'Rate rules are only valid for species' if !(out.kind_of? Species) && @type == 'rate'
    raise 'Rule type must be "rate" or "scalar"' if @type != 'rate' && @type != 'scalar'
end

Public Instance Methods

to_s() click to toggle source
# File lib/modelling/rule.rb, line 23
def to_s
    if @type == 'rate'
        "d#{@output.name}/dt = #{@equation.to_s}"   
    else
        "#{@output.name} = #{@equation.to_s}"   
    end
end