Sha256: af47c2c78fcd38fe14dba95241f078f1636bf1b4ecd6f72b1f4d3992ed3d151a

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

module Bloodbath
  module Utils
    class Verbose
      class << self
        COLORS = {
          red: 31,
          green: 32,
          blue: 34,
        }.freeze

        def capture(label)
          result = yield
          return puts """
          #{screen("[VERBOSE]")} #{screen("#{label}:", color: :blue)} #{screen(result, color: :red)}
          """ if verbose?
        end

        private

        def verbose?
          Bloodbath.config.verbose
        end

        def screen(message, color: :green)
          "\e[#{COLORS[color]}m#{message}\e[0m"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bloodbath-1.1.1 lib/bloodbath/utils/verbose.rb