lib/vedeu/output/compositor.rb in vedeu-0.0.10 vs lib/vedeu/output/compositor.rb in vedeu-0.0.11
- old
+ new
@@ -1,9 +1,11 @@
module Vedeu
+ class UndefinedInterface < StandardError; end
+
class Compositor
class << self
- def arrange(output = [], interface = :dummy)
+ def arrange(output = [], interface = 'dummy')
return if output.nil? || output.empty?
if output.is_a?(Array)
new(output, interface).arrange
elsif output.is_a?(Hash)
@@ -12,23 +14,24 @@
end
end
end
end
- def initialize(output = [], interface = :dummy)
- @output, @interface = output, interface
+ def initialize(output = [], interface = 'dummy')
+ @output = output || []
+ @interface = interface
end
def arrange
Renderer.write(composition)
end
private
def composition
container = []
- streams = []
+ streams = []
output.map do |line|
line.each_with_index do |stream, index|
streams << clear(index)
streams << Directive.enact(stream)
end
@@ -41,11 +44,11 @@
def clear(index)
[origin(index), (' ' * width), origin(index)].join
end
def origin(index)
- Position.set(geometry.vy(index), geometry.vx)
+ target_interface.origin(index)
end
def width
geometry.width
end
@@ -63,9 +66,9 @@
raise UndefinedInterface if interface.nil?
interface
end
def interface
- @_interface ||= Interfaces.defined.find(@interface)
+ @_interface ||= InterfaceRepository.find_by_name(@interface)
end
end
end