Sha256: 4783fdb1bb9d76dc04411c979d51fb646577a0289dda21e29c82832054c5a703
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
module Vedeu class UndefinedInterface < StandardError; end class Compositor class << self 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) output.map { |i, o| new(o, i).arrange } end end end def initialize(output = [], interface = 'dummy') @output = output || [] @interface = interface end def arrange interface.enqueue(composition) end private def composition container = [] streams = [] container << colour.set output.map do |lines| if lines.size < height remaining = height - lines.size remaining.times { |i| lines << '' } end lines.each_with_index do |stream, index| streams << clear(index) streams << Directive.enact(interface, stream) end container << streams.join streams = [] end container << colour.reset container << cursor container end def clear(index) [origin(index), (' ' * width), origin(index)].join end def origin(index) geometry.origin(index) end def height geometry.height end def width geometry.width end def geometry interface.geometry end def colour interface.colour end def cursor interface.cursor end def output return @output.split if @output.is_a?(String) @output end def interface @_interface ||= InterfaceRepository.find_by_name(@interface) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.0.19 | lib/vedeu/output/compositor.rb |