Sha256: 63ede10291b19153edc387524e5a3ab76f3f2d6e21bf765f985cfe4ccd50ef1b
Contents?: true
Size: 603 Bytes
Versions: 7
Compression:
Stored size: 603 Bytes
Contents
module Helium class Console module Formatters class MaxLines ELLIPSES = "...\"" def initialize(max_lines:, max_width:, ellipses:) @max_lines = max_lines @max_width = max_width @ellipses = ellipses end def call(string) return string if !@max_lines || string.lines.count <= @max_lines lines = string.lines.first(@max_lines) last_line = lines.pop lines << last_line.chars.first(@max_width - @ellipses.length).join + @ellipses lines.join() end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems