rubyx/lib/parfait/variable.rb

20 lines
506 B
Ruby
Raw Normal View History

module Parfait
class Variable < Object
2015-09-27 15:06:11 +02:00
def initialize type , name , value = nil
raise "not type #{type}" unless Virtual.machine.space.get_class_by_name(type)
2015-09-27 15:06:11 +02:00
self.type , self.name , self.value = type , name , value
self.value = 0 if self.type == :int and value == nil
raise "must give name for variable" unless name
end
attributes [:type , :name, :value]
2015-09-27 15:06:11 +02:00
def to_s
"Variable(#{self.type} ,#{self.name})"
end
def inspect
to_s
end
end
end