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

Overview

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

Included Modules

Direct Known Subclasses

Defined in:

question/abstract_choice.cr

Constructors

Instance Method Summary

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 : Indexable(T), default : Int | T | Nil = nil) #

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

[View source]

Instance Method Detail

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

Returns the possible choices.


[View source]
def error_message : String #

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


[View source]
def error_message=(error_message : String) : self #

[View source]
def prompt : String #

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


[View source]
def prompt=(prompt : String) #

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


[View source]
def validator : Proc(T | Nil, ChoiceType) | Nil #

See [Validating the Answer][Athena::Console::Question--validating-the-answer].


[View source]
def validator(&validator : T | Nil -> ChoiceType) : Nil #

Sets the validator callback to the provided block. See [Validating the Answer][Athena::Console::Question--validating-the-answer].


[View source]
def validator=(validator : Proc(T | Nil, ChoiceType) | Nil) #

See [Validating the Answer][Athena::Console::Question--validating-the-answer].


[View source]