Class: Step

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathsObject

Returns the value of attribute answer_paths.



3
4
5
# File 'lib/tuvi/step.rb', line 3

def answer_paths
  @answer_paths
end

#code_blocksObject

Returns the value of attribute code_blocks.



3
4
5
# File 'lib/tuvi/step.rb', line 3

def code_blocks
  @code_blocks
end

#exit_programObject

Returns the value of attribute exit_program.



3
4
5
# File 'lib/tuvi/step.rb', line 3

def exit_program
  @exit_program
end

#positionObject

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_answersObject



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_messageObject



16
17
18
# File 'lib/tuvi/step.rb', line 16

def get_message
  @message
end

#message(text) ⇒ Object



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

def message(text)
  @message = text
end

#stopObject



24
25
26
# File 'lib/tuvi/step.rb', line 24

def stop
  @exit_program = true
end