Class: Script::TopLevel
- Inherits:
-
Object
- Object
- Script::TopLevel
- Defined in:
- lib/script.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#triggers ⇒ Object
readonly
Returns the value of attribute triggers.
Instance Method Summary collapse
- #action(tag, &block) ⇒ Object
- #doit ⇒ Object
-
#initialize(logger, script_source) ⇒ TopLevel
constructor
A new instance of TopLevel.
-
#trigger(tag, &block) ⇒ Object
————————————————————— DSL.
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
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
12 13 14 |
# File 'lib/script.rb', line 12 def actions @actions end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/script.rb', line 12 def logger @logger end |
#triggers ⇒ Object (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 |
#doit ⇒ Object
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 |