Sha256: 93d0819d771e27b31b53cb1bddb7af28363288cc955020b950f8b990a8af2b3d
Contents?: true
Size: 583 Bytes
Versions: 1
Compression:
Stored size: 583 Bytes
Contents
# frozen_string_literal: true module Helium class Console module Formatters module Overflow class Wrap def initialize(max_width:) @max_width = max_width end def call(string) return string unless @max_width result = string.lines.flat_map do |line| line.chomp.chars.each_slice(@max_width).map(&:join) end result = result.join("\n") result += "\n" if string.end_with?("\n") result end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
helium-console-0.1.13 | lib/helium/console/formatters/overflow/wrap.rb |