$models = [] $types = [] class Connective def initialize(prototype) @prototype = prototype end end class Model def initialize $models << self end end def findModelsByType(type) retModels = [] $models.each do |model| if model.types.member?(type) retModels << model end end return retModels end class Data end class Type end class IntType < Type end class IntModel < Model def initialize super @bindings = Hash.new @types = [IntType] end def types @types end def create(tokens) if tokens[1] == "IntType" name = tokens[2] value = tokens[4].to_i @bindings[name] = value end return true end def processCommand(tokens) if tokens [2] end end class Create < Connective def initialize super("create X") end end class Button < Type def push end def release end end class TextBox < Type def initialize(text) super @operations = ["setText"] @text = text end def setText(inText) @text = inText end end class Widgets < Model def initialize super addType(Button) addType(TextBox) end def types @types end end # takes care of visual information for types class Display < Model def initialize super @typeModels = [Widgets] @predicateModels = [Creation] @predicates = "draw" end end # relates actions for types class Control < Model def initialize @models = Display @typeModels = [Widgets] @predicateModels = [Creation, Causation] end end class Causation < Model end