Sha256: d8aae67262583afa9b4159ba726a296d97ed6b267d7b739863e65e2676f20f78
Contents?: true
Size: 778 Bytes
Versions: 173
Compression:
Stored size: 778 Bytes
Contents
module Softcover::Output class << self attr_accessor :silent, :stream, :verbosity_level def stream silent? ? StringIO.new : (defined?(@stream) && @stream) || $stdout end def silence! @silent = true end def unsilence! @silent = false end def silent? defined?(@silent) && @silent end def should_output?(level) !silent? || !(level && defined?(@verbosity_level) && level < @verbosity_level) end end %w{puts printf print}.each do |method| define_method method do |string, options={}| if Softcover::Output.should_output?(options[:level]) Softcover::Output.stream.send method, string end end end def system(cmd) output = `#{cmd}` puts output end end
Version data entries
173 entries across 173 versions & 2 rubygems