Sha256: 99b3693447d1728e835e1d6898b832c404d411f5940dd6d43a0b59e619cd0240

Contents?: true

Size: 1.77 KB

Versions: 19

Compression:

Stored size: 1.77 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
#
# Show colorized output.
#
require 'colorized_string'

module Gloo
  module Objs
    class Colorize < GlooLang::Core::Obj

      KEYWORD = 'colorize'.freeze
      KEYWORD_SHORT = 'color'.freeze

      #
      # The name of the object type.
      #
      def self.typename
        return KEYWORD
      end

      #
      # The short name of the object type.
      #
      def self.short_typename
        return KEYWORD_SHORT
      end

      # ---------------------------------------------------------------------
      #    Children
      # ---------------------------------------------------------------------

      # Does this object have children to add when an object
      # is created in interactive mode?
      # This does not apply during obj load, etc.
      def add_children_on_create?
        return true
      end

      # Add children to this object.
      # This is used by containers to add children needed
      # for default configurations.
      def add_default_children
        fac = @engine.factory
        fac.create_string 'white', '', self
      end

      # ---------------------------------------------------------------------
      #    Messages
      # ---------------------------------------------------------------------

      #
      # Get a list of message names that this object receives.
      #
      def self.messages
        return super + [ 'run' ]
      end

      #
      # Run the colorize command.
      #
      def msg_run
        msg = ''
        children.each do |o|
          msg += ColorizedString[ o.value_display ].colorize( o.name.to_sym )
        end
        $log.show msg
        @engine.heap.it.set_to msg.to_s
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gloo-1.4.2 lib/gloo/objs/cli/colorize.rb
gloo-1.4.1 lib/gloo/objs/cli/colorize.rb
gloo-1.4.0 lib/gloo/objs/cli/colorize.rb
gloo-1.3.3 lib/gloo/objs/cli/colorize.rb
gloo-1.3.2 lib/gloo/objs/cli/colorize.rb
gloo-1.3.1 lib/gloo/objs/cli/colorize.rb
gloo-1.3.0 lib/gloo/objs/cli/colorize.rb
gloo-1.2.10 lib/gloo/objs/cli/colorize.rb
gloo-1.2.9 lib/gloo/objs/cli/colorize.rb
gloo-1.2.8 lib/gloo/objs/cli/colorize.rb
gloo-1.2.7 lib/gloo/objs/cli/colorize.rb
gloo-1.2.6 lib/gloo/objs/cli/colorize.rb
gloo-1.2.5 lib/gloo/objs/cli/colorize.rb
gloo-1.2.4 lib/gloo/objs/cli/colorize.rb
gloo-1.2.3 lib/gloo/objs/cli/colorize.rb
gloo-1.2.2 lib/gloo/objs/cli/colorize.rb
gloo-1.2.0 lib/gloo/objs/cli/colorize.rb
gloo-1.1.0 lib/gloo/objs/cli/colorize.rb
gloo-1.0.0 lib/gloo/objs/cli/colorize.rb