Class: Step
- Inherits:
-
Object
- Object
- Step
- Defined in:
- lib/tuvi/step.rb
Instance Attribute Summary collapse
-
#answer_paths ⇒ Object
Returns the value of attribute answer_paths.
-
#code_blocks ⇒ Object
Returns the value of attribute code_blocks.
-
#exit_program ⇒ Object
Returns the value of attribute exit_program.
-
#position ⇒ Object
Returns the value of attribute position.
Instance Method Summary collapse
- #answer(input, step_number) ⇒ Object
- #code(&block) ⇒ Object
- #formatted_answers ⇒ Object
- #get_message ⇒ Object
-
#initialize(position, &block) ⇒ Step
constructor
A new instance of Step.
- #message(text) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(position, &block) ⇒ Step
Returns a new instance of Step.
5 6 7 8 9 10 |
# File 'lib/tuvi/step.rb', line 5 def initialize(position, &block) @position = position @answer_paths = {} @code_blocks = [] instance_eval(&block) if block_given? end |
Instance Attribute Details
#answer_paths ⇒ Object
Returns the value of attribute answer_paths.
3 4 5 |
# File 'lib/tuvi/step.rb', line 3 def answer_paths @answer_paths end |
#code_blocks ⇒ Object
Returns the value of attribute code_blocks.
3 4 5 |
# File 'lib/tuvi/step.rb', line 3 def code_blocks @code_blocks end |
#exit_program ⇒ Object
Returns the value of attribute exit_program.
3 4 5 |
# File 'lib/tuvi/step.rb', line 3 def exit_program @exit_program end |
#position ⇒ Object
Returns the value of attribute position.
3 4 5 |
# File 'lib/tuvi/step.rb', line 3 def position @position end |
Instance Method Details
#answer(input, step_number) ⇒ Object
20 21 22 |
# File 'lib/tuvi/step.rb', line 20 def answer(input, step_number) @answer_paths[input.downcase] = step_number end |
#code(&block) ⇒ Object
32 33 34 |
# File 'lib/tuvi/step.rb', line 32 def code(&block) code_blocks << block end |
#formatted_answers ⇒ Object
28 29 30 |
# File 'lib/tuvi/step.rb', line 28 def formatted_answers "You can type one of the following: [#{@answer_paths.keys.join(", ")}] Enter 'exit' to quit." end |
#get_message ⇒ Object
16 17 18 |
# File 'lib/tuvi/step.rb', line 16 def @message end |
#message(text) ⇒ Object
12 13 14 |
# File 'lib/tuvi/step.rb', line 12 def (text) @message = text end |
#stop ⇒ Object
24 25 26 |
# File 'lib/tuvi/step.rb', line 24 def stop @exit_program = true end |