manage to create ruby methods

This commit is contained in:
Torsten Ruger
2017-01-12 20:38:04 +02:00
parent 89f5badc16
commit 3f6c1bc3a3
12 changed files with 76 additions and 24 deletions

View File

@ -23,6 +23,7 @@ module Parfait
super()
@name = name
@super_class_name = superclass
@methods = {}
set_instance_type( instance_type )
end
@ -34,6 +35,14 @@ module Parfait
"Class(#{name})"
end
def add_method(method)
@methods[method.name] = method
end
def get_method(name)
@methods[name]
end
# setting the type generates all methods for this type
# (or will do, once we store the methods code to do that)
def set_instance_type( type )

View File

@ -29,7 +29,7 @@ module Parfait
# While data ususally would live in a .data section, we may also "inline" it into the code
# in an oo system all data is represented as objects
class Space < Object
class Space < Object
def initialize(classes )
@classes = classes
@ -99,10 +99,10 @@ module Parfait
# get or create the class by the (symbol) name
# notice that this method of creating classes implies Object superclass
def get_class_by_name! name
def get_class_by_name!(name , super_class = :Object)
c = get_class_by_name(name)
return c if c
create_class name
create_class( name ,super_class)
end
# this is the way to instantiate classes (not Parfait::Class.new)