Sha256: 5f33606f939efc777a80f2fb0b199ca78aa833bcfd6c70db5d5b832175ed336d

Contents?: true

Size: 960 Bytes

Versions: 4

Compression:

Stored size: 960 Bytes

Contents

module HoneyFormat
  # CLI result writer handles command output
  # @attr_reader [true, false] verbose the writer mode
  class CLIResultWriter
    attr_accessor :verbose

    # Instantiate the result writer
    # @param verbose [true, false] mode (default: false)
    # @return [CLIResultWriter] the result writer
    def initialize(verbose: false)
      @verbose = verbose
    end

    # Return if verbose mode is true/false
    # @return [true, false]
    def verbose?
      @verbose
    end

    # Print the string
    # @param [String] string to print
    # @param verbose [true, false] mode (default: false)
    def print(string, verbose: false)
      return if !verbose? && verbose

      Kernel.print(string)
    end

    # Puts the string
    # @param [String] string to puts
    # @param verbose [true, false] mode (default: false)
    def puts(string, verbose: false)
      return if !verbose? && verbose

      Kernel.puts(string)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
honey_format-0.16.0 lib/honey_format/cli/result_writer.rb
honey_format-0.15.0 lib/honey_format/cli/result_writer.rb
honey_format-0.14.0 lib/honey_format/cli/result_writer.rb
honey_format-0.13.0 lib/honey_format/cli/result_writer.rb