Class: Gloo::Exec::Script
- Inherits:
-
Object
- Object
- Gloo::Exec::Script
- Defined in:
- lib/gloo/exec/script.rb
Instance Attribute Summary collapse
-
#obj ⇒ Object
Returns the value of attribute obj.
Instance Method Summary collapse
-
#break_out ⇒ Object
Stop running this script.
-
#display_value ⇒ Object
Generic function to get display value.
-
#initialize(engine, obj) ⇒ Script
constructor
Set up the script.
-
#run ⇒ Object
Run the script.
Constructor Details
#initialize(engine, obj) ⇒ Script
Set up the script.
15 16 17 18 19 |
# File 'lib/gloo/exec/script.rb', line 15 def initialize( engine, obj ) @engine = engine @obj = obj @break_out = false end |
Instance Attribute Details
#obj ⇒ Object
Returns the value of attribute obj.
11 12 13 |
# File 'lib/gloo/exec/script.rb', line 11 def obj @obj end |
Instance Method Details
#break_out ⇒ Object
Stop running this script.
52 53 54 |
# File 'lib/gloo/exec/script.rb', line 52 def break_out @break_out = true end |
#display_value ⇒ Object
Generic function to get display value. Can be used for debugging, etc.
45 46 47 |
# File 'lib/gloo/exec/script.rb', line 45 def display_value return @obj.pn end |
#run ⇒ Object
Run the script. The script might be a single string or an array of lines.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gloo/exec/script.rb', line 26 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| break if @break_out @engine.parser.run line end end @engine.exec_env.pop_script end |