Skip to content

abstract class Athena::Console::Question::AbstractChoice(T, ChoiceType)
inherits Reference #

Base type of choice based questions. See each subclass for more information.

Included modules

Athena::Console::Question::Base

Direct known subclasses

Athena::Console::Question::Choice(T) Athena::Console::Question::MultipleChoice(T)

Constructors#

.new(question : String, choices : Indexable(T), default : Int | T | Nil = nil)#

.new(question : String, choices : Hash(String | Int32, T), default : T | Nil = nil)#

Methods#

#choices : Hash(String | Int32, T)#

Returns the possible choices.

#error_message : String#

Returns the message to display if the provided answer is not a valid choice.

#error_message=(error_message : String) : self#

#prompt : String#

Returns/sets the prompt to use for the question. The prompt being the character(s) before the user input.

#prompt=(prompt : String)#

Returns/sets the prompt to use for the question. The prompt being the character(s) before the user input.

#validator : Proc(T | ::Nil, ChoiceType) | ::Nil#

#validator : Nil#

Sets the validator callback to the provided block. See Validating the Answer.

#validator=(validator : Proc(T | Nil, ChoiceType) | Nil)#