Sha256: de4ceb74b96d8cf03b6ee1daa454b2ad9d0678743c28c20832f66224829e41e2

Contents?: true

Size: 1.84 KB

Versions: 6

Compression:

Stored size: 1.84 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# An abstract base verb.
# Derives from the Baseo object.
# It is a special type of object in that it can be run
# and can perform an action.
#

module GlooLang
  module Core
    class Verb < Baseo

      attr_reader :tokens, :params

      #
      # Set up the verb.
      #
      def initialize( tokens, params = [] )
        @tokens = tokens
        @params = params
      end

      #
      # Register verbs when they are loaded.
      #
      def self.inherited( subclass )
        Dictionary.instance.register_verb( subclass )
      end

      #
      # Run the verb.
      #
      # We'll mark the application as not running and let the
      # engine stop gracefully next time through the loop.
      #
      def run
        raise 'this method should be overriden'
      end

      #
      # Get the Verb's keyword.
      #
      # The keyword will be in lower case only.
      # It is used by the parser.
      #
      def self.keyword
        raise 'this method should be overriden'
      end

      #
      # Get the Verb's keyword shortcut.
      #
      def self.keyword_shortcut
        raise 'this method should be overriden'
      end

      #
      # The object type, suitable for display.
      #
      def type_display
        return self.class.keyword
      end

      #
      # Generic function to get display value.
      # Can be used for debugging, etc.
      #
      def display_value
        return self.class.keyword
      end

      # ---------------------------------------------------------------------
      #    Help
      # ---------------------------------------------------------------------

      #
      # Get help for this verb.
      #
      def self.help
        return 'No help found.'
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gloo-lang-0.9.8 lib/gloo_lang/core/verb.rb
gloo-lang-0.9.7 lib/gloo_lang/core/verb.rb
gloo-lang-0.9.6 lib/gloo_lang/core/verb.rb
gloo-lang-0.9.5 lib/gloo_lang/core/verb.rb
gloo-lang-0.9.4 lib/gloo_lang/core/verb.rb
gloo-lang-0.9.3 lib/gloo_lang/core/verb.rb