Sha256: b801244ced47a2c350bbc63adaa800bf7175d3c891a1aa333a99565d949ff8e7
Contents?: true
Size: 1.03 KB
Versions: 22
Compression:
Stored size: 1.03 KB
Contents
module Coltrane module Renderers module TextRenderer class ArrayDrawer < BaseDrawer alias array model def render public_send("render_#{layout}") end def renders @renders ||= array.map {|it| TextRenderer.render(it, **options) } end def render_vertical renders.join("\n") end def render_horizontal array .each_slice(per_row) .map { |row| row .map { |element| TextRenderer.render(element, **options) .split("\n") .yield_self { |lines| lines .map { |l| l.gsub(/\e\[(\d+)(;\d+)*m/, '').size } .max .yield_self { |column_w| lines .map { |l| l.ljust(column_w) } .+([' ' * column_w]) } } } .transpose .map(&:join) }.join("\n") end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems