Class: CLI::UI::Printer

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/cli/ui/printer.rb

Class Method Summary collapse

Methods included from T::Sig

sig

Class Method Details

.puts(msg, frame_color: nil, to: $stdout, encoding: Encoding::UTF_8, format: true, graceful: true, wrap: true) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cli/ui/printer.rb', line 49

def puts(
  msg,
  frame_color: nil,
  to: $stdout,
  encoding: Encoding::UTF_8,
  format: true,
  graceful: true,
  wrap: true
)
  msg = (+msg).force_encoding(encoding) if encoding
  msg = CLI::UI.fmt(msg) if format
  msg = CLI::UI.wrap(msg) if wrap

  if frame_color
    CLI::UI::Frame.with_frame_color_override(frame_color) { to.puts(msg) }
  else
    to.puts(msg)
  end

  true
rescue Errno::EIO, Errno::EPIPE, IOError => e
  raise(e) unless graceful

  false
end