Class: Gamefic::Scene::MultipleChoice
- Defined in:
- lib/gamefic/scene/multiple_choice.rb
Overview
Provide a list of options and process the selection in the scene’s finish block. After the scene is finished, the :active scene will be cued unless some other scene has already been prepared or cued.
The finish block’s input parameter receives a MultipleChoice::Input object instead of a String.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
- #invalid_message ⇒ Object
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#selection ⇒ Object
readonly
Returns the value of attribute selection.
Attributes inherited from Base
#actor, #input, #prompt, #type
Instance Method Summary collapse
Methods inherited from Base
#finished?, #flush, #initialize, #on_finish, on_start, #start, start_block, subclass, #update
Constructor Details
This class inherits a constructor from Gamefic::Scene::Base
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
11 12 13 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 11 def index @index end |
#invalid_message ⇒ Object
35 36 37 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 35 def @invalid_message ||= 'That is not a valid choice.' end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
12 13 14 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 12 def number @number end |
#selection ⇒ Object (readonly)
Returns the value of attribute selection.
13 14 15 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 13 def selection @selection end |
Instance Method Details
#finish ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 21 def finish get_choice if selection.nil? actor.tell else super end end |
#options ⇒ Object
31 32 33 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 31 def @options ||= [] end |
#post_initialize ⇒ Object
16 17 18 19 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 16 def post_initialize self.type = 'MultipleChoice' self.prompt = 'Enter a choice:' end |
#state ⇒ Object
39 40 41 |
# File 'lib/gamefic/scene/multiple_choice.rb', line 39 def state super.merge options: end |