Class: Weaver::Action
- Inherits:
-
Object
- Object
- Weaver::Action
- Defined in:
- lib/weaver/element_types/action.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(page, anchors, &block) ⇒ Action
constructor
A new instance of Action.
- #name ⇒ Object
- #script(code) ⇒ Object
Constructor Details
#initialize(page, anchors, &block) ⇒ Action
Returns a new instance of Action.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/weaver/element_types/action.rb', line 5 def initialize(page, anchors, &block) @page = page @anchors = anchors actionsArray = @anchors['action'] @anchors['action'] = [] unless @anchors['action'] actionsArray = @anchors['action'] @actionName = "action#{actionsArray.length}" actionsArray << @actionName @code = '' instance_eval(&block) end |
Instance Method Details
#generate ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/weaver/element_types/action.rb', line 27 def generate # puts @code <<~FUNCTION function #{@actionName}(caller, data) { #{@code} } FUNCTION end |
#name ⇒ Object
36 37 38 |
# File 'lib/weaver/element_types/action.rb', line 36 def name @actionName end |
#script(code) ⇒ Object
23 24 25 |
# File 'lib/weaver/element_types/action.rb', line 23 def script(code) @code = code end |