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

Overview

Similar to ACON::Question::Choice, but allows for more than one answer to be selected. This question accepts a comma separated list of answers.

question = ACON::Question::MultipleChoice.new "What is your favorite color?", {"red", "blue", "green"}
answer = helper.ask input, output, question

This question is also similar to ACON::Question::Choice in that you can provide either the index, key, or value of the choice. For example submitting green,0 would result in ["green", "red"] as the value of answer.

Defined in:

question/multiple_choice.cr

Constructors

Instance methods inherited from class Athena::Console::Question::AbstractChoice(T, Array(T))

choices : Hash(String | Int32, T) choices, error_message : String error_message, error_message=(error_message : String) : self error_message=, prompt : String prompt, prompt=(prompt : String) prompt=, validator : Proc(T | Nil, ChoiceType(T)) | Nil
validator(&validator : T | Nil -> ChoiceType(T)) : Nil
validator
, validator=(validator : Proc(T | Nil, ChoiceType(T)) | Nil) validator=

Constructor methods inherited from class Athena::Console::Question::AbstractChoice(T, Array(T))

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

Instance methods inherited from module Athena::Console::Question::Base(T?)

default : T? default, hidden=(hidden : Bool) : self hidden=, hidden? : Bool hidden?, hidden_fallback=(hidden_fallback : Bool) hidden_fallback=, hidden_fallback? : Bool hidden_fallback?, max_attempts : Int32 | Nil max_attempts, max_attempts=(attempts : Int32 | Nil) : self max_attempts=, multi_line=(multi_line : Bool) multi_line=, multi_line? : Bool multi_line?, normalizer : Proc(T? | String, T?) | Nil
normalizer(&normalizer : T? | String -> T?) : Nil
normalizer
, normalizer=(normalizer : Proc(T? | String, T?) | Nil) normalizer=, question : String question, trimmable=(trimmable : Bool) trimmable=, trimmable? : Bool trimmable?

Constructor methods inherited from module Athena::Console::Question::Base(T?)

new(question : String, default : T?) new

Constructor Detail

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

[View source]
def self.new(question : String, choices : Indexable(T), default : Int | T | Nil = nil) #

[View source]