class Helium::Console::Formatters::Overflow::Wrap
Public Class Methods
new(max_width:)
click to toggle source
# File lib/helium/console/formatters/overflow/wrap.rb, line 8 def initialize(max_width:) @max_width = max_width end
Public Instance Methods
call(string)
click to toggle source
# File lib/helium/console/formatters/overflow/wrap.rb, line 12 def call(string) 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