Class: Gloo::Exec::Script

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/exec/script.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#objObject

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_outObject

Stop running this script.



52
53
54
# File 'lib/gloo/exec/script.rb', line 52

def break_out
  @break_out = true
end

#display_valueObject

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

#runObject

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