Sha256: dc37aef9676c9b099f373ecc785515ace68430010c825d63cab6cfcca8f7c266

Contents?: true

Size: 972 Bytes

Versions: 29

Compression:

Stored size: 972 Bytes

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
#
# An action is a message sent to an object with optional parameters.
#

module GlooLang
  module Exec
    class Action

      attr_accessor :msg, :to, :params

      #
      # Set up the action.
      #
      def initialize( msg, to, params = nil )
        @msg = msg
        @to = to
        @params = params
      end

      #
      # The action is valid if the object can receive
      # the message specified.
      #
      def valid?
        return @to.can_receive_message?( @msg )
      end

      #
      # Execute the action.
      # Dispatch the message to the object.
      #
      def dispatch
        @to.send_message @msg, @params
      end

      #
      # Generic function to get display value.
      # Can be used for debugging, etc.
      #
      def display_value
        return "#{@msg} -> #{@to.pn}"
      end

    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
gloo-lang-0.9.11 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.10 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.9 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.8 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.7 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.6 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.5 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.4 lib/gloo_lang/exec/action.rb
gloo-lang-0.9.3 lib/gloo_lang/exec/action.rb