Sha256: 4ee827cbefe48ae3751bedb0cabeb2a9b907aee6b4de4e6ad5bd4c4e6d68740e

Contents?: true

Size: 991 Bytes

Versions: 12

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

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

12 entries across 12 versions & 1 rubygems

Version Path
honey_format-0.27.0 lib/honey_format/cli/result_writer.rb
honey_format-0.26.0 lib/honey_format/cli/result_writer.rb
honey_format-0.25.0 lib/honey_format/cli/result_writer.rb
honey_format-0.24.0 lib/honey_format/cli/result_writer.rb
honey_format-0.23.0 lib/honey_format/cli/result_writer.rb
honey_format-0.22.0 lib/honey_format/cli/result_writer.rb
honey_format-0.21.1 lib/honey_format/cli/result_writer.rb
honey_format-0.21.0 lib/honey_format/cli/result_writer.rb
honey_format-0.20.0 lib/honey_format/cli/result_writer.rb
honey_format-0.19.0 lib/honey_format/cli/result_writer.rb
honey_format-0.18.0 lib/honey_format/cli/result_writer.rb
honey_format-0.17.0 lib/honey_format/cli/result_writer.rb