Class: Pushpop::Step
- Inherits:
-
Object
- Object
- Pushpop::Step
- Defined in:
- lib/pushpop/step.rb
Defined Under Namespace
Classes: ERBContext
Constant Summary collapse
- TEMPLATES_DIRECTORY =
File.('templates', Dir.pwd)
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#name ⇒ Object
Returns the value of attribute name.
-
#plugin ⇒ Object
Returns the value of attribute plugin.
Instance Method Summary collapse
-
#initialize(name = nil, plugin = nil, &block) ⇒ Step
constructor
A new instance of Step.
- #run(last_response = nil, step_responses = nil) ⇒ Object
- #template(filename, response, step_responses = {}, directory = TEMPLATES_DIRECTORY) ⇒ Object
Constructor Details
#initialize(name = nil, plugin = nil, &block) ⇒ Step
Returns a new instance of Step.
27 28 29 30 31 |
# File 'lib/pushpop/step.rb', line 27 def initialize(name=nil, plugin=nil, &block) self.name = name || plugin || Pushpop.random_name self.plugin = plugin self.block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
25 26 27 |
# File 'lib/pushpop/step.rb', line 25 def block @block end |
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/pushpop/step.rb', line 23 def name @name end |
#plugin ⇒ Object
Returns the value of attribute plugin.
24 25 26 |
# File 'lib/pushpop/step.rb', line 24 def plugin @plugin end |
Instance Method Details
#run(last_response = nil, step_responses = nil) ⇒ Object
38 39 40 |
# File 'lib/pushpop/step.rb', line 38 def run(last_response=nil, step_responses=nil) self.instance_exec(last_response, step_responses, &block) end |
#template(filename, response, step_responses = {}, directory = TEMPLATES_DIRECTORY) ⇒ Object
33 34 35 36 |
# File 'lib/pushpop/step.rb', line 33 def template(filename, response, step_responses={}, directory=TEMPLATES_DIRECTORY) erb_context = ERBContext.new(response, step_responses) ERB.new(get_template_contents(filename, directory)).result(erb_context.get_binding) end |