Sha256: 7192f18e717d14b824aadcf8324f6614385795b37a1934a412859df4835c5c5c
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'io/console' # For determining console width/height module Reviewer class Output # Wrapper to encapsulate some lower-level details of printing to $stdout class Printer attr_reader :stream # Creates an instance of Output to print Reviewer activity and results to the console def initialize(stream = $stdout) @stream = stream.tap do |str| # If the IO channel supports flushing the output immediately, then ensure it's enabled str.sync = str.respond_to?(:sync=) end end def print(style, content) text(style, content) end def puts(style, content) text(style, content) stream.puts end def tty? stream.tty? end alias style_enabled? tty? private def text(style, content) if style_enabled? stream.print Token.new(style, content).to_s else stream.print content end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reviewer-0.1.5 | lib/reviewer/output/printer.rb |