Sha256: f06ef73086b902f13cba2abe7d76ccf203e50777733886ff2bd59d1574cb0954
Contents?: true
Size: 713 Bytes
Versions: 2
Compression:
Stored size: 713 Bytes
Contents
# frozen_string_literal: true module Pcli module Output class Padded def self.show(input, output, screen) amount = 5 messages = input messages = [messages] unless messages.respond_to?(:each) messages = messages.flat_map { |m| m == '' ? '' : m.split("\n") } length = screen.width - amount result = '' messages.each do |message| message.each_char.with_index do |c, i| if (i % length).zero? result += "\n" if i.positive? result += ' ' * amount end result += c end result += "\n" end output.print(result) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pcli-0.1.1 | lib/pcli/output/padded.rb |
pcli-0.1.0 | lib/pcli/output/padded.rb |