Sha256: e1d8f3a1a3962048bdd637628dd91b944f2e598ce8faa3fff2daee26c7d60408

Contents?: true

Size: 925 Bytes

Versions: 14

Compression:

Stored size: 925 Bytes

Contents

# frozen_stirng_literal: true

module GFSM
  module Output
    def self.included(klass)
      klass.extend(Methods)
    end

    module Methods
      def stdout_handle
        $stdout.tap { |handle| handle.sync = true }
      end

      def stderr_handle
        $stderr.tap { |handle| handle.sync = true }
      end

      def print(message = nil, stderr: false)
        stderr ? stderr_handle.print(message) : stdout_handle.print(message)
      end

      def puts(message = nil, stderr: false)
        stderr ? stderr_handle.puts(message) : stdout_handle.puts(message)
      end

      def info(message)
        puts(message)
      end

      def warn(message)
        puts("WARNING: #{message}", stderr: true)
      end

      def error(message)
        puts("ERROR: #{message}", stderr: true)
      end

      def success(message)
        puts(message)
      end
    end

    extend Methods
    include Methods
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gfsm-0.8.0 lib/tools/output.rb
gfsm-0.7.0 lib/tools/output.rb
gfsm-0.6.0 lib/tools/output.rb
gfsm-0.5.1 lib/tools/output.rb
gfsm-0.5.0 lib/tools/output.rb
gfsm-0.4.1 lib/tools/output.rb
gfsm-0.4.0 lib/tools/output.rb
gfsm-0.3.2 lib/tools/output.rb
gfsm-0.3.1 lib/tools/output.rb
gfsm-0.3.0 lib/tools/output.rb
gfsm-0.2.0 lib/tools/output.rb
gfsm-0.1.4 lib/tools/output.rb
gfsm-0.1.3 lib/tools/output.rb
gfsm-0.1.2 lib/tools/output.rb