moving know_object out of the base class

object is only common to constant and object slots (which should be unified)
On the way to making the array recursive
This commit is contained in:
2020-02-15 15:26:49 +07:00
parent 6aa6b32c50
commit 8b29326957
6 changed files with 32 additions and 35 deletions

View File

@ -29,17 +29,16 @@ module SlotMachine
end
end
attr_reader :known_object , :slots
attr_reader :slots
# is an array of symbols, that specifies the first the object, and then the Slot.
# The first element is either a known type name (Capitalized symbol of the class name) ,
# or the symbol :message
# And subsequent symbols must be instance variables on the previous type.
# Examples: [:message , :receiver] or [:Space , :next_message]
def initialize( object , slots)
def initialize( slots)
raise "No slots #{object}" unless slots
slots = [slots] unless slots.is_a?(Array)
@known_object , @slots = object , slots
raise "Not known #{slots}" unless object
@slots = slots
end
def to_s