Sha256: e5c0813bc5fed30b6dadc34fb53e09ca85fc2ffb845e253290027e6df0774287

Contents?: true

Size: 960 Bytes

Versions: 15

Compression:

Stored size: 960 Bytes

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# A script to be run.
#

module Gloo
  module Exec
    class Script

      attr_accessor :obj

      #
      # Set up the script.
      #
      def initialize( engine, obj )
        @engine = engine
        @obj = obj
      end

      #
      # Run the script.
      # The script might be a single string or an array
      # of lines.
      #
      def run
        @engine.exec_env.push_script self

        if @obj.value.is_a? String
          @engine.parser.run @obj.value
        elsif @obj.value.is_a? Array
          @obj.value.each do |line|
            @engine.parser.run line
          end
        end

        @engine.exec_env.pop_script
      end

      #
      # Generic function to get display value.
      # Can be used for debugging, etc.
      #
      def display_value
        return @obj.pn
      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gloo-3.1.1 lib/gloo/exec/script.rb
gloo-3.1.0 lib/gloo/exec/script.rb
gloo-3.0.1 lib/gloo/exec/script.rb
gloo-3.0.0 lib/gloo/exec/script.rb
gloo-2.5.0 lib/gloo/exec/script.rb
gloo-2.4.3 lib/gloo/exec/script.rb
gloo-2.4.2 lib/gloo/exec/script.rb
gloo-2.4.1 lib/gloo/exec/script.rb
gloo-2.4.0 lib/gloo/exec/script.rb
gloo-2.3.1 lib/gloo/exec/script.rb
gloo-2.2.0 lib/gloo/exec/script.rb
gloo-2.1.0 lib/gloo/exec/script.rb
gloo-2.0.2 lib/gloo/exec/script.rb
gloo-2.0.1 lib/gloo/exec/script.rb
gloo-2.0.0 lib/gloo/exec/script.rb