Rule class
the equation of the rule (equation object)
output (Species or Parameter)
type: ‘scalar’ or ‘rate’
# 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
# 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