Sha256: 297d8d2952aea674f6227733a24aa7fcae703b9d13892182133f9c156ffbf003

Contents?: true

Size: 1.43 KB

Versions: 20

Compression:

Stored size: 1.43 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# Show a single object's value.
#

module Gloo
  module Verbs
    class Show < Gloo::Core::Verb

      KEYWORD = 'show'.freeze
      KEYWORD_SHORT = '='.freeze

      #
      # Run the verb.
      #
      def run
        if @tokens.token_count > 1
          expr = Gloo::Expr::Expression.new( @engine, @tokens.params )
          result = expr.evaluate
          @engine.log.show get_formatted_string( result )
          @engine.heap.it.set_to result
        else
          @engine.log.show ''
        end
      end

      #
      # Get the Verb's keyword.
      #
      def self.keyword
        return KEYWORD
      end

      #
      # Get the Verb's keyword shortcut.
      #
      def self.keyword_shortcut
        return KEYWORD_SHORT
      end

      # ---------------------------------------------------------------------
      #    Private functions
      # ---------------------------------------------------------------------

      private

      #
      # Get the formatted string.
      #
      def get_formatted_string( str )
        if @params&.token_count&.positive?
          expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
          val = expr.evaluate
          color = val.to_sym
          return @engine.platform.getColorizedString( str, color )
        end
        return str
      end

    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
gloo-3.5.0 lib/gloo/verbs/show.rb
gloo-3.4.1 lib/gloo/verbs/show.rb
gloo-3.4.0 lib/gloo/verbs/show.rb
gloo-3.3.0 lib/gloo/verbs/show.rb
gloo-3.2.0 lib/gloo/verbs/show.rb
gloo-3.1.1 lib/gloo/verbs/show.rb
gloo-3.1.0 lib/gloo/verbs/show.rb
gloo-3.0.1 lib/gloo/verbs/show.rb
gloo-3.0.0 lib/gloo/verbs/show.rb
gloo-2.5.0 lib/gloo/verbs/show.rb
gloo-2.4.3 lib/gloo/verbs/show.rb
gloo-2.4.2 lib/gloo/verbs/show.rb
gloo-2.4.1 lib/gloo/verbs/show.rb
gloo-2.4.0 lib/gloo/verbs/show.rb
gloo-2.3.1 lib/gloo/verbs/show.rb
gloo-2.2.0 lib/gloo/verbs/show.rb
gloo-2.1.0 lib/gloo/verbs/show.rb
gloo-2.0.2 lib/gloo/verbs/show.rb
gloo-2.0.1 lib/gloo/verbs/show.rb
gloo-2.0.0 lib/gloo/verbs/show.rb