Sha256: 606e1d25773b174aa5c4291dfd310c83506da77a5b04bef7062d306805fb358e

Contents?: true

Size: 562 Bytes

Versions: 9

Compression:

Stored size: 562 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)
        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

9 entries across 9 versions & 1 rubygems

Version Path
cased-ruby-0.5.2 lib/cased/cli/log.rb
cased-ruby-0.5.1 lib/cased/cli/log.rb
cased-ruby-0.5.0 lib/cased/cli/log.rb
cased-ruby-0.4.8 lib/cased/cli/log.rb
cased-ruby-0.4.7 lib/cased/cli/log.rb
cased-ruby-0.4.6 lib/cased/cli/log.rb
cased-ruby-0.4.5 lib/cased/cli/log.rb
cased-ruby-0.4.4 lib/cased/cli/log.rb
cased-ruby-0.4.3 lib/cased/cli/log.rb