Sha256: 07e550d61d2fbbbb4f5590f8319d12f02d1e05cfcec16bf172cb7523855bc72c

Contents?: true

Size: 501 Bytes

Versions: 7

Compression:

Stored size: 501 Bytes

Contents

module Helium
  class Console
    module Formatters
      module Overflow
        class Wrap
          def initialize(max_width:)
            @max_width = max_width
          end

          def call(string)
            result = string.lines.flat_map do |line|
              line.chomp.chars.each_slice(@max_width).map(&:join)
            end
            result = result.join($/)
            result += $/ if string.end_with?($/)
            result
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
helium-console-0.1.7 lib/helium/console/formatters/overflow/wrap.rb
helium-console-0.1.6 lib/helium/console/formatters/overflow/wrap.rb
helium-console-0.1.5 lib/helium/console/formatters/overflow/wrap.rb
helium-console-0.1.4 lib/helium/console/formatters/overflow/wrap.rb
helium-console-0.1.3 lib/helium/console/formatters/overflow/wrap.rb
helium-console-0.1.2 lib/helium/console/formatters/overflow/wrap.rb
helium-console-0.1.1 lib/helium/console/formatters/overflow/wrap.rb