Sha256: d4eb9342f968375d395fcd40922e6d05d168bca16d4d1f8cbcb1f4df93cf631b
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Helium class Console define_formatter_for String do def render_compact render_string(object, max_width: 15, max_lines: 1) end def render_inline render_string(object.gsub("\n", '\n'), max_lines: 1) end def render_partial render_string(object, max_lines: max_lines || 3) end def render_full render_string(object) end def simple? object.lines.count == 1 && length_of(object) < 15 end def render_string(string, max_lines: self.max_lines, max_width: self.max_width) formatted = format_string( "\"#{string.gsub('"', '\"')}\"", max_width: max_width, max_lines: max_lines, overflow: overflow, ellipses: '..."', indent: indent ) result = formatted.lines .map { |line| light_green(line.chomp) } .join("\n") result = "#{result}\n" if formatted.end_with?("\n") result end def max_lines @options[:max_lines] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
helium-console-0.1.13 | lib/helium/console/registry/string.rb |
helium-console-0.1.12 | lib/helium/console/registry/string.rb |