Class: Script::TopLevel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, script_source) ⇒ TopLevel

Returns a new instance of TopLevel.



5
6
7
8
9
10
# File 'lib/script.rb', line 5

def initialize(logger, script_source)
  @logger = logger
  @triggers = {}
  @actions = {}
  instance_eval(script_source)
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



12
13
14
# File 'lib/script.rb', line 12

def actions
  @actions
end

#loggerObject (readonly)

Returns the value of attribute logger.



12
13
14
# File 'lib/script.rb', line 12

def logger
  @logger
end

#triggersObject (readonly)

Returns the value of attribute triggers.



12
13
14
# File 'lib/script.rb', line 12

def triggers
  @triggers
end

Instance Method Details

#action(tag, &block) ⇒ Object



26
27
28
# File 'lib/script.rb', line 26

def action(tag, &block)
  @actions[tag] = Action.new(self, &block)
end

#doitObject



14
15
16
17
18
# File 'lib/script.rb', line 14

def doit
  @triggers.each do |k, t|
    t.doit
  end
end

#trigger(tag, &block) ⇒ Object


DSL



22
23
24
# File 'lib/script.rb', line 22

def trigger(tag, &block)
  @triggers[tag] = Trigger.new(self, &block)
end