lib/vedeu/interface/interfaces.rb in vedeu-0.0.8 vs lib/vedeu/interface/interfaces.rb in vedeu-0.0.9

- old
+ new

@@ -12,40 +12,44 @@ self end end def defined - interfaces.empty? ? nil : self + interfaces.empty? ? default : self end - def default - add(:dummy, Dummy) - end - def list interfaces.inspect end - def add(name, klass, options = {}) - if valid?(klass) - interfaces[name] = Proc.new { klass.new(options) } - self - end + def add(name, options = {}, klass = Dummy) + interfaces[name] = klass.new(options) if valid?(klass) + self end def initial_state - interfaces.values.map { |io| io.call.initial_state } + interfaces.values.map { |io| io.initial_state } end - def event_loop - interfaces.values.map { |io| io.call.event_loop } + def input + interfaces.values.map { |io| io.input } end + def output(stream) + interfaces.values.map { |io| io.output(stream) } + end + private def valid?(klass) raise UndefinedInterface unless Object.const_defined?(klass.to_s) true + end + + def default + add(:dummy) + + self end def interfaces @interfaces ||= {} end