rubyx/lib/slot_language/slot_maker.rb

29 lines
462 B
Ruby
Raw Normal View History

2019-10-04 16:38:51 +02:00
module SlotLanguage
class SlotMaker
2019-10-07 19:14:40 +02:00
attr_reader :leaps
2019-10-07 19:14:40 +02:00
def initialize(leaps)
case leaps
when Array
@leaps = leaps
when nil
raise "No leaps given"
else
2019-10-07 19:14:40 +02:00
@leaps = [leaps]
end
end
def add_slot_name(name)
2019-10-07 19:14:40 +02:00
@leaps << name
end
def slot_def(compiler)
SlotMachine::SlotDefinition.new(:message , leaps)
2019-10-04 16:38:51 +02:00
end
2020-02-09 15:33:34 +01:00
def to_s
"message." + leaps.join(",")
end
2019-10-04 16:38:51 +02:00
end
end