Sha256: 01b897d5b1d7ca0aee445a467b7ced2a6510ef941fcd1d854270b951c85b1988

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

module Cased
  module CLI
    module Log
      CLEAR   = "\e[0m"
      YELLOW  = "\e[33m"
      BOLD    = "\e[1m"

      def self.string(text)
        [color('[cased]', YELLOW, true), text].join(' ')
      end

      def self.log(text)
        puts string(text)
      ensure
        $stdout.flush
      end

      def self.color(text, color, bold = false) # rubocop:disable Style/OptionalBooleanParameter
        color = self.class.const_get(color.upcase) if color.is_a?(Symbol)
        bold  = bold ? BOLD : ''
        "#{bold}#{color}#{text}#{CLEAR}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cased-ruby-0.7.1 lib/cased/cli/log.rb
cased-ruby-0.7.0 lib/cased/cli/log.rb
cased-ruby-0.6.1 lib/cased/cli/log.rb