lib/gloo/exec/script.rb in gloo-3.1.1 vs lib/gloo/exec/script.rb in gloo-3.2.0
- old
+ new
@@ -7,17 +7,17 @@
module Gloo
module Exec
class Script
attr_accessor :obj
-
#
# Set up the script.
#
def initialize( engine, obj )
@engine = engine
@obj = obj
+ @break_out = false
end
#
# Run the script.
# The script might be a single string or an array
@@ -28,10 +28,11 @@
if @obj.value.is_a? String
@engine.parser.run @obj.value
elsif @obj.value.is_a? Array
@obj.value.each do |line|
+ break if @break_out
@engine.parser.run line
end
end
@engine.exec_env.pop_script
@@ -41,9 +42,16 @@
# Generic function to get display value.
# Can be used for debugging, etc.
#
def display_value
return @obj.pn
+ end
+
+ #
+ # Stop running this script.
+ #
+ def break_out
+ @break_out = true
end
end
end
end