Sha256: d4623858a245bd60db02a0d575169d071989ff99eadb72b1508c8a711c13aca4

Contents?: true

Size: 646 Bytes

Versions: 39

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

module Doing
  # STDOUT and STDERR methods
  module PromptSTD
    ##
    ## Clear the terminal screen
    ##
    def clear_screen(msg = nil)
      puts "\e[H\e[2J" if $stdout.tty?
      puts msg if msg.good?
    end

    ##
    ## Redirect STDOUT and STDERR to /dev/null or file
    ##
    ## @param      file  [String] a file path to redirect to
    ##
    def silence_std(file = '/dev/null')
      $stdout = File.new(file, 'w')
      $stderr = File.new(file, 'w')
    end

    ##
    ## Restore silenced STDOUT and STDERR
    ##
    def restore_std
      $stdout = STDOUT
      $stderr = STDERR
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
doing-2.1.86 lib/doing/prompt/std.rb
doing-2.1.85 lib/doing/prompt/std.rb
doing-2.1.84 lib/doing/prompt/std.rb
doing-2.1.83 lib/doing/prompt/std.rb
doing-2.1.82 lib/doing/prompt/std.rb
doing-2.1.81 lib/doing/prompt/std.rb
doing-2.1.80 lib/doing/prompt/std.rb
doing-2.1.79 lib/doing/prompt/std.rb
doing-2.1.78 lib/doing/prompt/std.rb
doing-2.1.77 lib/doing/prompt/std.rb
doing-2.1.76 lib/doing/prompt/std.rb
doing-2.1.75 lib/doing/prompt/std.rb
doing-2.1.74 lib/doing/prompt/std.rb
doing-2.1.73 lib/doing/prompt/std.rb
doing-2.1.72 lib/doing/prompt/std.rb
doing-2.1.69 lib/doing/prompt/std.rb
doing-2.1.68 lib/doing/prompt/std.rb
doing-2.1.66 lib/doing/prompt/std.rb
doing-2.1.65 lib/doing/prompt/std.rb
doing-2.1.64 lib/doing/prompt/std.rb