Class: Gamefic::Props::MultipleChoice
- Defined in:
- lib/gamefic/props/multiple_choice.rb
Overview
Props for MultipleChoice scenes.
Direct Known Subclasses
Instance Attribute Summary collapse
Attributes inherited from Default
#context, #input, #prompt, #scene
Instance Method Summary collapse
-
#index ⇒ Integer?
The zero-based index of the selected option.
-
#number ⇒ Integer?
The one-based index of the selected option.
-
#options ⇒ Array<String>
The array of available options.
-
#selection ⇒ String?
The full text of the selected option.
Methods inherited from Default
Constructor Details
This class inherits a constructor from Gamefic::Props::Default
Instance Attribute Details
#invalid_message ⇒ Object
21 22 23 |
# File 'lib/gamefic/props/multiple_choice.rb', line 21 def @invalid_message ||= '"%<input>s" is not a valid choice.' end |
Instance Method Details
#index ⇒ Integer?
The zero-based index of the selected option.
28 29 30 31 32 |
# File 'lib/gamefic/props/multiple_choice.rb', line 28 def index return nil unless input @index ||= index_by_number || index_by_text end |
#number ⇒ Integer?
The one-based index of the selected option.
37 38 39 40 41 |
# File 'lib/gamefic/props/multiple_choice.rb', line 37 def number return nil unless index index + 1 end |
#options ⇒ Array<String>
The array of available options.
17 18 19 |
# File 'lib/gamefic/props/multiple_choice.rb', line 17 def @options ||= [] end |
#selection ⇒ String?
The full text of the selected option.
46 47 48 49 50 |
# File 'lib/gamefic/props/multiple_choice.rb', line 46 def selection return nil unless index [index] end |